Skip to content

Commit

Permalink
pass the task as action button callback param
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Dec 7, 2023
1 parent 3f65eb2 commit eaa2455
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export async function openAssistantForm({
actionButtons,
},
}).$mount(modalElement)
let lastTask = null

view.$on('cancel', () => {
view.$destroy()
Expand All @@ -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()
Expand All @@ -92,15 +95,16 @@ 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()
} else {
view.output = task?.output
}
} else if (task.status === STATUS.scheduled) {
view.input = task.input
view.showScheduleConfirmation = true
}
view.loading = false
Expand All @@ -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()
Expand All @@ -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()
})
Expand Down

0 comments on commit eaa2455

Please sign in to comment.