From fa739dcf3510da4059351c0a432aa51e32a428bb Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 3 Feb 2021 20:12:36 +0000 Subject: [PATCH] --- .../components/data-table-filter-control.vue | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/ayanova/src/components/data-table-filter-control.vue b/ayanova/src/components/data-table-filter-control.vue index c8bd8e7f..3628ca55 100644 --- a/ayanova/src/components/data-table-filter-control.vue +++ b/ayanova/src/components/data-table-filter-control.vue @@ -371,12 +371,39 @@ export default { CURRENTLY IN BUILDER: editItemFilter:{ "any": true, "items": [ { "op": "=", "value": "*thisweek*", "display": "= Week - Current", "token": true }, { "op": "=", "value": "*lastmonth*", "display": "= Month - Previous", "token": true } ] } -*/ - //turn activeFilter into object json.parse +from server: activefilter:{ "id": 1, "concurrency": 5029293, "userId": 1, "name": "-", "public": false, "defaultFilter": true, "listKey": "TestWidgetDataList", "filter": "[]" } - //todo: iterate this.activeFilter see if this.tableColumnData.fk is there, if it is, replace it with editItemFilter if it isn't then push it into collection +*/ + console.log("BEFORE SAVE ACTIVE FILTER:", this.activeFilter); + //turn activeFilter into object json.parse + let af = JSON.parse(this.activeFilter.filter); + + //remove column filter if it is already there to replace + if (af.length != 0) { + let index = af.findIndex(z => z.column == this.tableColumnData.fk); + if (index > -1) { + af.splice(index, 1); + } + } + + let newColumnFilter = { + column: this.tableColumnData.fk, + any: this.editItem.filter.any, + items: [] + }; + this.editItem.filter.items.forEach(function(z) { + newColumnFilter.items.push({ + op: z.op, + value: z.value + }); + }); + af.push(newColumnFilter); //turn activeFilter back into json and send back to server to save + this.activeFilter.filter = JSON.stringify(af); + + //SAVE + console.log("SAVE ACTIVE FILTER:", this.activeFilter); this.close({ refresh: true }); },