mirror of
https://github.com/hcengineering/platform.git
synced 2025-03-14 18:15:01 +00:00
more card fixes (#8077)
Some checks are pending
CI / build (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
This commit is contained in:
parent
ce10156fe4
commit
355025d56a
@ -32,6 +32,15 @@ export function createModel (builder: Builder): void {
|
||||
}
|
||||
})
|
||||
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverCard.trigger.OnAttributeRemove,
|
||||
isAsync: true,
|
||||
txMatch: {
|
||||
_class: core.class.TxRemoveDoc,
|
||||
objectClass: core.class.Attribute
|
||||
}
|
||||
})
|
||||
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverCard.trigger.OnMasterTagRemove,
|
||||
isAsync: true,
|
||||
|
@ -760,7 +760,7 @@ export class LiveQuery implements WithTx, Client {
|
||||
}
|
||||
const docs = q.result.getDocs()
|
||||
for (const doc of docs) {
|
||||
const docToUpdate = doc.$associations?.[association._id].find((it) => it._id === tx.objectId)
|
||||
const docToUpdate = doc.$associations?.[association._id]?.find((it) => it._id === tx.objectId)
|
||||
if (docToUpdate !== undefined) {
|
||||
if (tx._class === core.class.TxMixin) {
|
||||
TxProcessor.updateMixin4Doc(docToUpdate, tx as TxMixin<Doc, Doc>)
|
||||
|
@ -14,7 +14,7 @@
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { MasterTag } from '@hcengineering/card'
|
||||
import { Ref } from '@hcengineering/core'
|
||||
import core, { Ref } from '@hcengineering/core'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
BreadcrumbItem,
|
||||
@ -46,7 +46,7 @@
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
const query = createQuery()
|
||||
$: query.query(card.class.MasterTag, { _id: selectedTagId }, (res) => {
|
||||
$: query.query(core.class.Class, { _id: selectedTagId }, (res) => {
|
||||
masterTag = res[0]
|
||||
})
|
||||
|
||||
|
@ -19,7 +19,7 @@ export * from './analytics'
|
||||
|
||||
export interface MasterTag extends Class<Card> {}
|
||||
|
||||
export interface Tag extends Mixin<Card> {}
|
||||
export interface Tag extends MasterTag, Mixin<Card> {}
|
||||
|
||||
export interface Card extends Doc {
|
||||
attachments?: number
|
||||
|
@ -34,11 +34,43 @@ async function OnAttribute (ctx: TxCreateDoc<AnyAttribute>[], control: TriggerCo
|
||||
)
|
||||
const prefs = await control.findAll(control.ctx, view.class.ViewletPreference, { attachedTo: viewlet._id })
|
||||
for (const pref of prefs) {
|
||||
pref.config.push(attr.name)
|
||||
res.push(
|
||||
control.txFactory.createTxUpdateDoc(pref._class, pref.space, pref._id, {
|
||||
config: pref.config
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
async function OnAttributeRemove (ctx: TxRemoveDoc<AnyAttribute>[], control: TriggerControl): Promise<Tx[]> {
|
||||
const attr = control.removedMap.get(ctx[0].objectId) as AnyAttribute
|
||||
if (attr === undefined) return []
|
||||
if (control.hierarchy.isDerived(attr.attributeOf, card.class.Card)) {
|
||||
const desc = control.hierarchy.getDescendants(attr.attributeOf)
|
||||
const res: Tx[] = []
|
||||
for (const des of desc) {
|
||||
const viewlets = control.modelDb.findAllSync(view.class.Viewlet, { attachTo: des })
|
||||
for (const viewlet of viewlets) {
|
||||
viewlet.config = viewlet.config.filter((p) => p !== attr.name)
|
||||
res.push(
|
||||
control.txFactory.createTxUpdateDoc(viewlet._class, viewlet.space, viewlet._id, {
|
||||
config: viewlet.config
|
||||
})
|
||||
)
|
||||
const prefs = await control.findAll(control.ctx, view.class.ViewletPreference, { attachedTo: viewlet._id })
|
||||
for (const pref of prefs) {
|
||||
pref.config = pref.config.filter((p) => p !== attr.name)
|
||||
res.push(
|
||||
control.txFactory.createTxUpdateDoc(pref._class, pref.space, pref._id, {
|
||||
config: pref.config
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,6 +104,7 @@ async function OnMasterTagRemove (ctx: TxRemoveDoc<MasterTag>[], control: Trigge
|
||||
export default async () => ({
|
||||
trigger: {
|
||||
OnAttribute,
|
||||
OnAttributeRemove,
|
||||
OnMasterTagRemove
|
||||
}
|
||||
})
|
||||
|
@ -28,6 +28,7 @@ export const serverCardId = 'server-card' as Plugin
|
||||
export default plugin(serverCardId, {
|
||||
trigger: {
|
||||
OnAttribute: '' as Resource<TriggerFunc>,
|
||||
OnAttributeRemove: '' as Resource<TriggerFunc>,
|
||||
OnMasterTagRemove: '' as Resource<TriggerFunc>
|
||||
}
|
||||
})
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import core, {
|
||||
Domain,
|
||||
DOMAIN_MODEL,
|
||||
groupByArray,
|
||||
TxProcessor,
|
||||
withContext,
|
||||
@ -86,6 +87,14 @@ export class DomainTxMiddleware extends BaseMiddleware implements Middleware {
|
||||
const deleteByDomain = groupByArray(toDelete, (it) => this.context.hierarchy.getDomain(it.objectClass))
|
||||
|
||||
for (const [domain, domainTxes] of deleteByDomain.entries()) {
|
||||
if (domain === DOMAIN_MODEL) {
|
||||
for (const tx of domainTxes) {
|
||||
const ddoc = this.context.modelDb.findObject(tx.objectId)
|
||||
if (ddoc !== undefined) {
|
||||
ctx.contextData.removedMap.set(ddoc._id, ddoc)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const todel = await ctx.with(
|
||||
'adapter-load',
|
||||
{},
|
||||
@ -103,6 +112,7 @@ export class DomainTxMiddleware extends BaseMiddleware implements Middleware {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const classes = Array.from(new Set(txes.map((it) => it.objectClass)))
|
||||
const _classes = Array.from(new Set(txes.map((it) => it._class)))
|
||||
|
Loading…
Reference in New Issue
Block a user