|
9 | 9 | ref="confirmDialog"
|
10 | 10 | header="Bulk AI Flow"
|
11 | 11 | class="!max-w-full w-full lg:w-[1600px] !lg:max-w-[1600px]"
|
| 12 | + :beforeCloseFunction="closeDialog" |
12 | 13 | :buttons="[
|
13 | 14 | { label: checkedCount > 1 ? 'Save fields' : 'Save field', options: { disabled: isLoading || checkedCount < 1 || isCriticalError || isFetchingRecords || isGeneratingImages || isAnalizingFields || isAnalizingImages, loader: isLoading, class: 'w-fit sm:w-40' }, onclick: (dialog) => { saveData(); dialog.hide(); } },
|
14 | 15 | { label: 'Cancel', onclick: (dialog) => dialog.hide() },
|
@@ -91,9 +92,10 @@ const checkedCount = ref(0);
|
91 | 92 | const isGeneratingImages = ref(false);
|
92 | 93 | const isAnalizingFields = ref(false);
|
93 | 94 | const isAnalizingImages = ref(false);
|
94 |
| -
|
| 95 | +const isDialogOpen = ref(false); |
95 | 96 |
|
96 | 97 | const openDialog = async () => {
|
| 98 | + isDialogOpen.value = true; |
97 | 99 | confirmDialog.value.open();
|
98 | 100 | isFetchingRecords.value = true;
|
99 | 101 | await getRecords();
|
@@ -143,6 +145,23 @@ const openDialog = async () => {
|
143 | 145 | }
|
144 | 146 | }
|
145 | 147 |
|
| 148 | +const closeDialog = () => { |
| 149 | + confirmDialog.value.close(); |
| 150 | + isAiResponseReceivedAnalize.value = []; |
| 151 | + isAiResponseReceivedImage.value = []; |
| 152 | +
|
| 153 | + records.value = []; |
| 154 | + images.value = []; |
| 155 | + selected.value = []; |
| 156 | + tableColumns.value = []; |
| 157 | + tableColumnsIndexes.value = []; |
| 158 | + isError.value = false; |
| 159 | + isCriticalError.value = false; |
| 160 | + isImageGenerationError.value = false; |
| 161 | + errorMessage.value = ''; |
| 162 | + isDialogOpen.value = false; |
| 163 | +} |
| 164 | +
|
146 | 165 | watch(selected, (val) => {
|
147 | 166 | //console.log('Selected changed:', val);
|
148 | 167 | checkedCount.value = val.filter(item => item.isChecked === true).length;
|
@@ -468,7 +487,7 @@ async function runAiAction({
|
468 | 487 | //polling jobs
|
469 | 488 | let isInProgress = true;
|
470 | 489 | //if no jobs were created, skip polling
|
471 |
| - while (isInProgress) { |
| 490 | + while (isInProgress && isDialogOpen.value) { |
472 | 491 | //check if at least one job is still in progress
|
473 | 492 | let isAtLeastOneInProgress = false;
|
474 | 493 | //checking status of each job
|
|
0 commit comments