From c6738a02cb94c84e48d91d38eedd6cf17fd1e722 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Sun, 3 May 2026 15:53:23 +0500 Subject: [PATCH] markup check filled (#10817) Signed-off-by: Denis Bykhov --- common/config/rush/pnpm-lock.yaml | 3 +++ models/process/src/index.ts | 18 +++++++++++++++ plugins/process-resources/package.json | 1 + plugins/process-resources/src/utils.ts | 22 +++++++++++++++++++ .../process-resources/src/functions.ts | 22 +++++++++++++++++++ 5 files changed, 66 insertions(+) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index e8d4c7c1da..de433b45da 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -24762,6 +24762,9 @@ importers: '@hcengineering/setting-resources': specifier: workspace:^0.7.0 version: link:../setting-resources + '@hcengineering/text-core': + specifier: workspace:^0.7.19 + version: link:../../foundations/core/packages/text-core '@hcengineering/time': specifier: workspace:^0.7.0 version: link:../time diff --git a/models/process/src/index.ts b/models/process/src/index.ts index 5d1b9008a1..5f939b9f42 100644 --- a/models/process/src/index.ts +++ b/models/process/src/index.ts @@ -797,6 +797,24 @@ export function createModel (builder: Builder): void { } }) + builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, { + category: 'attribute', + editor: process.criteriaEditor.BaseCriteria, + of: core.class.TypeMarkup, + props: { + modes: ['StringContains', 'Exists'] + } + }) + + builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, { + category: 'inplace', + editor: process.criteriaEditor.BaseCriteria, + of: core.class.TypeMarkup, + props: { + modes: ['StringContains', 'Exists'] + } + }) + builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, { category: 'attribute', editor: process.criteriaEditor.BaseCriteria, diff --git a/plugins/process-resources/package.json b/plugins/process-resources/package.json index 2dcb202441..efac93f482 100644 --- a/plugins/process-resources/package.json +++ b/plugins/process-resources/package.json @@ -59,6 +59,7 @@ "@hcengineering/platform": "workspace:^0.7.20", "@hcengineering/process": "workspace:^0.7.0", "@hcengineering/login": "workspace:^0.7.0", + "@hcengineering/text-core": "workspace:^0.7.19", "@hcengineering/account-client": "workspace:^0.7.25", "svelte": "^4.2.20", "fast-equals": "^5.2.2" diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 18eaab1e90..6288460aa6 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -58,6 +58,7 @@ import { type UpdateCriteriaComponent, type UserResult } from '@hcengineering/process' +import { isEmptyMarkup } from '@hcengineering/text-core' import { showPopup } from '@hcengineering/ui' import { type AttributeCategory } from '@hcengineering/view' import process from './plugin' @@ -821,6 +822,17 @@ export async function approveRequestRejected ( return context.todo?.group === params._id && context.todo?.approved === false } +function getMarkupParams (card: Card, params: Record, client: Client): Record { + const markup: Record = {} + for (const [key, value] of Object.entries(params)) { + const attr = client.getHierarchy().findAttribute(card._class, key) + if (attr?.type?._class === core.class.TypeMarkup) { + markup[key] = value + } + } + return markup +} + export function matchCardCheck ( client: Client, execution: Execution, @@ -834,6 +846,11 @@ export function matchCardCheck ( if (client.getHierarchy().isMixin(process.masterTag)) { doc = client.getHierarchy().as(doc, process.masterTag) } + const markup = getMarkupParams(doc, params, client) + for (const key of Object.keys(markup)) { + if (isEmptyMarkup(doc[key])) return false + } + const res = matchQuery([doc], params, doc._class, client.getHierarchy(), true) return res.length > 0 } @@ -849,6 +866,11 @@ export function fieldChangesCheck ( 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) + for (const key of Object.keys(markup)) { + if (isEmptyMarkup(doc[key])) return false + } + const res = matchQuery([doc], params, doc._class, client.getHierarchy(), true) return res.length > 0 } diff --git a/server-plugins/process-resources/src/functions.ts b/server-plugins/process-resources/src/functions.ts index 9477528cbc..eeb12d5294 100644 --- a/server-plugins/process-resources/src/functions.ts +++ b/server-plugins/process-resources/src/functions.ts @@ -48,6 +48,7 @@ import process, { UserResult } from '@hcengineering/process' import { ExecuteResult, ProcessControl, SuccessExecutionContext } from '@hcengineering/server-process' +import { isEmptyMarkup } from '@hcengineering/text-core' import time, { ToDoPriority } from '@hcengineering/time' function checkResult (execution: Execution, results: Record | undefined): boolean { @@ -146,10 +147,26 @@ export function MatchCardCheck ( if (context.card === undefined) return false const process = control.client.getModel().findObject(execution.process) if (process === undefined) return false + const markup = getMarkupParams(context.card, params, control) + for (const key of Object.keys(markup)) { + if (isEmptyMarkup(context.card[key])) return false + } + const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true) return res.length > 0 } +function getMarkupParams (card: Card, 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) + if (attr?.type?._class === core.class.TypeMarkup) { + markup[key] = value + } + } + return markup +} + export function EventCheck ( control: ProcessControl, execution: Execution, @@ -173,6 +190,11 @@ 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) + for (const key of Object.keys(markup)) { + if (isEmptyMarkup(context.card[key])) return false + } + const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true) return res.length > 0 }