From eaa2455804de959f57ace7283f18e215a7375f5e Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Thu, 7 Dec 2023 15:45:56 +0100 Subject: [PATCH] pass the task as action button callback param Signed-off-by: Julien Veyssier --- src/assistant.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/assistant.js b/src/assistant.js index a848c8e6..ba68bcf3 100644 --- a/src/assistant.js +++ b/src/assistant.js @@ -66,6 +66,7 @@ export async function openAssistantForm({ actionButtons, }, }).$mount(modalElement) + let lastTask = null view.$on('cancel', () => { view.$destroy() @@ -76,7 +77,9 @@ export async function openAssistantForm({ .then((response) => { view.input = data.input view.showScheduleConfirmation = true - resolve(response.data?.ocs?.data?.task) + const task = response.data?.ocs?.data?.task + lastTask = task + resolve(task) }) .catch(error => { view.$destroy() @@ -92,7 +95,9 @@ export async function openAssistantForm({ runOrScheduleTask(appId, identifier, data.taskTypeId, data.input) .then((response) => { const task = response.data?.task + lastTask = task resolve(task) + view.input = task.input if (task.status === STATUS.successfull) { if (closeOnResult) { view.$destroy() @@ -100,7 +105,6 @@ export async function openAssistantForm({ view.output = task?.output } } else if (task.status === STATUS.scheduled) { - view.input = task.input view.showScheduleConfirmation = true } view.loading = false @@ -124,7 +128,9 @@ export async function openAssistantForm({ .then((response) => { view.showSyncTaskRunning = false view.showScheduleConfirmation = true - resolve(response.data?.ocs?.data?.task) + const task = response.data?.ocs?.data?.task + lastTask = task + resolve(task) }) .catch(error => { view.$destroy() @@ -134,7 +140,8 @@ export async function openAssistantForm({ }) view.$on('action-button-clicked', (data) => { if (data.button?.onClick) { - data.button.onClick(data.output) + lastTask.output = data.output + data.button.onClick(lastTask) } view.$destroy() })