WIP #295 not yet keep previous page
This commit is contained in:
@@ -2,6 +2,7 @@ import Swal from 'sweetalert2';
|
||||
import AllMapDataStore from '@/stores/allMapData.js';
|
||||
import ConformanceStore from '@/stores/conformance.js';
|
||||
import FilesStore from '@/stores/files.js';
|
||||
import PageAdminStore from '@/stores/pageAdmin.js';
|
||||
|
||||
const customClass = {
|
||||
container: '!z-[99999]',
|
||||
@@ -78,6 +79,8 @@ export async function savedSuccessfully(value) {
|
||||
*/
|
||||
export async function leaveFilter(next, addFilterId, toPath, logOut) {
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const pageAdminStore = PageAdminStore();
|
||||
|
||||
const result = await Swal.fire({
|
||||
title: 'SAVE YOUR FILTER?',
|
||||
html: 'If you want to continue using this filter in any other page, please select [Yes].',
|
||||
@@ -89,22 +92,38 @@ export async function leaveFilter(next, addFilterId, toPath, logOut) {
|
||||
showCancelButton: true,
|
||||
cancelButtonText: 'No',
|
||||
cancelButtonColor: '#94a3b8',
|
||||
customClass: customClass
|
||||
})
|
||||
customClass: customClass,
|
||||
});
|
||||
|
||||
if(result.isConfirmed) {
|
||||
if(allMapDataStore.createFilterId) {
|
||||
await allMapDataStore.updataFilter();
|
||||
if(allMapDataStore.isUpdataFilter) await savedSuccessfully(allMapDataStore.filterName);
|
||||
if(allMapDataStore.isUpdataFilter) {
|
||||
await savedSuccessfully(allMapDataStore.filterName);
|
||||
}
|
||||
} else {
|
||||
await saveFilter(addFilterId);
|
||||
}
|
||||
|
||||
// Handle page admin issue
|
||||
pageAdminStore.copyPendingPageToActivePage();
|
||||
|
||||
logOut ? logOut() : next(toPath);
|
||||
} else if(result.dismiss === 'cancel') {
|
||||
// Handle page admin issue
|
||||
pageAdminStore.keepPreviousPage();
|
||||
|
||||
allMapDataStore.tempFilterId = null;
|
||||
logOut ? logOut() : next(toPath);
|
||||
} else if(result.dismiss === 'backdrop') {
|
||||
// Handle page admin issue
|
||||
pageAdminStore.keepPreviousPage();
|
||||
|
||||
logOut ? null : next(false);
|
||||
}
|
||||
|
||||
// In any cases, execute the following
|
||||
pageAdminStore.clearPendingActivePage();
|
||||
};
|
||||
/**
|
||||
* Conformance Saved
|
||||
|
||||
Reference in New Issue
Block a user