Skip to content

Commit c6738a0

Browse files
authored
markup check filled (#10817)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
1 parent 1dc41f0 commit c6738a0

5 files changed

Lines changed: 66 additions & 0 deletions

File tree

common/config/rush/pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/process/src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,24 @@ export function createModel (builder: Builder): void {
797797
}
798798
})
799799

800+
builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, {
801+
category: 'attribute',
802+
editor: process.criteriaEditor.BaseCriteria,
803+
of: core.class.TypeMarkup,
804+
props: {
805+
modes: ['StringContains', 'Exists']
806+
}
807+
})
808+
809+
builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, {
810+
category: 'inplace',
811+
editor: process.criteriaEditor.BaseCriteria,
812+
of: core.class.TypeMarkup,
813+
props: {
814+
modes: ['StringContains', 'Exists']
815+
}
816+
})
817+
800818
builder.createDoc(process.class.UpdateCriteriaComponent, core.space.Model, {
801819
category: 'attribute',
802820
editor: process.criteriaEditor.BaseCriteria,

plugins/process-resources/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@hcengineering/platform": "workspace:^0.7.20",
6060
"@hcengineering/process": "workspace:^0.7.0",
6161
"@hcengineering/login": "workspace:^0.7.0",
62+
"@hcengineering/text-core": "workspace:^0.7.19",
6263
"@hcengineering/account-client": "workspace:^0.7.25",
6364
"svelte": "^4.2.20",
6465
"fast-equals": "^5.2.2"

plugins/process-resources/src/utils.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
type UpdateCriteriaComponent,
5959
type UserResult
6060
} from '@hcengineering/process'
61+
import { isEmptyMarkup } from '@hcengineering/text-core'
6162
import { showPopup } from '@hcengineering/ui'
6263
import { type AttributeCategory } from '@hcengineering/view'
6364
import process from './plugin'
@@ -821,6 +822,17 @@ export async function approveRequestRejected (
821822
return context.todo?.group === params._id && context.todo?.approved === false
822823
}
823824

825+
function getMarkupParams (card: Card, params: Record<string, any>, client: Client): Record<string, any> {
826+
const markup: Record<string, any> = {}
827+
for (const [key, value] of Object.entries(params)) {
828+
const attr = client.getHierarchy().findAttribute(card._class, key)
829+
if (attr?.type?._class === core.class.TypeMarkup) {
830+
markup[key] = value
831+
}
832+
}
833+
return markup
834+
}
835+
824836
export function matchCardCheck (
825837
client: Client,
826838
execution: Execution,
@@ -834,6 +846,11 @@ export function matchCardCheck (
834846
if (client.getHierarchy().isMixin(process.masterTag)) {
835847
doc = client.getHierarchy().as(doc, process.masterTag)
836848
}
849+
const markup = getMarkupParams(doc, params, client)
850+
for (const key of Object.keys(markup)) {
851+
if (isEmptyMarkup(doc[key])) return false
852+
}
853+
837854
const res = matchQuery([doc], params, doc._class, client.getHierarchy(), true)
838855
return res.length > 0
839856
}
@@ -849,6 +866,11 @@ export function fieldChangesCheck (
849866
const operations = (context.operations ?? {}) as DocumentUpdate<Doc>
850867
const target = Object.keys(params)[0]
851868
if (!TxProcessor.hasUpdate(operations, target)) return false
869+
const markup = getMarkupParams(doc, params, client)
870+
for (const key of Object.keys(markup)) {
871+
if (isEmptyMarkup(doc[key])) return false
872+
}
873+
852874
const res = matchQuery([doc], params, doc._class, client.getHierarchy(), true)
853875
return res.length > 0
854876
}

server-plugins/process-resources/src/functions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import process, {
4848
UserResult
4949
} from '@hcengineering/process'
5050
import { ExecuteResult, ProcessControl, SuccessExecutionContext } from '@hcengineering/server-process'
51+
import { isEmptyMarkup } from '@hcengineering/text-core'
5152
import time, { ToDoPriority } from '@hcengineering/time'
5253

5354
function checkResult (execution: Execution, results: Record<string, any> | undefined): boolean {
@@ -146,10 +147,26 @@ export function MatchCardCheck (
146147
if (context.card === undefined) return false
147148
const process = control.client.getModel().findObject(execution.process)
148149
if (process === undefined) return false
150+
const markup = getMarkupParams(context.card, params, control)
151+
for (const key of Object.keys(markup)) {
152+
if (isEmptyMarkup(context.card[key])) return false
153+
}
154+
149155
const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true)
150156
return res.length > 0
151157
}
152158

159+
function getMarkupParams (card: Card, params: Record<string, any>, control: ProcessControl): Record<string, any> {
160+
const markup: Record<string, any> = {}
161+
for (const [key, value] of Object.entries(params)) {
162+
const attr = control.client.getHierarchy().findAttribute(card._class, key)
163+
if (attr?.type?._class === core.class.TypeMarkup) {
164+
markup[key] = value
165+
}
166+
}
167+
return markup
168+
}
169+
153170
export function EventCheck (
154171
control: ProcessControl,
155172
execution: Execution,
@@ -173,6 +190,11 @@ export function FieldChangedCheck (
173190
const operations = context.operations as DocumentUpdate<Doc>
174191
const target = Object.keys(params)[0]
175192
if (!TxProcessor.hasUpdate(operations, target)) return false
193+
const markup = getMarkupParams(context.card, params, control)
194+
for (const key of Object.keys(markup)) {
195+
if (isEmptyMarkup(context.card[key])) return false
196+
}
197+
176198
const res = matchQuery([context.card], params, process.masterTag, control.client.getHierarchy(), true)
177199
return res.length > 0
178200
}

0 commit comments

Comments
 (0)