From 572f286fecd256235f57d7cbea565346546bd058 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Sun, 10 May 2026 21:50:26 +0500 Subject: [PATCH] Fix markup check Signed-off-by: Denis Bykhov --- .../src/components/CardArrayEditor.svelte | 16 +++++++++-- .../src/components/MarkupProperties.svelte | 1 - plugins/process-resources/src/utils.ts | 15 ++++++---- .../process-resources/src/functions.ts | 28 +++++++++++++------ 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/plugins/card-resources/src/components/CardArrayEditor.svelte b/plugins/card-resources/src/components/CardArrayEditor.svelte index 2c5b422723e..b7c3d3d6b57 100644 --- a/plugins/card-resources/src/components/CardArrayEditor.svelte +++ b/plugins/card-resources/src/components/CardArrayEditor.svelte @@ -24,7 +24,7 @@ import CardsPopup from './CardsPopup.svelte' export let _class: Ref> | undefined = undefined - export let value: Ref[] | undefined + export let value: Ref[] | Ref | undefined export let readonly: boolean = false export let label: IntlString | undefined export let onChange: ((value: any) => void) | undefined @@ -60,13 +60,23 @@ showPopup( CardsPopup, - { selectedObjects: value, _class, multiSelect: true }, + { selectedObjects: toArray(value), _class, multiSelect: true }, eventToHTMLElement(event), undefined, change ) } + function toArray (value: Ref[] | Ref | undefined): Ref[] { + if (Array.isArray(value)) { + return value + } + if (value === undefined) { + return [] + } + return [value] + } + const change = (value: Ref[]): void => { onChange?.(value) dispatch('change', value) @@ -75,7 +85,7 @@ let docs: Card[] = [] const query = createQuery() - $: query.query(card.class.Card, { _id: { $in: value ?? [] } }, (res) => { + $: query.query(card.class.Card, { _id: { $in: toArray(value) } }, (res) => { docs = res }) diff --git a/plugins/card-resources/src/components/MarkupProperties.svelte b/plugins/card-resources/src/components/MarkupProperties.svelte index 15fc8e9bdc9..d0a6b1d8f4a 100644 --- a/plugins/card-resources/src/components/MarkupProperties.svelte +++ b/plugins/card-resources/src/components/MarkupProperties.svelte @@ -66,7 +66,6 @@
, client: Client): Record { +function getMarkupParams (process: Process, params: Record, client: Client): Record { const markup: Record = {} for (const [key, value] of Object.entries(params)) { - const attr = client.getHierarchy().findAttribute(card._class, key) + const attr = client.getHierarchy().findAttribute(process.masterTag, key) if (attr?.type?._class === core.class.TypeMarkup) { markup[key] = value } @@ -846,7 +846,7 @@ export function matchCardCheck ( if (client.getHierarchy().isMixin(process.masterTag)) { doc = client.getHierarchy().as(doc, process.masterTag) } - const markup = getMarkupParams(doc, params, client) + const markup = getMarkupParams(process, params, client) for (const key of Object.keys(markup)) { if (isEmptyMarkup(doc[key])) return false } @@ -861,12 +861,17 @@ export function fieldChangesCheck ( params: Record, context: Record ): boolean { - const doc = context.card + let doc = context.card if (doc === undefined) return false + const process = client.getModel().findObject(execution.process) + if (process === undefined) return false + if (client.getHierarchy().isMixin(process.masterTag)) { + doc = client.getHierarchy().as(doc, process.masterTag) + } const operations = (context.operations ?? {}) as DocumentUpdate const target = Object.keys(params)[0] if (!TxProcessor.hasUpdate(operations, target)) return false - const markup = getMarkupParams(doc, params, client) + const markup = getMarkupParams(process, params, client) for (const key of Object.keys(markup)) { if (isEmptyMarkup(doc[key])) return false } diff --git a/server-plugins/process-resources/src/functions.ts b/server-plugins/process-resources/src/functions.ts index ad9e4dc271b..0797c99114d 100644 --- a/server-plugins/process-resources/src/functions.ts +++ b/server-plugins/process-resources/src/functions.ts @@ -144,22 +144,27 @@ export function MatchCardCheck ( params: Record, context: Record ): boolean { - if (context.card === undefined) return false + let card = context.card + if (card === undefined) return false const process = control.client.getModel().findObject(execution.process) if (process === undefined) return false - const markup = getMarkupParams(context.card, params, control) + const markup = getMarkupParams(process, params, control) + const h = control.client.getHierarchy() + if (h.isMixin(process.masterTag)) { + card = h.as(card, process.masterTag) + } for (const key of Object.keys(markup)) { - if (isEmptyMarkup(context.card[key])) return false + if (isEmptyMarkup(card[key])) return false } - const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true) + const res = matchQuery([card], params, process.masterTag, control.client.getHierarchy(), true) return res.length > 0 } -function getMarkupParams (card: Card, params: Record, control: ProcessControl): Record { +function getMarkupParams (process: Process, params: Record, control: ProcessControl): Record { const markup: Record = {} for (const [key, value] of Object.entries(params)) { - const attr = control.client.getHierarchy().findAttribute(card._class, key) + const attr = control.client.getHierarchy().findAttribute(process.masterTag, key) if (attr?.type?._class === core.class.TypeMarkup) { markup[key] = value } @@ -190,12 +195,17 @@ export function FieldChangedCheck ( const operations = context.operations as DocumentUpdate const target = Object.keys(params)[0] if (!TxProcessor.hasUpdate(operations, target)) return false - const markup = getMarkupParams(context.card, params, control) + const markup = getMarkupParams(process, params, control) + const h = control.client.getHierarchy() + let card = context.card + if (h.isMixin(process.masterTag)) { + card = h.as(card, process.masterTag) + } for (const key of Object.keys(markup)) { - if (isEmptyMarkup(context.card[key])) return false + if (isEmptyMarkup(card[key])) return false } - const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true) + const res = matchQuery([card], params, process.masterTag, control.client.getHierarchy(), true) return res.length > 0 }