Discover: fix filter's save done.

This commit is contained in:
chiayin
2023-05-03 13:25:18 +08:00
parent 51b56c0ccb
commit 162af24a2a
5 changed files with 32 additions and 24 deletions

View File

@@ -25,7 +25,7 @@
</div>
</div>
<!-- Button -->
<div class="">
<div>
<div class="float-right space-x-4 px-4 py-2">
<button type="button" class="btn btn-sm " :class="[ temporaryData.length === 0 ? 'btn-disable' : 'btn-neutral']" :disabled="temporaryData.length === 0" @click="deleteRule('all')">Delete All</button>
<button type="button" class="btn btn-sm" :class="[ temporaryData.length === 0 ? 'btn-disable' : 'btn-neutral']" :disabled="temporaryData.length === 0" @click="submitAll">Apply All</button>
@@ -61,11 +61,14 @@ export default {
if(!e) this.temporaryData[index] = 0;
else this.temporaryData[index] = rule;
},
// header:Funnel 刪除全部的 Funnel
/**
* header:Funnel 刪除全部的 Funnel
*/
deleteRule(index) {
if(index === 'all') {
this.temporaryData = [];
this.isRuleData = [];
this.ruleData = [];
this.$toast.success('All deleted.');
}else{
this.$toast.success(`Delete ${this.ruleData[index].label}.`);
@@ -74,7 +77,9 @@ export default {
this.ruleData.splice(index, 1);
}
},
// header:Funnel 發送暫存的選取資料
/**
* header:Funnel 發送暫存的選取資料
*/
async submitAll() {
this.postRuleData = this.temporaryData.filter(item => item !== 0); // 取得 submit 的資料,有 toggle button 的話,找出並刪除陣列中為 0 的項目
if(!this.postRuleData?.length) return this.$toast.error('Not selected');

View File

@@ -439,7 +439,7 @@ export default {
}else {
this.temporaryData.push(...postData);
this.isRuleData.push(...postData);
this.ruleData.push(this.setRule(...postData));
this.ruleData.push(...postData.map(e => this.setRule(e)))
}
this.reset(false);
this.isLoading = true;