From 3a45f31ae81da695be14a39ec3ba603dc00526b2 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 7 Jan 2026 15:14:09 +0500 Subject: [PATCH] Multiple user request input (#10367) Signed-off-by: Denis Bykhov --- .../EmployeeAttributePresenter.svelte | 53 ++++++++- .../components/EmployeeRefPresenter.svelte | 8 +- .../contextEditors/RequestUserInput.svelte | 105 ++++++------------ .../RequestUserInputAttribute.svelte | 98 ++++++++++++++++ plugins/process-resources/src/utils.ts | 66 ++++++----- 5 files changed, 228 insertions(+), 102 deletions(-) create mode 100644 plugins/process-resources/src/components/contextEditors/RequestUserInputAttribute.svelte diff --git a/plugins/contact-resources/src/components/EmployeeAttributePresenter.svelte b/plugins/contact-resources/src/components/EmployeeAttributePresenter.svelte index b0c7dde63c..8f86c408be 100644 --- a/plugins/contact-resources/src/components/EmployeeAttributePresenter.svelte +++ b/plugins/contact-resources/src/components/EmployeeAttributePresenter.svelte @@ -1,12 +1,13 @@ {#if onChange !== undefined} @@ -39,6 +87,7 @@ {value} size={'medium'} kind={'link'} + docQuery={query} showNavigate={false} justify={'left'} {shouldShowName} diff --git a/plugins/contact-resources/src/components/EmployeeRefPresenter.svelte b/plugins/contact-resources/src/components/EmployeeRefPresenter.svelte index c5cb7fb43f..97e1180cba 100644 --- a/plugins/contact-resources/src/components/EmployeeRefPresenter.svelte +++ b/plugins/contact-resources/src/components/EmployeeRefPresenter.svelte @@ -1,6 +1,6 @@ {#if Array.isArray(value)} @@ -31,6 +33,8 @@ {shouldShowName} {avatarSize} {readonly} + {attribute} + {space} on:accent-color /> {/each} @@ -47,6 +51,8 @@ {shouldShowName} {avatarSize} {readonly} + {attribute} + {space} on:accent-color /> {/if} diff --git a/plugins/process-resources/src/components/contextEditors/RequestUserInput.svelte b/plugins/process-resources/src/components/contextEditors/RequestUserInput.svelte index 5ca6d89258..218d1414d1 100644 --- a/plugins/process-resources/src/components/contextEditors/RequestUserInput.svelte +++ b/plugins/process-resources/src/components/contextEditors/RequestUserInput.svelte @@ -13,65 +13,27 @@ // limitations under the License. --> {/if} - {#if attribute} - + + diff --git a/plugins/process-resources/src/components/contextEditors/RequestUserInputAttribute.svelte b/plugins/process-resources/src/components/contextEditors/RequestUserInputAttribute.svelte new file mode 100644 index 0000000000..839f37a85f --- /dev/null +++ b/plugins/process-resources/src/components/contextEditors/RequestUserInputAttribute.svelte @@ -0,0 +1,98 @@ + + + +{#if attribute} +
+
+{/if} +{#if editor} +
+ +
+{/if} diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 983d54ddbb..fc98fc6063 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -420,7 +420,7 @@ export async function continueExecution (value: Execution): Promise { let context = value.context const transition = value.error[0].transition if (transition == null) { - const res = await newExecutionUserInput(value.process, context) + const res = await newExecutionUserInput(value.process, value.space, context) context = res ?? context } else { const _transition = client.getModel().findObject(transition) @@ -433,14 +433,15 @@ export async function continueExecution (value: Execution): Promise { export async function requestUserInput ( processId: Ref, + space: Ref, target: Transition, userContext: ExecutionContext ): Promise { - const tr = await getTransitionUserInput(processId, target, userContext) + const tr = await getTransitionUserInput(processId, space, target, userContext) if (tr !== undefined) { userContext = { ...userContext, ...tr } } - const sub = await getSubProcessesUserInput(target, userContext) + const sub = await getSubProcessesUserInput(space, target, userContext) if (sub !== undefined) { userContext = { ...userContext, ...sub } } @@ -449,39 +450,46 @@ export async function requestUserInput ( export async function getTransitionUserInput ( processId: Ref, + space: Ref, transition: Transition, userContext: ExecutionContext ): Promise { let changed = false for (const action of transition.actions) { if (action == null) continue + const inputs: SelectedUserRequest[] = [] for (const key in action.params) { const value = (action.params as any)[key] const context = parseContext(value) if (context !== undefined && context.type === 'userRequest') { - const promise = new Promise((resolve) => { - showPopup( - process.component.RequestUserInput, - { - processId, - transition: transition._id, - key: context.key, - _class: context._class, - value: userContext[context.id] - }, - undefined, - (res) => { - if (res?.value !== undefined) { - changed = true - userContext[context.id] = res.value - } - resolve() - } - ) - }) - await promise + inputs.push(context) } } + if (inputs.length > 0) { + const promise = new Promise((resolve) => { + showPopup( + process.component.RequestUserInput, + { + processId, + transition: transition._id, + space, + inputs, + values: {} + }, + undefined, + (res) => { + if (res?.value !== undefined) { + changed = true + for (const [key, value] of Object.entries(res.value)) { + userContext[key as ContextId] = value + } + } + resolve() + } + ) + }) + await promise + } } return changed ? userContext : undefined } @@ -492,6 +500,7 @@ function getEmptyContext (): ExecutionContext { } export async function getSubProcessesUserInput ( + space: Ref, transition: Transition, userContext: ExecutionContext ): Promise { @@ -501,7 +510,7 @@ export async function getSubProcessesUserInput ( const processId = action.params._id as Ref if (processId === undefined) continue const context = action.params.context ?? getEmptyContext() - const res = await newExecutionUserInput(processId, context) + const res = await newExecutionUserInput(processId, space, context) if (action.context == null || res === undefined) continue userContext[action.context._id] = res changed = true @@ -511,6 +520,7 @@ export async function getSubProcessesUserInput ( export async function newExecutionUserInput ( _id: Ref, + space: Ref, userContext?: ExecutionContext ): Promise { const client = getClient() @@ -519,7 +529,7 @@ export async function newExecutionUserInput ( from: null })[0] if (initTransition === undefined) return userContext - return await requestUserInput(_id, initTransition, userContext ?? getEmptyContext()) + return await requestUserInput(_id, space, initTransition, userContext ?? getEmptyContext()) } export async function getNextStateUserInput ( @@ -530,13 +540,13 @@ export async function getNextStateUserInput ( const client = getClient() const process = client.getModel().findObject(execution.process) if (process === undefined) return userContext - return await requestUserInput(execution.process, transition, userContext) + return await requestUserInput(execution.process, execution.space, transition, userContext) } export async function createExecution (card: Ref, _id: Ref, space: Ref): Promise { const client = getClient() // eslint-disable-next-line @typescript-eslint/consistent-type-assertions - const context = await newExecutionUserInput(_id) + const context = await newExecutionUserInput(_id, space) const _process = client.getModel().findObject(_id) if (_process === undefined) return const initTransition = client.getModel().findAllSync(process.class.Transition, {