case 4503

This commit is contained in:
2023-04-04 22:52:29 +00:00
parent e5047c6236
commit 31477e44fd
4 changed files with 42 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "sockeye", "name": "sockeye",
"version": "8.0.10", "version": "8.0.11",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",

View File

@@ -1,4 +1,4 @@
export default { export default {
version: "8.0.10", version: "8.0.11",
copyright: "© 1999-2022, Ground Zero Tech-Works Inc." copyright: "© 1999-2022, Ground Zero Tech-Works Inc."
}; };

View File

@@ -380,7 +380,8 @@ export default {
props: { props: {
dataListKey: { type: String, default: null }, dataListKey: { type: String, default: null },
activeFilterId: { type: Number, default: null } activeFilterId: { type: Number, default: null },
defaultFilterId: { type: Number, default: null }
}, },
data: () => ({ data: () => ({
isVisible: false, isVisible: false,
@@ -390,6 +391,7 @@ export default {
fieldDefinitions: [], fieldDefinitions: [],
editItem: { filter: { items: [] } }, editItem: { filter: { items: [] } },
activeFilter: null, activeFilter: null,
defaultFilter: null,
selectLists: { selectLists: {
dateFilterOperators: [], dateFilterOperators: [],
dateFilterTokens: [], dateFilterTokens: [],
@@ -452,13 +454,16 @@ export default {
af.push(newColumnFilter); af.push(newColumnFilter);
} }
//turn activeFilter back into json and send back to server to save //turn activeFilter back into json and send back to server to save to default filter (case 4503)
this.activeFilter.filter = JSON.stringify(af); this.defaultFilter.filter = JSON.stringify(af);
//case 4503 save as new default filter so that any saved filter is not ovewritten here, data table will ensure it flips back to default filter after this
//saves and emits a refresh command
//SAVE //SAVE
const res = await window.$gz.api.put( const res = await window.$gz.api.put(
"data-list-filter", "data-list-filter",
this.activeFilter this.defaultFilter
); );
if (res.error) { if (res.error) {
throw new Error(window.$gz.errorHandler.errorToString(res, this)); throw new Error(window.$gz.errorHandler.errorToString(res, this));
@@ -586,6 +591,7 @@ export default {
this.tableColumnData = tableColumnData; this.tableColumnData = tableColumnData;
await fetchActiveFilter(this); await fetchActiveFilter(this);
await fetchDefaultFilter(this); //case 4503
initEditItem(this); initEditItem(this);
this.formState.dirty = false; this.formState.dirty = false;
this.isVisible = true; this.isVisible = true;
@@ -646,6 +652,19 @@ async function fetchActiveFilter(vm) {
vm.activeFilter = res.data; vm.activeFilter = res.data;
} }
} }
////////////////////
//case 4503
async function fetchDefaultFilter(vm) {
///api/v8/data-list-filter/{id}
const res = await window.$gz.api.get(
`data-list-filter/${vm.defaultFilterId}`
);
if (res.error) {
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
} else {
vm.defaultFilter = res.data;
}
}
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// //

View File

@@ -5,6 +5,7 @@
ref="dataTableFilter" ref="dataTableFilter"
:data-list-key="dataListKey" :data-list-key="dataListKey"
:active-filter-id="activeFilterId" :active-filter-id="activeFilterId"
:default-filter-id="defaultFilterId"
> >
</gz-data-table-filter> </gz-data-table-filter>
<gz-data-table-filter-manager <gz-data-table-filter-manager
@@ -567,6 +568,7 @@ export default {
dataTablePagingOptions: {}, dataTablePagingOptions: {},
lastDataTablePagingOptions: {}, lastDataTablePagingOptions: {},
activeFilterId: 0, //<--0 signifies to select default as it's uninitialized activeFilterId: 0, //<--0 signifies to select default as it's uninitialized
defaultFilterId: 0, //case 4503
lastFetchFilterId: -1, //used to track change of filter and reset paging in getdata lastFetchFilterId: -1, //used to track change of filter and reset paging in getdata
selectLists: { selectLists: {
savedFilters: [] savedFilters: []
@@ -700,6 +702,11 @@ export default {
this.selected = []; //remove any selections this.selected = []; //remove any selections
//New filter, need to go back to the first page //New filter, need to go back to the first page
this.dataTablePagingOptions.page = 1; this.dataTablePagingOptions.page = 1;
//case 4503 change filter selection to default then get data
//Reset back to DEFAULT filter
setActiveFilter(this); //will not trigger refresh yet
this.getDataFromApi(); this.getDataFromApi();
} }
}, },
@@ -1321,6 +1328,16 @@ async function fetchSavedFilterList(vm) {
vm.selectLists.savedFilters = res.data; vm.selectLists.savedFilters = res.data;
//confirm we still have the current active filter id //confirm we still have the current active filter id
setActiveFilter(vm, vm.activeFilterId); setActiveFilter(vm, vm.activeFilterId);
//case 4503 get default filter id so we know it
//no specific id so attempt to set to default
const dflt = vm.selectLists.savedFilters.find(z => z.default == true);
if (dflt) {
vm.defaultFilterId = dflt.id;
return;
} else {
vm.defaultFilterId = 0;
}
} }
} }