Add tag process fixes (#10561)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-02-26 14:46:19 +05:00
committed by GitHub
parent 93bce6207b
commit b116e711f8
2 changed files with 74 additions and 5 deletions
@@ -1,15 +1,17 @@
<script lang="ts">
import { Ref } from '@hcengineering/core'
import presentation, { getClient } from '@hcengineering/presentation'
import { Process, Transition, Trigger } from '@hcengineering/process'
import presentation, { createQuery, getClient } from '@hcengineering/presentation'
import { Process, State, Transition, Trigger } from '@hcengineering/process'
import { clearSettingsStore } from '@hcengineering/setting-resources'
import {
ButtonIcon,
Component,
Dropdown,
DropdownIntlItem,
DropdownLabelsIntl,
IconDelete,
Label,
ListItem,
Modal
} from '@hcengineering/ui'
import plugin from '../../plugin'
@@ -23,6 +25,14 @@
const client = getClient()
let states: State[] = []
const statesQuery = createQuery()
$: process &&
statesQuery.query(plugin.class.State, { process: process?._id }, (res) => {
states = res
})
async function save (): Promise<void> {
await client.update(transition, { triggerParams: params, trigger: selectedTrigger })
clearSettingsStore()
@@ -45,6 +55,32 @@
const triggers = client.getModel().findAllSync(plugin.class.Trigger, { init: transition.from === null })
const triggersItems: DropdownIntlItem[] = triggers.map((p) => ({ label: p.label, id: p._id, icon: p.icon }))
let statesItems: ListItem[] = []
$: statesItems = states.map((s) => ({ label: s.title, _id: s._id }))
let fromState: ListItem | undefined
$: fromState = statesItems.find((s) => s._id === (transition?.from as string))
let toState: ListItem | undefined
$: toState = statesItems.find((s) => s._id === (transition?.to as string))
$: withoutFrom =
process &&
client.getModel().findAllSync(plugin.class.Transition, { from: null, process: process._id })[0] === undefined
async function updateFrom (e: CustomEvent<ListItem>): Promise<void> {
if (transition === undefined) return
const from = (e.detail?._id as Ref<State>) ?? null
await client.update(transition, { from })
}
async function updateTo (e: CustomEvent<ListItem>): Promise<void> {
if (transition === undefined) return
const to = e.detail?._id as Ref<State>
if (to === undefined) return
await client.update(transition, { to })
}
</script>
<Modal
@@ -69,6 +105,30 @@
</div>
{#if trigger !== undefined}
<div class="editor-grid">
<Label label={plugin.string.From} />
{#if !withoutFrom || transition.from === null}
<Dropdown
items={statesItems}
selected={fromState}
placeholder={plugin.string.From}
justify={'left'}
width={'100%'}
kind={'no-border'}
on:selected={updateFrom}
/>
{:else}
<div></div>
{/if}
<Label label={plugin.string.To} />
<Dropdown
items={statesItems}
selected={toState}
placeholder={plugin.string.To}
justify={'left'}
width={'100%'}
kind={'no-border'}
on:selected={updateTo}
/>
<Label label={plugin.string.Trigger} />
<DropdownLabelsIntl
items={triggersItems}
@@ -323,11 +323,20 @@ export async function AddTag (
res.push(tx)
const card = control.cache.get(execution.card)
if (card === undefined) throw processError(process.error.ObjectNotFound, { _id: execution.card })
if (control.client.getHierarchy().hasMixin(card, tagId)) {
return { txes: res, rollback: [], context: null }
}
const cardWithMixin =
card !== undefined ? TxProcessor.updateMixin4Doc(control.client.getHierarchy().clone(card), tx) : undefined
if (control.client.getHierarchy().hasMixin(card, tagId)) {
return {
txes: res,
rollback: [],
context: [
{
_id: execution.card,
value: cardWithMixin
}
]
}
}
const rollback: Tx[] = [
control.client.txFactory.createTxUpdateDoc(_process.masterTag, execution.space, execution.card, {