This commit is contained in:
2021-02-03 21:44:30 +00:00
parent bad6b9f012
commit 1b36ce360c

View File

@@ -9,8 +9,8 @@
<v-card-title>{{ tableColumnData.text }}</v-card-title>
<!-- <v-card-subtitle class="mt-1">sub title text</v-card-subtitle> -->
<v-card-text>
activefilter:{{ activeFilter }} <br /><br />
editItemFilter:{{ editItem.filter }}
<!-- activefilter:{{ activeFilter }} <br /><br />
editItemFilter:{{ editItem.filter }} -->
<!-- FILTER CONTROL -->
<template v-if="editItem.isFilterable">
<div class="pt-6">
@@ -289,7 +289,7 @@
</v-list-item-title>
</v-list-item-content>
<v-list-item-action>
<v-btn icon @click="removeFilterCondition(item, index)">
<v-btn icon @click="removeFilterCondition(editItem, index)">
<v-icon>$ayiTrashAlt</v-icon>
</v-btn>
</v-list-item-action>
@@ -353,28 +353,6 @@ export default {
},
methods: {
async saveAndExit() {
//todo: save changes here
//Note: we are working with a specific filter, either the "default" filter which is the one used when no other filter is specified or a specific one
//So here we need to take the current filter, update it and save it
//todo: populate current filter on open of this control so we have it here to modify and it's near live
// grid doesn't know about filters and has no need to, so this form just needs to know the currently active filter id
//take existing filter
//upsert conditions for this column
//save filter
//let grid do it's thing
/*
filter:[{column:"PartPartNumber",any:true/false,items:[{op: "=",value: "400735"}]}],
clientCriteria:"2" //could be anything here that makes sense to the list, in this case an example customer id for customernotedatalist
CURRENTLY IN BUILDER:
editItemFilter:{ "any": true, "items": [ { "op": "=", "value": "*thisweek*", "display": "= Week - Current", "token": true }, { "op": "=", "value": "*lastmonth*", "display": "= Month - Previous", "token": true } ] }
from server: activefilter:{ "id": 1, "concurrency": 5029293, "userId": 1, "name": "-", "public": false, "defaultFilter": true, "listKey": "TestWidgetDataList", "filter": "[]" }
*/
// console.log("BEFORE SAVE ACTIVE FILTER:", this.activeFilter);
//turn activeFilter into object json.parse
let af = JSON.parse(this.activeFilter.filter);
@@ -397,7 +375,11 @@ from server: activefilter:{ "id": 1, "concurrency": 5029293, "userId": 1, "name"
value: z.value
});
});
af.push(newColumnFilter);
//add it *if* it has any filters at all
if (newColumnFilter.items.length > 0) {
af.push(newColumnFilter);
}
//turn activeFilter back into json and send back to server to save
this.activeFilter.filter = JSON.stringify(af);
@@ -512,6 +494,13 @@ from server: activefilter:{ "id": 1, "concurrency": 5029293, "userId": 1, "name"
return;
}
},
removeFilterCondition(editItem, index) {
editItem.filter.items.splice(index, 1);
window.$gz.form.setFormState({
vm: this,
dirty: true
});
},
async open(tableColumnData) {
this.tableColumnData = tableColumnData;
@@ -829,6 +818,13 @@ function populateSelectionLists(vm) {
////////////////////
//
function initEditItem(vm) {
/*
activefilter:{ "id": 1, "concurrency": 5029405, "userId": 1, "name": "-", "public": false, "defaultFilter": true, "listKey": "TestWidgetDataList",
"filter": "[{\"column\":\"widgetname\",\"any\":false,\"items\":[{\"op\":\">\",\"value\":\"A\"}]},{\"column\":\"widgetserial\",\"any\":false,\"items\":[{\"op\":\">\",\"value\":\"50\"}]},{\"column\":\"widgetdollaramount\",\"any\":false,\"items\":[{\"op\":\">\",\"value\":9}]}]" }
editItemFilter:{ "any": false, "items": [] }
*/
if (vm.fieldDefinitions == null) {
throw new Error(
"ay-data-list::initEditItem - fieldDefinitions are not set"
@@ -848,6 +844,16 @@ function initEditItem(vm) {
tempFilterValue: null
};
//re-hydrate the filter if already defined for this column
//turn activeFilter into object json.parse
let allActiveFilters = JSON.parse(vm.activeFilter.filter);
let af = allActiveFilters.find(z => z.column == vm.tableColumnData.fk);
if (af) {
o.filter.any = af.any;
o.filter.items = af.items;
}
//If it's a tag and it's not been set yet it needs to have an empty array to stat with for the picker
if (o.uiFieldDataType == 9 && o.tempFilterValue == null) {
o.tempFilterValue = [];