diff --git a/plugins/card-resources/src/components/settings/EditRole.svelte b/plugins/card-resources/src/components/settings/EditRole.svelte index 8fff6c0c9c0..b30dcba6428 100644 --- a/plugins/card-resources/src/components/settings/EditRole.svelte +++ b/plugins/card-resources/src/components/settings/EditRole.svelte @@ -20,6 +20,7 @@ Class, ClassPermission, Doc, + notEmpty, Permission, Ref } from '@hcengineering/core' @@ -58,7 +59,8 @@ .getModel() .findAllSync(cardPlugin.class.PermissionObjectClass, {}) .map((poc) => poc.objectClass) - const tagDesc = Array.from(new Set(role?.types?.map((p) => [...h.getAncestors(p), ...h.getDescendants(p)]).flat())) + const types = role?.types?.map((p) => h.findClass(p)).filter(notEmpty) + const tagDesc = Array.from(new Set(types?.map((p) => [...h.getAncestors(p._id), ...h.getDescendants(p._id)]).flat())) const allPermissions = client.getModel().findAllSync(core.class.Permission, { scope: 'space', objectClass: { $in: [...cardPermissionsObjectClasses, ...tagDesc] } diff --git a/plugins/card-resources/src/exporter.ts b/plugins/card-resources/src/exporter.ts index 3e370d177d8..f1d26bbfdec 100644 --- a/plugins/card-resources/src/exporter.ts +++ b/plugins/card-resources/src/exporter.ts @@ -133,6 +133,9 @@ async function exportType (_id: Ref>, processed: Set>): Prom if (type.icon === view.ids.IconWithEmoji && typeof type.color === 'string') { type.icon = card.icon.Card } + + res.push(...m.findAllSync(view.class.Viewlet, { attachTo: _id })) + res.push(type) res.push(...m.findAllSync(core.class.ClassPermission, { targetClass: _id })) @@ -152,8 +155,6 @@ async function exportType (_id: Ref>, processed: Set>): Prom res.push(...m.findAllSync(card.class.Role, { types: _id })) - res.push(...m.findAllSync(view.class.Viewlet, { attachTo: _id })) - const assocA = m.findAllSync(core.class.Association, { classA: _id }) for (const assoc of assocA) { res.push(assoc) diff --git a/server-plugins/card-resources/src/index.ts b/server-plugins/card-resources/src/index.ts index c9cc581993f..b6c2f6ea125 100644 --- a/server-plugins/card-resources/src/index.ts +++ b/server-plugins/card-resources/src/index.ts @@ -262,7 +262,12 @@ async function OnMasterTagCreate (ctx: TxCreateDoc[], control: attachTo: tag.extends, variant: { $exists: false } }) + const existingViewlets = await control.findAll(control.ctx, view.class.Viewlet, { + attachTo: createTx.objectId, + variant: { $exists: false } + }) for (const viewlet of viewlets) { + if (existingViewlets.find((it) => it.descriptor === viewlet.descriptor) !== undefined) continue const base = extractObjectData(viewlet) res.push( control.txFactory.createTxCreateDoc(view.class.Viewlet, core.space.Model, {