fix #295 include both save and cancel cases of popup modal; however, for cases when conformance page acting as starting point, bugs are still there

This commit is contained in:
Cindy Chang
2024-05-31 16:04:52 +08:00
parent 0a1eefbaa7
commit 2142399f8c
4 changed files with 57 additions and 26 deletions

View File

@@ -3,12 +3,10 @@ import { defineStore } from "pinia";
export default defineStore('pageAdminStore', {
state: () => ({
activePage: 'FILES',
activeSubPage: 'ALL',
previousPage: 'FILES',
previousSubPage: 'ALL',
pendingActivePage: 'FILES',
pendingActiveSubPage: 'ALL',
isPending: false,
shouldKeepPreviousPage: false, // false -- meaning modal is not pressed as "NO"
}),
getters: {
},
@@ -16,11 +14,10 @@ export default defineStore('pageAdminStore', {
/**
* Set Active Page; the page which the user is currently visiting
* @param {string} activePage
* @param {string} activeSubPage
*/
setActivePage(activePage, activeSubPage) {
setActivePage(activePage) {
console.log("setActivePage", activePage)
this.activePage = activePage;
this.activeSubPage = activeSubPage;
},
/**
* Specify previous page state value.
@@ -34,15 +31,13 @@ export default defineStore('pageAdminStore', {
*/
setPrevioiusPageUsingActivePage() {
this.previoiusPage = this.activePage;
this.previoiusSubPage = this.activeSubPage;
},
/**
* Copy(transit) the value of pendingActivePage to activePage
*/
copyPendingPageToActivePage() {
console.log("Copying:", this.pendingActivePage, this.pendingActiveSubPage)
console.log("copyPendingPageToActivePage", this.pendingActivePage);
this.activePage = this.pendingActivePage;
this.activeSubPage = this.pendingActiveSubPage;
},
/**
* Set Pending active Page, meaning we are not sure if user will chang her mind later on.
@@ -50,9 +45,9 @@ export default defineStore('pageAdminStore', {
* Often, user triggers the modal and the pending state starts.
* @param {string} pendingActivePage
*/
setPendingActivePage(argPendingActivePage, argPendingActiveSubPage) {
setPendingActivePage(argPendingActivePage) {
console.log("setPendingActivePage", argPendingActivePage);
this.pendingActivePage = argPendingActivePage;
this.pendingActiveSubPage = argPendingActiveSubPage;
this.isPending = true;
},
/**
@@ -60,8 +55,8 @@ export default defineStore('pageAdminStore', {
* Also, stop pending state.
*/
clearPendingActivePage(){
console.log("clearPendingActivePage");
this.pendingActivePage = '';
this.pendingActiveSubPage = '';
this.isPending = false;
},
/**
@@ -69,9 +64,18 @@ export default defineStore('pageAdminStore', {
* instead, we apply the previous page.
*/
keepPreviousPage() {
console.log("keepPreviousPage", this.previousPage);
this.activePage = this.previousPage;
this.activeSubPage = this.previousSubPage;
this.isPending = false;
}
this.shouldKeepPreviousPage = true;
},
/**
* When user dismiss the popup modal, we don't apply the new page,
* instead, we apply the previous page.
*/
clearShouldKeepPreviousPageBoolean(){
console.log("clearShouldKeepPreviousPageBoolean FALSE");
this.shouldKeepPreviousPage = false;
},
},
})