Skip to content

Commit 4dd5185

Browse files
authored
Merge pull request #15 from devforth/feature/AdminForth/1621/change-this-dialog-to-accept-m
feat: implement accept modal before closing in generation mode
2 parents 90d2639 + 3ed77c8 commit 4dd5185

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

custom/VisionAction.vue

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@
1212
:class="popupMode === 'generation' ? 'lg:w-auto !lg:max-w-[1600px]'
1313
: popupMode === 'settings' ? 'lg:w-[1000px] !lg:max-w-[1000px]'
1414
: 'lg:w-[500px] !lg:max-w-[500px]'"
15-
:beforeCloseFunction="closeDialog"
15+
:beforeCloseFunction="handleBeforeClose"
1616
:closable="false"
17-
:askForCloseConfirmation="popupMode === 'generation' ? true : false"
18-
:closeConfirmationText="t('Are you sure you want to close without saving?')"
1917
:buttons="popupMode === 'generation' ? generationModeButtons : popupMode === 'settings' ? [
2018
{
2119
label: t('Save settings'),
@@ -185,6 +183,7 @@ import { useFiltersStore } from '@/stores/filters';
185183
186184
const coreStore = useCoreStore();
187185
const filtersStore = useFiltersStore();
186+
const showCloseConfirmModal = ref(false);
188187
189188
const { t } = useI18n();
190189
const props = defineProps<{
@@ -319,7 +318,7 @@ const generationModeButtons = computed(() => {
319318
options: {
320319
class: 'bg-white hover:!bg-gray-100 !text-gray-900 hover:!text-gray-800 dark:!bg-gray-800 dark:!text-gray-100 dark:hover:!bg-gray-700 !border-gray-200 dark:!border-gray-600'
321320
},
322-
onclick: (dialog) => confirmDialog.value.tryToHideModal()
321+
onclick: async (dialog) => { await handleBeforeClose(dialog); }
323322
},
324323
]
325324
@@ -336,6 +335,28 @@ const generationModeButtons = computed(() => {
336335
return arrayToReturn;
337336
});
338337
338+
const handleBeforeClose = async (dialog?: any) => {
339+
if (popupMode.value === 'generation') {
340+
const confirmed = await adminforth.confirm({
341+
title: t('Close without saving?'),
342+
message: t('Are you sure you want to close without saving?'),
343+
yes: t('Yes'),
344+
no: t('Cancel'),
345+
});
346+
347+
if (confirmed) {
348+
closeDialog();
349+
350+
if (confirmDialog.value && typeof confirmDialog.value.hide === 'function') {
351+
confirmDialog.value.hide();
352+
} else if (dialog && typeof dialog.hide === 'function') {
353+
dialog.hide();
354+
}
355+
return true;
356+
}
357+
return false;
358+
}
359+
}
339360
340361
const isSavingCurrent = ref(false);
341362
function checkIfDialogOpen() {

0 commit comments

Comments
 (0)