original bug is fixed but save modal is not handle (nav-item bg color is not correctly painted)

This commit is contained in:
Cindy Chang
2024-05-31 14:36:51 +08:00
parent 69f6a2048a
commit 0a1eefbaa7
4 changed files with 32 additions and 17 deletions

View File

@@ -15,7 +15,7 @@
</div> </div>
<ul class="flex justify-center items-center space-x-4 text-xl font-semibold text-neutral-300 cursor-pointer"> <ul class="flex justify-center items-center space-x-4 text-xl font-semibold text-neutral-300 cursor-pointer">
<li @click="switchNavItem($event, item)" v-for="(item, index) in navViewData[navViewName]" <li @click="switchNavItem($event, item)" v-for="(item, index) in navViewData[navViewName]"
:key="index" :class="{'active': activePage === item}"> :key="index" class="nav-item" :class="{'active': activePage.toUpperCase() === item}">
{{ item }} {{ item }}
</li> </li>
</ul> </ul>
@@ -138,6 +138,8 @@ export default {
filterName: function(newVal, oldVal) { filterName: function(newVal, oldVal) {
this.filterName = newVal; this.filterName = newVal;
}, },
activePage: function(newVal) {
}
}, },
mounted() { mounted() {
if(this.$route.params.type === 'filter') this.createFilterId= this.$route.params.fileId; if(this.$route.params.type === 'filter') this.createFilterId= this.$route.params.fileId;
@@ -291,7 +293,7 @@ export default {
break; break;
} }
}, },
...mapActions(PageAdminStore, ['setPendingActivePage', ],), ...mapActions(PageAdminStore, ['setPendingActivePage', 'setPrevioiusPage'],),
}, },
} }
</script> </script>

View File

@@ -6,8 +6,8 @@ export default defineStore('pageAdminStore', {
activeSubPage: 'ALL', activeSubPage: 'ALL',
previousPage: 'FILES', previousPage: 'FILES',
previousSubPage: 'ALL', previousSubPage: 'ALL',
pendingActivePage: '', pendingActivePage: 'FILES',
pendingActiveSubPage: '', pendingActiveSubPage: 'ALL',
isPending: false, isPending: false,
}), }),
getters: { getters: {
@@ -18,25 +18,29 @@ export default defineStore('pageAdminStore', {
* @param {string} activePage * @param {string} activePage
* @param {string} activeSubPage * @param {string} activeSubPage
*/ */
setActivePage(activePage, activeSubpage) { setActivePage(activePage, activeSubPage) {
console.log("setActivePage:", activePage, activeSubPage);
this.activePage = activePage; this.activePage = activePage;
this.activeSubPage = activeSubPage; this.activeSubPage = activeSubPage;
}, },
/** /**
* Set the previous(usually current) page because the user might change her mind when navigating. * Specify previous page state value.
* @param {string} previoiusPage * @param {*} prevPage
* @param {string} previoiusSubPage */
*/ setPrevioiusPage(prevPage) {
setPrevioiusPage(previoiusPage, previousSubPage) { this.previousPage = prevPage;
this.previoiusPage = previoiusPage;
this.previoiusSubPage = previousSubPage;
}, },
/** /**
* Copy the value of pendingActivePage to activePage * Set the previous(usually current) pages to the ones we just decide.
*/
setPrevioiusPageUsingActivePage() {
this.previoiusPage = this.activePage;
this.previoiusSubPage = this.activeSubPage;
},
/**
* Copy(transit) the value of pendingActivePage to activePage
*/ */
copyPendingPageToActivePage() { copyPendingPageToActivePage() {
console.log("Copy the value of pendingActivePage to activePage\nCopying:", this.pendingActivePage, this.pendingActiveSubPage) console.log("Copying:", this.pendingActivePage, this.pendingActiveSubPage)
this.activePage = this.pendingActivePage; this.activePage = this.pendingActivePage;
this.activeSubPage = this.pendingActiveSubPage; this.activeSubPage = this.pendingActiveSubPage;
}, },
@@ -52,7 +56,7 @@ export default defineStore('pageAdminStore', {
this.isPending = true; this.isPending = true;
}, },
/** /**
* Set Pending active Page to empty string; we call this right after we just decide an activePage. * Set Pending active Page to empty string; we call this right after we just decide an active page.
* Also, stop pending state. * Also, stop pending state.
*/ */
clearPendingActivePage(){ clearPendingActivePage(){

6
src/utils/pageUtils.js Normal file
View File

@@ -0,0 +1,6 @@
const mapPageNameToCapitalUnifiedName = (rawPageName) => {
};
export {
mapPageNameToCapitalUnifiedName,
};

View File

@@ -42,7 +42,7 @@ export default {
Loading Loading
}, },
methods: { methods: {
...mapActions(PageAdminStore, ['copyPendingPageToActivePage',],), ...mapActions(PageAdminStore, ['copyPendingPageToActivePage', 'setPrevioiusPage'],),
}, },
created() { created() {
// Save token in Headers. // Save token in Headers.
@@ -50,6 +50,9 @@ export default {
this.$http.defaults.headers.common['Authorization'] = `Bearer ${token}`; this.$http.defaults.headers.common['Authorization'] = `Bearer ${token}`;
}, },
beforeRouteUpdate(to, from, next) { beforeRouteUpdate(to, from, next) {
this.setPrevioiusPage(from.name);
console.log("beforeRouteUpdate from.name", from.name)
// 離開 Map 頁時判斷是否有無資料和需要存檔 // 離開 Map 頁時判斷是否有無資料和需要存檔
if ((from.name === 'Map' || from.name === 'CheckMap') && this.tempFilterId) { if ((from.name === 'Map' || from.name === 'CheckMap') && this.tempFilterId) {
// 傳給 Map通知 Sidebar 要關閉。 // 傳給 Map通知 Sidebar 要關閉。