mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-11 01:40:32 +00:00
Fix duplication of views (#8450)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
a4166b220d
commit
cacb6036ee
@ -40,11 +40,27 @@ export const cardOperation: MigrateOperation = {
|
||||
{
|
||||
state: 'migrateViewlets-v2',
|
||||
func: migrateViewlets
|
||||
},
|
||||
{
|
||||
state: 'removeVariantViewlets',
|
||||
func: removeVariantViewlets
|
||||
}
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
async function removeVariantViewlets (client: Client): Promise<void> {
|
||||
const txOp = new TxOperations(client, core.account.System)
|
||||
const desc = client
|
||||
.getHierarchy()
|
||||
.getDescendants(card.class.Card)
|
||||
.filter((c) => c !== card.class.Card)
|
||||
const viewlets = await client.findAll(view.class.Viewlet, { attachTo: { $in: desc }, variant: { $exists: true } })
|
||||
for (const viewlet of viewlets) {
|
||||
await txOp.remove(viewlet)
|
||||
}
|
||||
}
|
||||
|
||||
async function setParentInfo (client: MigrationClient): Promise<void> {
|
||||
await client.update(
|
||||
DOMAIN_CARD,
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
import { MasterTag } from '@hcengineering/card'
|
||||
import { WithLookup } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import { createQuery } from '@hcengineering/presentation'
|
||||
import setting from '@hcengineering/setting'
|
||||
import { clearSettingsStore, settingsStore } from '@hcengineering/setting-resources'
|
||||
import { ButtonIcon, Icon, IconAdd, Label, showPopup } from '@hcengineering/ui'
|
||||
@ -29,14 +29,12 @@
|
||||
export let masterTag: MasterTag
|
||||
|
||||
let viewlets: WithLookup<Viewlet>[] = []
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
const query = createQuery()
|
||||
|
||||
$: query.query(
|
||||
view.class.Viewlet,
|
||||
{ attachTo: { $in: hierarchy.getDescendants(masterTag._id) } },
|
||||
{ attachTo: masterTag._id, variant: { $exists: false } },
|
||||
(res) => {
|
||||
viewlets = res
|
||||
},
|
||||
|
@ -216,7 +216,10 @@ async function OnMasterTagCreate (ctx: TxCreateDoc<MasterTag | Tag>[], control:
|
||||
control.txFactory.createTxMixin(createTx.objectId, core.class.Mixin, core.space.Model, setting.mixin.UserMixin, {})
|
||||
)
|
||||
if (tag._class === card.class.MasterTag) {
|
||||
const viewlets = await control.findAll(control.ctx, view.class.Viewlet, { attachTo: tag.extends })
|
||||
const viewlets = await control.findAll(control.ctx, view.class.Viewlet, {
|
||||
attachTo: tag.extends,
|
||||
variant: { $exists: false }
|
||||
})
|
||||
for (const viewlet of viewlets) {
|
||||
const base = extractObjectProps(viewlet)
|
||||
res.push(
|
||||
|
Loading…
Reference in New Issue
Block a user