Process configure: show reduce funcs (#9822)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-09-10 18:45:14 +05:00
committed by GitHub
parent 07fa7f4a16
commit 70d2485069
16 changed files with 82 additions and 45 deletions
@@ -105,7 +105,7 @@
$: sourceFunc =
contextValue.sourceFunction !== undefined
? client.getModel().findAllSync(plugin.class.ProcessFunction, { _id: contextValue.sourceFunction })[0]
? client.getModel().findAllSync(plugin.class.ProcessFunction, { _id: contextValue.sourceFunction.func })[0]
: undefined
$: functionButtonIndex = functionsLength + (sourceFunc !== undefined ? 1 : 0)
@@ -161,7 +161,7 @@
}
function onSourceFunctionSelect (e: Ref<ProcessFunction>): void {
contextValue.sourceFunction = e
contextValue.sourceFunction = { func: e, props: {} }
onChange(contextValue)
}
@@ -332,11 +332,11 @@
/>
<!-- <div class="menu-separator" /> -->
{/if}
{#if !forbidValue}
<div class="menu-separator" />
{/if}
{/if}
{#if !forbidValue}
{#if sourceFunc !== undefined || availableFunctions.length > 0 || functionsLength > 0}
<div class="menu-separator" />
{/if}
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
<button
bind:this={elements[functionButtonIndex + 1]}
@@ -54,7 +54,7 @@
onClick({
type: 'attribute',
key: val.name,
functions: valueFunc !== undefined ? [{ func: valueFunc, props: {} }] : []
functions: valueFunc !== undefined ? [valueFunc] : []
})
}
@@ -39,11 +39,14 @@
{:else if contextValue.type === 'userRequest'}
<Label label={plugin.string.RequestFromUser} />
{:else if contextValue.type === 'function'}
<FunctionContextPresenter {contextValue} {context} />
<FunctionContextPresenter {contextValue} {context} {process} />
{:else if contextValue.type === 'context'}
<ExecutionContextPresenter {contextValue} {process} />
{/if}
</div>
{#if contextValue.sourceFunction}
<FunctionPresenter value={contextValue.sourceFunction} {context} {process} />
{/if}
{#each contextValue.functions ?? [] as func}
<FunctionPresenter value={func} {context} {process} />
{/each}
@@ -13,10 +13,10 @@
// limitations under the License.
-->
<script lang="ts">
import { Context, Process, SelectedExecutionContext } from '@hcengineering/process'
import { getClient } from '@hcengineering/presentation'
import { Process, SelectedExecutionContext } from '@hcengineering/process'
import ui, { Label } from '@hcengineering/ui'
import ProcessContextPresenter from '../contextEditors/ProcessContextPresenter.svelte'
import { getClient } from '@hcengineering/presentation'
export let contextValue: SelectedExecutionContext
export let process: Process
@@ -47,7 +47,7 @@
type: 'context',
key: attr.name,
id: context.context,
functions: valueFunc !== undefined ? [{ func: valueFunc, props: {} }] : []
functions: valueFunc !== undefined ? [valueFunc] : []
})
}
</script>
@@ -14,9 +14,10 @@
-->
<script lang="ts">
import { getClient } from '@hcengineering/presentation'
import { Context, SelectedContextFunc } from '@hcengineering/process'
import { Label } from '@hcengineering/ui'
import { Context, Process, SelectedContextFunc } from '@hcengineering/process'
import { Component, Label } from '@hcengineering/ui'
export let process: Process
export let contextValue: SelectedContextFunc
export let context: Context
@@ -25,5 +26,9 @@
</script>
{#if func !== undefined}
<Label label={func.label} />
{#if func.presenter !== undefined}
<Component is={func.presenter} props={{ context, contextValue, process }} />
{:else}
<Label label={func.label} />
{/if}
{/if}
@@ -48,7 +48,7 @@
type: 'nested',
key: attr.name,
path: context.attribute.name,
functions: valueFunc !== undefined ? [{ func: valueFunc, props: {} }] : [],
functions: valueFunc !== undefined ? [valueFunc] : [],
sourceFunction: pathReduce
})
}
@@ -53,7 +53,7 @@
association: context.association,
direction: context.direction,
name: context.name,
functions: valueFunc !== undefined ? [{ func: valueFunc, props: {} }] : [],
functions: valueFunc !== undefined ? [valueFunc] : [],
sourceFunction: reduceFunc
})
}
@@ -196,13 +196,7 @@
</div>
{/if}
<div class="button flex-row-center">
<Button
icon={IconAdd}
kind="ghost"
on:click={(e) => {
selectContext(e)
}}
/>
<Button icon={IconAdd} kind="ghost" on:click={selectContext} />
<Button
icon={IconClose}
kind="ghost"
@@ -0,0 +1,33 @@
<!--
// 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 { Role } from '@hcengineering/card'
import { getClient } from '@hcengineering/presentation'
import { SelectedContextFunc } from '@hcengineering/process'
import { Label } from '@hcengineering/ui'
export let contextValue: SelectedContextFunc
const client = getClient()
const func = client.getModel().findObject(contextValue.func)
const role: Role | undefined =
contextValue.props?.target !== undefined ? client.getModel().findObject(contextValue.props?.target) : undefined
</script>
{#if role !== undefined && func !== undefined}
<div>
<Label label={func.label} />: {role.name}
</div>
{/if}