Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Class,
ClassPermission,
Doc,
notEmpty,
Permission,
Ref
} from '@hcengineering/core'
Expand Down Expand Up @@ -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] }
Expand Down
5 changes: 3 additions & 2 deletions plugins/card-resources/src/exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ async function exportType (_id: Ref<Class<Doc>>, processed: Set<Ref<Doc>>): 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 }))
Expand All @@ -152,8 +155,6 @@ async function exportType (_id: Ref<Class<Doc>>, processed: Set<Ref<Doc>>): 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)
Expand Down
5 changes: 5 additions & 0 deletions server-plugins/card-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ async function OnMasterTagCreate (ctx: TxCreateDoc<MasterTag | Tag>[], 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, {
Expand Down
Loading