diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index e2dc76594a..dbadda4f03 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -889,7 +889,7 @@
-
+
-
+
-
+
{#key lang} void) | undefined = undefined + async function handleBeforeIcon() { if (resolvedConfig.beforeIcon) { beforeIconComponent = await loadIcon(resolvedConfig.beforeIcon) @@ -109,21 +113,29 @@ event?.preventDefault() $selectedComponent = [id] - const inputOutput = { result: outputs.result.peak(), loading: true } - if (rowContext && rowInputs) { - rowInputs.set(id, inputOutput) - } - if (iterContext && listInputs) { - listInputs.set(id, inputOutput) - } - if (preclickAction) { - await preclickAction() + const action = async () => { + const inputOutput = { result: outputs.result.peak(), loading: true } + if (rowContext && rowInputs) { + rowInputs.set(id, inputOutput) + } + if (iterContext && listInputs) { + listInputs.set(id, inputOutput) + } + if (preclickAction) { + await preclickAction() + } + + if (!runnableComponent) { + runnableWrapper?.handleSideEffect(true) + } else { + await runnableComponent?.runComponent() + } } - if (!runnableComponent) { - runnableWrapper?.handleSideEffect(true) + if (resolvedConfig?.confirmationModal?.selected === 'confirmationModal') { + confirmedCallback = action } else { - await runnableComponent?.runComponent() + await action() } } let loading = false @@ -225,3 +237,29 @@ {/key} + +{#if resolvedConfig?.confirmationModal?.selected === 'confirmationModal'} + + { + confirmedCallback = undefined + }} + on:confirmed={() => { + if (confirmedCallback) { + confirmedCallback() + } + confirmedCallback = undefined + }} + > +
+ + {resolvedConfig?.confirmationModal?.configuration?.confirmationModal?.description ?? ''} + +
+
+
+{/if} diff --git a/frontend/src/lib/components/apps/editor/component/components.ts b/frontend/src/lib/components/apps/editor/component/components.ts index ce80713f35..3bc83cdc38 100644 --- a/frontend/src/lib/components/apps/editor/component/components.ts +++ b/frontend/src/lib/components/apps/editor/component/components.ts @@ -1013,8 +1013,42 @@ export const components = { value: false, fieldType: 'boolean' }, + onSuccess: onSuccessClick, - onError: onErrorClick + onError: onErrorClick, + confirmationModal: { + type: 'oneOf', + selected: 'none', + tooltip: 'If defined, the user will be asked to confirm the action in a modal.', + labels: { + none: 'Do nothing', + confirmationModal: 'Show confirmation modal' + }, + configuration: { + none: {}, + confirmationModal: { + title: { + fieldType: 'text', + type: 'static', + value: 'Title', + placeholder: 'Confirmation modal title' + }, + description: { + fieldType: 'text', + type: 'static', + value: 'Are you sure?', + placeholder: 'Are you sure?' + }, + confirmationText: { + fieldType: 'text', + type: 'static', + value: 'Confirm', + placeholder: 'Confirm', + tooltip: 'The text of the button that confirms the action.' + } + } + } + } } } },