This commit is contained in:
@@ -635,6 +635,7 @@ export default {
|
|||||||
},
|
},
|
||||||
resetListView: function() {
|
resetListView: function() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
|
console.log("ResetListView setting activefilter back to 0 ZERO");
|
||||||
vm.activeFilterId = 0;
|
vm.activeFilterId = 0;
|
||||||
vm.listView = undefined;
|
vm.listView = undefined;
|
||||||
vm.dataTablePagingOptions.page = 1;
|
vm.dataTablePagingOptions.page = 1;
|
||||||
@@ -791,11 +792,11 @@ export default {
|
|||||||
vm.getDataFromApi();
|
vm.getDataFromApi();
|
||||||
},
|
},
|
||||||
beforeUpdate() {
|
beforeUpdate() {
|
||||||
//WTF is beforeUpdate doing and what is resetlistview doing??
|
// //WTF is beforeUpdate doing and what is resetlistview doing??
|
||||||
console.log("data-table: BEFORE UPDATE CALLED WTF?");
|
// console.log("data-table: BEFORE UPDATE CALLED WTF?");
|
||||||
if (this.clientCriteria != null && this.activeFilterId != 0) {
|
// if (this.clientCriteria != null && this.activeFilterId != 0) {
|
||||||
this.resetListView();
|
// this.resetListView();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1085,22 +1086,8 @@ async function fetchSavedFilterList(vm) {
|
|||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
} else {
|
} else {
|
||||||
vm.selectLists.savedFilters = res.data;
|
vm.selectLists.savedFilters = res.data;
|
||||||
//confirm we still have the current active filter id (if it's not empty 0)
|
//confirm we still have the current active filter id
|
||||||
if (vm.activeFilterId != 0) {
|
setActiveFilter(vm, vm.activeFilterId);
|
||||||
if (!res.data.find(z => z.id == vm.activeFilterId)) {
|
|
||||||
vm.activeFilterId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vm.activeFilterId == 0) {
|
|
||||||
let dflt = res.data.find(z => z.default == true);
|
|
||||||
if (!dflt) {
|
|
||||||
throw new Error(
|
|
||||||
`data-table::fetchSavedFilterList - No default filter returned for listKey '${vm.dataListKey}'`
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
vm.activeFilterId = dflt.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1118,6 +1105,31 @@ function saveFormSettings(vm) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function setActiveFilter(vm, desiredId) {
|
||||||
|
//Handle a change of filter, ensure it exists, if not then try to select default and if not that then just put in a zero
|
||||||
|
//if desiredId is falsey then try to pick the default
|
||||||
|
|
||||||
|
if (desiredId) {
|
||||||
|
if (vm.selectLists.savedFilters.find(z => z.id == desiredId)) {
|
||||||
|
vm.activeFilterId = desiredId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//no specific id so attempt to set to default
|
||||||
|
let dflt = vm.selectLists.savedFilters.find(z => z.default == true);
|
||||||
|
if (dflt) {
|
||||||
|
vm.activeFilterId = dflt.id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("data-table::setActiveFilter - no default id found");
|
||||||
|
vm.activeFilterId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
function loadFormSettings(vm) {
|
function loadFormSettings(vm) {
|
||||||
@@ -1133,22 +1145,7 @@ function loadFormSettings(vm) {
|
|||||||
formSettings.saved.dataTable.activeFilterId != null &&
|
formSettings.saved.dataTable.activeFilterId != null &&
|
||||||
formSettings.saved.dataTable.activeFilterId != 0
|
formSettings.saved.dataTable.activeFilterId != 0
|
||||||
) {
|
) {
|
||||||
//Is this filter id available in the list of filters?
|
setActiveFilter(vm, formSettings.saved.dataTable.activeFilterId);
|
||||||
if (
|
|
||||||
!vm.selectLists.savedFilters.find(
|
|
||||||
z => z.id == formSettings.saved.dataTable.activeFilterId
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
//Nope so just go to default
|
|
||||||
vm.activeFilterId = 0;
|
|
||||||
} else {
|
|
||||||
//Yup so set it
|
|
||||||
console.log(
|
|
||||||
"Setting filterid to ",
|
|
||||||
formSettings.saved.dataTable.activeFilterId
|
|
||||||
);
|
|
||||||
vm.activeFilterId = formSettings.saved.dataTable.activeFilterId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user