Discover: fix filter's save done.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
<!-- Other Page: Save and Download -->
|
||||
<!-- Save 有 data 跳重新命名,沒有 data 跳要不要儲存,沒有動都不跳 -->
|
||||
<div v-else class="space-x-4">
|
||||
<button class="btn btn-sm" :class="[ disabledSave ? 'btn-disable' : 'btn-neutral']" :disabled="disabledSave" @click="showAlert">Save</button>
|
||||
<button class="btn btn-sm" :class="[ disabledSave ? 'btn-disable' : 'btn-neutral']" :disabled="disabledSave" @click="saveModal">Save</button>
|
||||
<button class="btn btn-sm btn-neutral">Download</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,9 +79,9 @@ export default {
|
||||
setup() {
|
||||
const store = filesStore();
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const { tempFilterId, createfilterId, filterName, postRuleData, isUpdataFilter } = storeToRefs(allMapDataStore);
|
||||
const { logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter } = storeToRefs(allMapDataStore);
|
||||
|
||||
return { store, allMapDataStore, tempFilterId, createfilterId, filterName, postRuleData, isUpdataFilter}
|
||||
return { store, allMapDataStore, logId, tempFilterId, createFilterId, filterName, postRuleData, isUpdataFilter}
|
||||
},
|
||||
components: {
|
||||
IconSearch,
|
||||
@@ -90,33 +90,36 @@ export default {
|
||||
savedSuccessfully
|
||||
},
|
||||
mounted() {
|
||||
this.showNavbarBreadcrumb = this.$route.matched[0].name !== ('AuthContainer')? true : false;
|
||||
this.getNavViewName();
|
||||
let filterId = this.$route.params.filterId;
|
||||
this.createfilterId = filterId;
|
||||
this.showNavbarBreadcrumb = this.$route.matched[0].name !== ('AuthContainer')? true : false;
|
||||
this.getNavViewName();
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* switch navbar item
|
||||
*/
|
||||
switchNavItem(event) {
|
||||
this.store.filesTag = event.target.innerText;
|
||||
},
|
||||
getNavViewName() {
|
||||
this.navViewName = this.$route.name.toUpperCase();
|
||||
if(this.navViewName === 'DISCOVERLOG' || this.navViewName === 'DISCOVERFILTER'){
|
||||
this.navViewName = 'DISCOVER';
|
||||
}
|
||||
if(this.navViewName === 'DISCOVERLOG' || this.navViewName === 'DISCOVERFILTER') this.navViewName = 'DISCOVER';
|
||||
|
||||
},
|
||||
showAlert() {
|
||||
/**
|
||||
* Save button' modal
|
||||
*/
|
||||
async saveModal() {
|
||||
// 先判斷有沒有 filter Id,有就儲存 return,沒有就往下走
|
||||
// 沒有 filter Id, 有暫存 tempFilterId Id 可以另存新檔
|
||||
console.log(this.createfilterId);
|
||||
if(this.createfilterId) {
|
||||
this.allMapDataStore.updataFilter();
|
||||
console.log(this.isUpdataFilter);
|
||||
if(this.isUpdataFilter) savedSuccessfully(this.filterName);
|
||||
this.tempFilterId = false
|
||||
}else{
|
||||
if(this.createFilterId) {
|
||||
await this.allMapDataStore.updataFilter();
|
||||
if(this.isUpdataFilter) await savedSuccessfully(this.filterName);
|
||||
this.tempFilterId = null;
|
||||
}else if(this.logId){
|
||||
saveFilter(this.allMapDataStore.addFilterId);
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user