Process improvements (#9801)

This commit is contained in:
Denis Bykhov
2025-09-08 22:43:45 +07:00
committed by GitHub
parent 1ed6f1d486
commit 6003e4a86a
27 changed files with 591 additions and 407 deletions
@@ -187,13 +187,14 @@
onChange(contextValue)
}
function onConfigure (e: MouseEvent, func: ProcessFunction, pos: number): void {
if (contextValue.functions === undefined || func.editor === undefined) return
function onConfigure (e: MouseEvent, func: Func, pos: number): void {
const f = getFunction(func.func)
if (contextValue.functions === undefined || f.editor === undefined) return
const val = contextValue.functions[pos]
showPopup(
func.editor,
f.editor,
{
func,
func: f,
masterTag: process.masterTag,
process,
context,
@@ -224,6 +225,10 @@
}
onChange(contextValue)
}
function getFunction (_id: Ref<ProcessFunction>): ProcessFunction {
return client.getModel().findAllSync(plugin.class.ProcessFunction, { _id })[0]
}
</script>
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
@@ -246,11 +251,13 @@
options={{ component: plugin.component.FunctionSelector }}
withHover
/>
<div class="menu-separator" />
{/if}
{#if availableFunctions.length > 0 || functionsLength > 0}
{#each funcs as f, i}
{#if reduceFuncs.includes(f._id)}
{#if sourceFunc !== undefined}
<div class="menu-separator" />
{/if}
{#each contextValue.functions ?? [] as f, i}
{#if reduceFuncs.includes(f.func)}
<Submenu
bind:element={elements[i + (sourceFunc !== undefined ? 1 : 0)]}
on:keydown={(event) => {
@@ -259,7 +266,7 @@
on:mouseover={() => {
elements[i + (sourceFunc !== undefined ? 1 : 0)]?.focus()
}}
label={f.label}
label={getFunction(f.func)?.label}
props={{
availableFunctions: reduceFuncs,
onSelect: getFunctionChange(i)
@@ -281,10 +288,10 @@
}}
>
<div>
<Label label={f.label} />
<Label label={getFunction(f.func).label} />
</div>
<div>
{#if f.editor}
{#if getFunction(f.func).editor}
<ButtonIcon
icon={IconSettings}
size="small"
@@ -325,7 +332,9 @@
/>
<!-- <div class="menu-separator" /> -->
{/if}
<div class="menu-separator" />
{#if !forbidValue}
<div class="menu-separator" />
{/if}
{/if}
{#if !forbidValue}
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
@@ -0,0 +1,67 @@
<!--
// Copyright © 2025 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 { Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { ExecutionContext, parseContext, Process, SelectedUserRequest, Transition } from '@hcengineering/process'
import { createEventDispatcher } from 'svelte'
import plugin from '../../plugin'
import ProcessAttributeEditor from './ProcessAttributeEditor.svelte'
export let process: Process
export let targetProcess: Ref<Process>
export let context: ExecutionContext
const client = getClient()
const dispatch = createEventDispatcher()
$: initTransition = client.getModel().findAllSync(plugin.class.Transition, {
process: targetProcess,
from: null
})[0]
let contexts: SelectedUserRequest[] = []
function fillParams (initTransition: Transition | undefined): void {
contexts = []
for (const action of initTransition?.actions ?? []) {
for (const key in action.params) {
const value = (action.params as any)[key]
const request = parseContext(value)
if (request !== undefined && request.type === 'userRequest') {
contexts.push(request)
}
}
}
contexts = contexts
}
$: fillParams(initTransition)
</script>
{#each contexts as ctx}
<ProcessAttributeEditor
{process}
_class={ctx._class}
key={ctx.key}
objectKey={ctx.id}
object={context}
allowRemove
on:change={(e) => {
context = e.detail.object
dispatch('change', context)
}}
/>
{/each}
@@ -17,9 +17,9 @@
import { getAttributeEditor, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { Process } from '@hcengineering/process'
import { AnySvelteComponent } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import { getContext } from '../../utils'
import ProcessAttribute from '../ProcessAttribute.svelte'
import { createEventDispatcher } from 'svelte'
export let process: Process
export let _class: Ref<Class<Doc>>
@@ -28,6 +28,7 @@
export let allowRemove: boolean = false
export let forbidValue: boolean = false
export let allowArray: boolean = false
export let objectKey: string | undefined = undefined
const client = getClient()
const hierarchy = client.getHierarchy()
@@ -36,14 +37,14 @@
function onChange (value: any | undefined): void {
if (value === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete (object as any)[key]
delete (object as any)[objectKey ?? key]
} else {
;(object as any)[key] = value
;(object as any)[objectKey ?? key] = value
}
dispatch('change', { value })
dispatch('change', { value, object })
}
$: value = object[key]
$: value = object[objectKey ?? key]
$: attribute = hierarchy.getAttribute(_class, key)
$: presenterClass = getAttributePresenterClass(hierarchy, attribute.type)
@@ -14,12 +14,14 @@
-->
<script lang="ts">
import card from '@hcengineering/card'
import { Ref } from '@hcengineering/core'
import { getClient } from '@hcengineering/presentation'
import { Execution, parseContext, Process, Step } from '@hcengineering/process'
import { Execution, ExecutionContext, parseContext, Process, Step } from '@hcengineering/process'
import { DropdownLabels, DropdownTextItem, Label, Toggle } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
import plugin from '../../plugin'
import { getContextMasterTag } from '../../utils'
import InitParamsEditor from './InitParamsEditor.svelte'
import ProcessAttributeEditor from './ProcessAttributeEditor.svelte'
export let process: Process
@@ -28,15 +30,18 @@
const client = getClient()
const hierarchy = client.getHierarchy()
let _id = step.params._id
let _id: Ref<Process> = step.params._id as any
$: context = parseContext(step.params.card)
$: masterTag = getContextMasterTag(client, context, process.masterTag) ?? process.masterTag
$: executionContext = (step.params.context ?? {}) as ExecutionContext
const dispatch = createEventDispatcher()
function change (e: CustomEvent<any>): void {
if (e.detail !== undefined) {
;(step.params as any)._id = e.detail
_id = e.detail
dispatch('change', step)
}
}
@@ -62,15 +67,20 @@
.findAllSync(plugin.class.Process, { masterTag: { $in: ancestors }, _id: { $ne: process._id } })
function changeThis (): void {
_id = undefined
step.params = {}
dispatch('change', step)
}
function changeTarget (e: CustomEvent<any>): void {
_id = undefined
step.params.card = e.detail.value
}
function changeContext (e: CustomEvent<ExecutionContext>): void {
if (e.detail !== undefined) {
step.params.context = e.detail
dispatch('change', step)
}
}
</script>
<div class="grid">
@@ -103,8 +113,17 @@
on:selected={change}
/>
</div>
<div class="divider" />
<div class="grid">
<InitParamsEditor {process} targetProcess={_id} context={executionContext} on:change={changeContext} />
</div>
<style lang="scss">
.divider {
border-bottom: 1px solid var(--divider-color);
margin: 1rem 0;
}
.grid {
display: grid;
grid-template-columns: 1fr 1.5fr;
@@ -14,12 +14,9 @@
-->
<script lang="ts">
import { MasterTag, Tag } from '@hcengineering/card'
import core, { AnyAttribute, Ref } from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import { AnyAttribute, Ref } from '@hcengineering/core'
import presentation, { Card, getAttributePresenterClass, getClient } from '@hcengineering/presentation'
import { Process, ProcessFunction } from '@hcengineering/process'
import { AnySvelteComponent } from '@hcengineering/ui'
import view from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import { getContext } from '../../utils'
import ProcessAttribute from '../ProcessAttribute.svelte'
@@ -29,6 +26,7 @@
export let masterTag: Ref<MasterTag | Tag>
export let attribute: AnyAttribute
export let props: Record<string, any> = {}
export let allowArray: boolean = false
let value: any = props?.value ?? ''
@@ -40,28 +38,9 @@
dispatch('close', { value })
}
let editor: AnySvelteComponent | undefined
function getEditor (): void {
try {
const inlineEditor = h.as(h.getClass(core.class.ArrOf), view.mixin.AttributeEditor).inlineEditor
void getResource(inlineEditor)
.then((p) => {
editor = p
})
.catch((e) => {
console.error(e)
})
} catch (e) {
console.error(e)
}
}
getEditor()
$: presenterClass = getAttributePresenterClass(h, attribute.type)
$: elementContext = getContext(client, process, presenterClass.attrClass, 'object')
$: elementContext = getContext(client, process, presenterClass.attrClass, 'attribute')
</script>
<Card on:close width={'x-small'} label={func.label} canSave okAction={save} okLabel={presentation.string.Save}>
@@ -71,12 +50,13 @@
{masterTag}
context={elementContext}
{attribute}
editor={undefined}
presenterClass={{
attrClass: presenterClass.attrClass,
category: 'attribute'
}}
{allowArray}
{value}
{editor}
on:change={(e) => {
value = e.detail
}}
@@ -0,0 +1,28 @@
<!--
// Copyright © 2025 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 { MasterTag, Tag } from '@hcengineering/card'
import { AnyAttribute, Ref } from '@hcengineering/core'
import { Process, ProcessFunction } from '@hcengineering/process'
import ArrayElementEditor from './ArrayElementEditor.svelte'
export let func: ProcessFunction
export let process: Process
export let masterTag: Ref<MasterTag | Tag>
export let attribute: AnyAttribute
export let props: Record<string, any> = {}
</script>
<ArrayElementEditor {func} {process} {masterTag} {attribute} {props} allowArray on:close />