fix #293. stay at MAP page. Remove calling of copyPending.......
This commit is contained in:
@@ -137,6 +137,7 @@ export default {
|
||||
'activePage',
|
||||
'pendingActivePage',
|
||||
'activePageComputedByRoute',
|
||||
'shouldKeepPreviousPage',
|
||||
]),
|
||||
},
|
||||
watch: {
|
||||
@@ -146,7 +147,13 @@ export default {
|
||||
},
|
||||
activePageComputedByRoute (newVal) {
|
||||
// console.log('activePageComputedByRoute newVal', newVal);
|
||||
}
|
||||
},
|
||||
activePage: function(newVal){
|
||||
// console.log('watch activePage', this.activePage);
|
||||
},
|
||||
pendingActivePage: function(newVal){
|
||||
// console.log('watch pendingActivePage', this.pendingActivePage);
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.handleNavItemBtn();
|
||||
@@ -259,7 +266,10 @@ export default {
|
||||
// so here we need to save to a pending state
|
||||
// 前端無法確定用戶稍後會按下彈窗上的哪個按鈕(取消還是確認、儲存),
|
||||
// 因此我們需要將其保存到待處理狀態
|
||||
if(!this.shouldKeepPreviousPage) { // 若使用者不是按下取消按鈕或是點選按鈕時
|
||||
this.setPendingActivePage(valueToSet);
|
||||
}
|
||||
|
||||
|
||||
return valueToSet;
|
||||
},
|
||||
|
||||
@@ -55,11 +55,11 @@ export async function saveFilter(addFilterId, next = null) {
|
||||
fileName = '';
|
||||
return true;
|
||||
} else { // 點擊取消或空白處,為存檔失敗。
|
||||
// console.log("PageAdminStore.activePage", PageAdminStore.activePage);
|
||||
pageAdminStore.keepPreviousPage();
|
||||
// console.log("現在 pageAdminStore.activePage", pageAdminStore.activePage);
|
||||
|
||||
// Not every time we have nontrivial next value
|
||||
next !== null ? next() : 1;
|
||||
next !== null ? next(false) : 1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,9 +117,6 @@ export async function leaveFilter(next, addFilterId, toPath, logOut) {
|
||||
await saveFilter(addFilterId, next);
|
||||
}
|
||||
|
||||
// Handle page admin issue
|
||||
pageAdminStore.copyPendingPageToActivePage();
|
||||
|
||||
logOut ? logOut() : next(toPath);
|
||||
} else if(result.dismiss === 'cancel') {
|
||||
// console.log('popup cancel case', );
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { mapPageNameToCapitalUnifiedName } from "../utils/pageUtils";
|
||||
const printPageAdiminLog = false;
|
||||
|
||||
// There are at least two ways to trigger a page navigation:
|
||||
// clicking the navigation button and refreshing the page.
|
||||
@@ -21,7 +22,7 @@ export default defineStore('pageAdminStore', {
|
||||
setActivePageComputedByRoute(routeMatched){
|
||||
if (routeMatched.length && routeMatched[routeMatched.length - 1]
|
||||
&& routeMatched[routeMatched.length - 1].name) {
|
||||
// console.log('setActivePageComputedByRoute()', mapPageNameToCapitalUnifiedName(routeMatched[routeMatched.length - 1].name));
|
||||
printPageAdiminLog && console.log('setActivePageComputedByRoute()', mapPageNameToCapitalUnifiedName(routeMatched[routeMatched.length - 1].name));
|
||||
this.activePageComputedByRoute = mapPageNameToCapitalUnifiedName(
|
||||
routeMatched[routeMatched.length - 1].name);
|
||||
}
|
||||
@@ -32,7 +33,7 @@ export default defineStore('pageAdminStore', {
|
||||
* @param {string} activePage
|
||||
*/
|
||||
setActivePage(activePage) {
|
||||
// console.log("setActivePage", activePage)
|
||||
printPageAdiminLog && console.log("setActivePage", activePage)
|
||||
this.activePage = mapPageNameToCapitalUnifiedName(activePage);
|
||||
},
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ export default defineStore('pageAdminStore', {
|
||||
* Copy(transit) the value of pendingActivePage to activePage
|
||||
*/
|
||||
copyPendingPageToActivePage() {
|
||||
// console.log('pinia copying this.pendingActivePage', this.pendingActivePage);
|
||||
printPageAdiminLog && console.log('pinia copying this.pendingActivePage', this.pendingActivePage);
|
||||
this.activePage = this.pendingActivePage;
|
||||
},
|
||||
/**
|
||||
@@ -72,7 +73,7 @@ export default defineStore('pageAdminStore', {
|
||||
* @param {string} pendingActivePage
|
||||
*/
|
||||
setPendingActivePage(argPendingActivePage) {
|
||||
// console.log('pinia setting this.pendingActivePage', this.pendingActivePage);
|
||||
printPageAdiminLog && console.log('pinia setting this.pendingActivePage', this.pendingActivePage);
|
||||
this.pendingActivePage = mapPageNameToCapitalUnifiedName(argPendingActivePage);
|
||||
},
|
||||
/**
|
||||
@@ -87,7 +88,7 @@ export default defineStore('pageAdminStore', {
|
||||
* instead, we apply the previous page.
|
||||
*/
|
||||
keepPreviousPage() {
|
||||
// console.log('pinia keeping this.previousPage', this.previousPage);
|
||||
printPageAdiminLog && console.log('pinia keeping this.previousPage', this.previousPage);
|
||||
this.activePage = this.previousPage;
|
||||
this.shouldKeepPreviousPage = true;
|
||||
},
|
||||
@@ -95,7 +96,7 @@ export default defineStore('pageAdminStore', {
|
||||
* Clean up the state of the boolean related to modal showing phase
|
||||
*/
|
||||
clearShouldKeepPreviousPageBoolean(){
|
||||
// console.log('clearShouldKeepPreviousPageBoolean()');
|
||||
printPageAdiminLog && console.log('clearShouldKeepPreviousPageBoolean()');
|
||||
this.shouldKeepPreviousPage = false;
|
||||
},
|
||||
},
|
||||
|
||||
@@ -64,7 +64,6 @@ export default {
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
// console.log("beforeRouteUpdate", from.name, "to:", to.name);
|
||||
this.setPrevioiusPage(from.name);
|
||||
this.setActivePageComputedByRoute(to.matched);
|
||||
|
||||
// 離開 Map 頁時判斷是否有無資料和需要存檔
|
||||
if ((from.name === 'Map' || from.name === 'CheckMap') && this.tempFilterId) {
|
||||
|
||||
Reference in New Issue
Block a user