WIP #295 not yet keep previous page
This commit is contained in:
73
src/stores/pageAdmin.js
Normal file
73
src/stores/pageAdmin.js
Normal file
@@ -0,0 +1,73 @@
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export default defineStore('pageAdminStore', {
|
||||
state: () => ({
|
||||
activePage: 'FILES',
|
||||
activeSubPage: 'ALL',
|
||||
previousPage: 'FILES',
|
||||
previousSubPage: 'ALL',
|
||||
pendingActivePage: '',
|
||||
pendingActiveSubPage: '',
|
||||
isPending: false,
|
||||
}),
|
||||
getters: {
|
||||
},
|
||||
actions: {
|
||||
/**
|
||||
* Set Active Page; the page which the user is currently visiting
|
||||
* @param {string} activePage
|
||||
* @param {string} activeSubPage
|
||||
*/
|
||||
setActivePage(activePage, activeSubpage) {
|
||||
console.log("setActivePage:", activePage, activeSubPage);
|
||||
this.activePage = activePage;
|
||||
this.activeSubPage = activeSubPage;
|
||||
},
|
||||
/**
|
||||
* Set the previous(usually current) page because the user might change her mind when navigating.
|
||||
* @param {string} previoiusPage
|
||||
* @param {string} previoiusSubPage
|
||||
*/
|
||||
setPrevioiusPage(previoiusPage, previousSubPage) {
|
||||
this.previoiusPage = previoiusPage;
|
||||
this.previoiusSubPage = previousSubPage;
|
||||
},
|
||||
/**
|
||||
* Copy the value of pendingActivePage to activePage
|
||||
*/
|
||||
copyPendingPageToActivePage() {
|
||||
console.log("Copy the value of pendingActivePage to activePage\nCopying:", this.pendingActivePage, this.pendingActiveSubPage)
|
||||
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.
|
||||
* Also, start pending state.
|
||||
* Often, user triggers the modal and the pending state starts.
|
||||
* @param {string} pendingActivePage
|
||||
*/
|
||||
setPendingActivePage(argPendingActivePage, argPendingActiveSubPage) {
|
||||
this.pendingActivePage = argPendingActivePage;
|
||||
this.pendingActiveSubPage = argPendingActiveSubPage;
|
||||
this.isPending = true;
|
||||
},
|
||||
/**
|
||||
* Set Pending active Page to empty string; we call this right after we just decide an activePage.
|
||||
* Also, stop pending state.
|
||||
*/
|
||||
clearPendingActivePage(){
|
||||
this.pendingActivePage = '';
|
||||
this.pendingActiveSubPage = '';
|
||||
this.isPending = false;
|
||||
},
|
||||
/**
|
||||
* When user dismiss the popup modal, we don't apply the new page,
|
||||
* instead, we apply the previous page.
|
||||
*/
|
||||
keepPreviousPage() {
|
||||
this.activePage = this.previousPage;
|
||||
this.activeSubPage = this.previousSubPage;
|
||||
this.isPending = false;
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user