feat: Implement CancelSubProcess action, fix process execution flow. (#10530)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2026-02-20 10:23:03 +07:00
committed by GitHub
parent f446e036ee
commit bb6d4c74e9
28 changed files with 202 additions and 41 deletions
@@ -16,7 +16,7 @@
import { getCurrentEmployee } from '@hcengineering/contact'
import { getEmbeddedLabel } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import { ApproveRequest, Execution, ProcessToDo } from '@hcengineering/process'
import { ApproveRequest, Execution, ExecutionStatus, ProcessToDo } from '@hcengineering/process'
import { Button } from '@hcengineering/ui'
import plugin from '../plugin'
import ApproveRequestButtons from './ApproveRequestButtons.svelte'
@@ -30,17 +30,22 @@
const emp = getCurrentEmployee()
const query = createQuery()
query.query(
plugin.class.ProcessToDo,
{
execution: value._id,
user: emp,
doneOn: null
},
(res) => {
todos = res
}
)
$: if (value.status === ExecutionStatus.Active) {
query.query(
plugin.class.ProcessToDo,
{
execution: value._id,
user: emp,
doneOn: null
},
(res) => {
todos = res
}
)
} else {
query.unsubscribe()
todos = []
}
async function checkTodo (todo: ProcessToDo) {
await client.update(todo, {
@@ -44,7 +44,7 @@
process.class.Execution,
{
card: card._id,
status: { $ne: ExecutionStatus.Cancelled }
status: ExecutionStatus.Active
},
(res) => {
docs = res
@@ -0,0 +1,72 @@
<!--
// Copyright © 2026 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import card from '@hcengineering/card'
import { Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Process, Step } from '@hcengineering/process'
import { DropdownLabels, DropdownTextItem, Label } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import plugin from '../../plugin'
export let process: Process
export let step: Step<Process>
const dispatch = createEventDispatcher()
const client = getClient()
const hierarchy = client.getHierarchy()
const params = step.params
let _id = params._id as Ref<Process>
function change (e: CustomEvent): void {
if (e.detail !== undefined) {
_id = e.detail
params._id = _id
step.params = params
dispatch('change', step)
}
}
let processes: Process[] = []
let items: DropdownTextItem[] = []
$: items = processes.map((it) => ({
id: it._id,
label: it.name
}))
$: ancestors = hierarchy.getAncestors(process.masterTag).filter((it) => hierarchy.isDerived(it, card.class.Card))
$: selected = _id !== undefined ? items.find((it) => it.id === _id)?.id : undefined
$: processes = client
.getModel()
.findAllSync(plugin.class.Process, { masterTag: { $in: ancestors }, _id: { $ne: process._id } })
</script>
<div class="editor-grid">
<Label label={plugin.string.Process} />
<DropdownLabels
autoSelect={false}
enableSearch={false}
width={'100%'}
{items}
{selected}
placeholder={plugin.string.Process}
on:selected={change}
/>
</div>
@@ -41,5 +41,5 @@
<div class="editor-grid">
<Label label={plugin.string.ToDo} />
<ToDoContextSelector readonly={false} {process} value={_id} on:change={change} />
<ToDoContextSelector readonly={false} skipRollback {process} value={_id} on:change={change} />
</div>
@@ -31,7 +31,7 @@
function change (e: CustomEvent<string>): void {
if (readonly || e.detail == null) return
params._id = e.detail
params.result = undefined
params.result = {}
dispatch('change', { params })
}
@@ -46,6 +46,12 @@
<Label label={plugin.string.ToDo} />
<ToDoContextSelector {readonly} {skipRollback} {process} value={params._id} on:change={change} />
{#if !skipRollback}
<ResultCriteriaEditor {readonly} {process} result={params.result} value={params._id} on:change={changeResult} />
<ResultCriteriaEditor
{readonly}
{process}
result={params.result ?? {}}
value={params._id}
on:change={changeResult}
/>
{/if}
</div>