fix #294 by handling navItem string with function mapPageNameToCapitalUnifiedName()

This commit is contained in:
Cindy Chang
2024-06-05 14:42:24 +08:00
parent 5f0e12ef1a
commit 0df045c218
3 changed files with 40 additions and 15 deletions

View File

@@ -17,7 +17,7 @@
<li @click="onNavItemBtnClick($event, item)" <li @click="onNavItemBtnClick($event, item)"
v-for="(item, index) in navViewData[navViewName]" v-for="(item, index) in navViewData[navViewName]"
:key="index" class="nav-item" :key="index" class="nav-item"
:class="{'active': activePageComputedByRoute === item}"> :class="{'active': activePage === item}">
{{ item }} {{ item }}
</li> </li>
</ul> </ul>
@@ -144,6 +144,9 @@ export default {
filterName: function(newVal, oldVal) { filterName: function(newVal, oldVal) {
this.filterName = newVal; this.filterName = newVal;
}, },
activePageComputedByRoute (newVal) {
console.log('activePageComputedByRoute newVal', newVal);
}
}, },
mounted() { mounted() {
this.handleNavItemBtn(); this.handleNavItemBtn();
@@ -178,22 +181,34 @@ export default {
switch (navItemCandidate) { switch (navItemCandidate) {
case 'MAP': case 'MAP':
if(isCheckPage) this.$router.push({name: 'CheckMap', params: { type: type, fileId: fileId }}); if(isCheckPage) {
else this.$router.push({name: 'Map', params: { type: type, fileId: fileId }}); this.$router.push({name: 'CheckMap', params: { type: type, fileId: fileId }});
}
else {
this.$router.push({name: 'Map', params: { type: type, fileId: fileId }});
}
break; break;
case 'CONFORMANCE': case 'CONFORMANCE':
if(isCheckPage) this.$router.push({name: 'CheckConformance', params: { type: type, fileId: fileId }}); if(isCheckPage) { // Beware of Swal popup, it might disturb which is the current active page
else this.$router.push({name: 'Conformance', params: { type: type, fileId: fileId }}); this.$router.push({name: 'CheckConformance', params: { type: type, fileId: fileId }});
}
else { // Beware of Swal popup, it might disturb which is the current active page
this.$router.push({name: 'Conformance', params: { type: type, fileId: fileId }});
}
break break
case 'PERFORMANCE': case 'PERFORMANCE':
if(isCheckPage) this.$router.push({name: 'CheckPerformance', params: { type: type, fileId: fileId }}); if(isCheckPage) {
else this.$router.push({name: 'Performance', params: { type: type, fileId: fileId }}); this.$router.push({name: 'CheckPerformance', params: { type: type, fileId: fileId }});
}
else {
this.$router.push({name: 'Performance', params: { type: type, fileId: fileId }});
}
break; break;
} }
break; break;
case 'COMPARE': case 'COMPARE':
break break
} };
}, },
/** /**
* Based on the route.name, decide the navViewName. * Based on the route.name, decide the navViewName.
@@ -323,6 +338,7 @@ export default {
'setPrevioiusPage', 'setPrevioiusPage',
'setActivePage', 'setActivePage',
'setActivePageComputedByRoute', 'setActivePageComputedByRoute',
'setIsPagePendingBoolean',
],), ],),
}, },
} }

View File

@@ -8,10 +8,10 @@ import { mapPageNameToCapitalUnifiedName } from "../utils/pageUtils";
// 因此至少要處理這兩種方式所引起的畫面切換 // 因此至少要處理這兩種方式所引起的畫面切換
export default defineStore('pageAdminStore', { export default defineStore('pageAdminStore', {
state: () => ({ state: () => ({
activePage: 'FILES', activePage: 'MAP',
previousPage: 'FILES', previousPage: 'MAP',
pendingActivePage: 'FILES', pendingActivePage: 'FILES',
isPending: false, isPagePending: false,
shouldKeepPreviousPage: false, // false -- meaning modal is not pressed as "NO" shouldKeepPreviousPage: false, // false -- meaning modal is not pressed as "NO"
activePageComputedByRoute: "MAP", activePageComputedByRoute: "MAP",
}), }),
@@ -40,7 +40,8 @@ export default defineStore('pageAdminStore', {
* @param {*} prevPage * @param {*} prevPage
*/ */
setPrevioiusPage(prevPage) { setPrevioiusPage(prevPage) {
this.previousPage = prevPage; // console.log('setPrevioiusPage()', prevPage);
this.previousPage = mapPageNameToCapitalUnifiedName(prevPage);
}, },
/** /**
* Set the previous(usually current) pages to the ones we just decide. * Set the previous(usually current) pages to the ones we just decide.
@@ -48,6 +49,14 @@ export default defineStore('pageAdminStore', {
setPrevioiusPageUsingActivePage() { setPrevioiusPageUsingActivePage() {
this.previoiusPage = this.activePage; this.previoiusPage = this.activePage;
}, },
/**
* Set the boolean value of status of pending state of the pate
* For the control of Swal popup
* @param {boolean} boolVal
*/
setIsPagePendingBoolean(boolVal) {
this.isPagePending = boolVal;
},
/** /**
* Copy(transit) the value of pendingActivePage to activePage * Copy(transit) the value of pendingActivePage to activePage
*/ */
@@ -65,7 +74,6 @@ export default defineStore('pageAdminStore', {
setPendingActivePage(argPendingActivePage) { setPendingActivePage(argPendingActivePage) {
// console.log('pinia setting this.pendingActivePage', this.pendingActivePage); // console.log('pinia setting this.pendingActivePage', this.pendingActivePage);
this.pendingActivePage = mapPageNameToCapitalUnifiedName(argPendingActivePage); this.pendingActivePage = mapPageNameToCapitalUnifiedName(argPendingActivePage);
this.isPending = true;
}, },
/** /**
* Set Pending active Page to empty string; we call this right after we just decide an active page. * Set Pending active Page to empty string; we call this right after we just decide an active page.
@@ -73,7 +81,6 @@ export default defineStore('pageAdminStore', {
*/ */
clearPendingActivePage(){ clearPendingActivePage(){
this.pendingActivePage = ''; this.pendingActivePage = '';
this.isPending = false;
}, },
/** /**
* When user dismiss the popup modal, we don't apply the new page, * When user dismiss the popup modal, we don't apply the new page,
@@ -82,13 +89,13 @@ export default defineStore('pageAdminStore', {
keepPreviousPage() { keepPreviousPage() {
// console.log('pinia keeping this.previousPage', this.previousPage); // console.log('pinia keeping this.previousPage', this.previousPage);
this.activePage = this.previousPage; this.activePage = this.previousPage;
this.isPending = false;
this.shouldKeepPreviousPage = true; this.shouldKeepPreviousPage = true;
}, },
/** /**
* Clean up the state of the boolean related to modal showing phase * Clean up the state of the boolean related to modal showing phase
*/ */
clearShouldKeepPreviousPageBoolean(){ clearShouldKeepPreviousPageBoolean(){
// console.log('clearShouldKeepPreviousPageBoolean()');
this.shouldKeepPreviousPage = false; this.shouldKeepPreviousPage = false;
}, },
}, },

View File

@@ -13,6 +13,8 @@ const mapPageNameToCapitalUnifiedName = (rawPageName) => {
return 'CONFORMANCE'; return 'CONFORMANCE';
case 'CHECKPERFORMANCE': case 'CHECKPERFORMANCE':
return 'PERFORMANCE'; return 'PERFORMANCE';
case 'COMPAREDASHBOARD':
return 'DASHBOARD';
default: default:
return rawPageName.toUpperCase(); return rawPageName.toUpperCase();
} }