This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
<v-card-title>{{ tableColumnData.text }}</v-card-title>
|
<v-card-title>{{ tableColumnData.text }}</v-card-title>
|
||||||
<!-- <v-card-subtitle class="mt-1">sub title text</v-card-subtitle> -->
|
<!-- <v-card-subtitle class="mt-1">sub title text</v-card-subtitle> -->
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
|
activefilter:{{ activeFilter }} editItem:{{ editItem }}
|
||||||
<!-- FILTER CONTROL -->
|
<!-- FILTER CONTROL -->
|
||||||
<template v-if="editItem.isFilterable">
|
<template v-if="editItem.isFilterable">
|
||||||
<div class="pt-6">
|
<div class="pt-6">
|
||||||
@@ -467,7 +468,7 @@ export default {
|
|||||||
async open(tableColumnData) {
|
async open(tableColumnData) {
|
||||||
this.tableColumnData = tableColumnData;
|
this.tableColumnData = tableColumnData;
|
||||||
|
|
||||||
await getActiveFilter(vm);
|
await fetchActiveFilter(this);
|
||||||
initEditItem(this);
|
initEditItem(this);
|
||||||
this.isVisible = true;
|
this.isVisible = true;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -526,9 +527,7 @@ async function populateFieldDefinitions(vm) {
|
|||||||
//
|
//
|
||||||
async function fetchActiveFilter(vm) {
|
async function fetchActiveFilter(vm) {
|
||||||
///api/v8/data-list-filter/{id}
|
///api/v8/data-list-filter/{id}
|
||||||
let res = await window.$gz.api.get(
|
let res = await window.$gz.api.get(`data-list-filter/${vm.activeFilterId}`);
|
||||||
`/api/v8/data-list-filter/${vm.activeFilterId}`
|
|
||||||
);
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
//throw new Error(res.error);
|
//throw new Error(res.error);
|
||||||
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
|
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
|
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
|
||||||
<gz-data-table-filter
|
<gz-data-table-filter
|
||||||
:dataListKey="dataListKey"
|
:dataListKey="dataListKey"
|
||||||
:activeFilterId="filterId"
|
:activeFilterId="activeFilterId"
|
||||||
ref="dataTableFilter"
|
ref="dataTableFilter"
|
||||||
>
|
>
|
||||||
</gz-data-table-filter>
|
</gz-data-table-filter>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
{{ headers }} -->
|
{{ headers }} -->
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-select
|
<v-select
|
||||||
v-model="filterId"
|
v-model="activeFilterId"
|
||||||
:items="selectLists.savedFilters"
|
:items="selectLists.savedFilters"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
@@ -384,7 +384,7 @@ export default {
|
|||||||
loading: true,
|
loading: true,
|
||||||
dataTablePagingOptions: {},
|
dataTablePagingOptions: {},
|
||||||
lastDataTablePagingOptions: {},
|
lastDataTablePagingOptions: {},
|
||||||
filterId: 0,
|
activeFilterId: 0, //<--0 signifies to select default as it's uninitialized
|
||||||
listView: undefined,
|
listView: undefined,
|
||||||
selectLists: {
|
selectLists: {
|
||||||
savedFilters: []
|
savedFilters: []
|
||||||
@@ -614,13 +614,13 @@ export default {
|
|||||||
params: {
|
params: {
|
||||||
dataListKey: this.dataListKey,
|
dataListKey: this.dataListKey,
|
||||||
formKey: this.formKey,
|
formKey: this.formKey,
|
||||||
filterId: this.filterId
|
activeFilterId: this.activeFilterId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
resetListView: function() {
|
resetListView: function() {
|
||||||
let vm = this;
|
let vm = this;
|
||||||
vm.filterId = 0;
|
vm.activeFilterId = 0;
|
||||||
vm.listView = undefined;
|
vm.listView = undefined;
|
||||||
vm.dataTablePagingOptions.page = 1;
|
vm.dataTablePagingOptions.page = 1;
|
||||||
saveFormSettings(vm);
|
saveFormSettings(vm);
|
||||||
@@ -628,6 +628,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
savedFilterSelected: async function() {
|
savedFilterSelected: async function() {
|
||||||
|
return;
|
||||||
let vm = this;
|
let vm = this;
|
||||||
|
|
||||||
//If listview had changed it can only have changed *away* from the unsaved filter item if it's present so just remove the unsaved filter item if it exists
|
//If listview had changed it can only have changed *away* from the unsaved filter item if it's present so just remove the unsaved filter item if it exists
|
||||||
@@ -651,11 +652,11 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.filterId == 0) {
|
if (vm.activeFilterId == 0) {
|
||||||
//default view, no saved, no cached
|
//default view, no saved, no cached
|
||||||
vm.listView = undefined;
|
vm.listView = undefined;
|
||||||
saveFormSettings(vm);
|
saveFormSettings(vm);
|
||||||
} else if (vm.filterId > 0) {
|
} else if (vm.activeFilterId > 0) {
|
||||||
await fetchListView(vm);
|
await fetchListView(vm);
|
||||||
saveFormSettings(vm);
|
saveFormSettings(vm);
|
||||||
}
|
}
|
||||||
@@ -788,7 +789,7 @@ export default {
|
|||||||
vm.getDataFromApi();
|
vm.getDataFromApi();
|
||||||
},
|
},
|
||||||
beforeUpdate() {
|
beforeUpdate() {
|
||||||
if (this.clientCriteria != null && this.filterId != 0) {
|
if (this.clientCriteria != null && this.activeFilterId != 0) {
|
||||||
this.resetListView();
|
this.resetListView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1071,44 +1072,52 @@ async function initForm(vm) {
|
|||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
async function populateSelectionLists(vm) {
|
async function populateSelectionLists(vm) {
|
||||||
//http://localhost:7575/api/v8/data-list-view/viewlist?ListKey=TestWidgetDataList
|
//http://localhost:7575/api/v8/data-list-filter/list?ListKey=TestWidgetDataList
|
||||||
let res = await window.$gz.api.get(
|
let res = await window.$gz.api.get(
|
||||||
"data-list-filter/list?ListKey=" + vm.dataListKey
|
"data-list-filter/list?ListKey=" + vm.dataListKey
|
||||||
);
|
);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
vm.formState.serverError = res.error;
|
vm.formState.serverError = res.error;
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
//window.$gz.errorHandler.handleFormError(res.error, vm);
|
|
||||||
} else {
|
} else {
|
||||||
vm.selectLists.savedFilters = res.data;
|
vm.selectLists.savedFilters = res.data;
|
||||||
window.$gz.form.addNoSelectionItem(vm.selectLists.savedFilters);
|
if (vm.activeFilterId == 0) {
|
||||||
|
let dflt = res.data.find(z => z.default == true);
|
||||||
|
if (!dflt) {
|
||||||
|
throw new Error(
|
||||||
|
`data-table::populateSelectionLists - No default filter returned for listKey '${vm.dataListKey}'`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
vm.activeFilterId = dflt.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////
|
||||||
//
|
// //
|
||||||
// Fetch and cache list view
|
// // Fetch and cache list view
|
||||||
//
|
// //
|
||||||
async function fetchListView(vm) {
|
// async function fetchListView(vm) {
|
||||||
if (!vm.filterId) {
|
// if (!vm.activeFilterId) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
let res = await window.$gz.api.get("data-list-view/" + vm.filterId);
|
// let res = await window.$gz.api.get("data-list-view/" + vm.activeFilterId);
|
||||||
if (res.error) {
|
// if (res.error) {
|
||||||
if (res.error.code && res.error.code == "2010") {
|
// if (res.error.code && res.error.code == "2010") {
|
||||||
//list not found, probably deleted by another user
|
// //list not found, probably deleted by another user
|
||||||
//or on another browser and this one still had it as the last used list view
|
// //or on another browser and this one still had it as the last used list view
|
||||||
vm.filterId = 0; //indicate no list view
|
// vm.activeFilterId = 0; //indicate no list view
|
||||||
return;
|
// return;
|
||||||
} else {
|
// } else {
|
||||||
vm.formState.serverError = res.error;
|
// vm.formState.serverError = res.error;
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
// window.$gz.form.setErrorBoxErrors(vm);
|
||||||
}
|
// }
|
||||||
// window.$gz.errorHandler.handleFormError(res.error, vm);
|
// // window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||||
} else {
|
// } else {
|
||||||
vm.listView = res.data.listView;
|
// vm.listView = res.data.listView;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
@@ -1116,18 +1125,18 @@ function saveFormSettings(vm) {
|
|||||||
let unsavedlv = vm.listView;
|
let unsavedlv = vm.listView;
|
||||||
let cachedlv = vm.listView;
|
let cachedlv = vm.listView;
|
||||||
|
|
||||||
if (vm.filterId == 0) {
|
if (vm.activeFilterId == 0) {
|
||||||
//we aren't using any listview
|
//we aren't using any listview
|
||||||
unsavedlv = undefined;
|
unsavedlv = undefined;
|
||||||
cachedlv = undefined;
|
cachedlv = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.filterId == -1) {
|
if (vm.activeFilterId == -1) {
|
||||||
//we have an unsaved one in use so there is no need for a cached one
|
//we have an unsaved one in use so there is no need for a cached one
|
||||||
cachedlv = undefined;
|
cachedlv = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vm.filterId > 0) {
|
if (vm.activeFilterId > 0) {
|
||||||
//we are using a saved lv so save cached one and clear anything in unsaved one
|
//we are using a saved lv so save cached one and clear anything in unsaved one
|
||||||
unsavedlv = undefined;
|
unsavedlv = undefined;
|
||||||
}
|
}
|
||||||
@@ -1136,7 +1145,10 @@ function saveFormSettings(vm) {
|
|||||||
temp: { page: vm.dataTablePagingOptions.page, cachedListView: cachedlv },
|
temp: { page: vm.dataTablePagingOptions.page, cachedListView: cachedlv },
|
||||||
saved: {
|
saved: {
|
||||||
itemsPerPage: vm.dataTablePagingOptions.itemsPerPage,
|
itemsPerPage: vm.dataTablePagingOptions.itemsPerPage,
|
||||||
dataTable: { filterId: vm.filterId, unsavedListView: unsavedlv }
|
dataTable: {
|
||||||
|
activeFilterId: vm.activeFilterId,
|
||||||
|
unsavedListView: unsavedlv
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1151,31 +1163,31 @@ function loadFormSettings(vm) {
|
|||||||
if (formSettings.saved.itemsPerPage) {
|
if (formSettings.saved.itemsPerPage) {
|
||||||
vm.dataTablePagingOptions.itemsPerPage = formSettings.saved.itemsPerPage;
|
vm.dataTablePagingOptions.itemsPerPage = formSettings.saved.itemsPerPage;
|
||||||
}
|
}
|
||||||
if (formSettings.saved.dataTable.filterId != null) {
|
if (formSettings.saved.dataTable.activeFilterId != null) {
|
||||||
vm.filterId = formSettings.saved.dataTable.filterId;
|
vm.activeFilterId = formSettings.saved.dataTable.activeFilterId;
|
||||||
}
|
}
|
||||||
if (vm.filterId == 0) {
|
// if (vm.activeFilterId == 0) {
|
||||||
//default view, not unsaved and not saved
|
// //default view, not unsaved and not saved
|
||||||
vm.listView = undefined;
|
// vm.listView = undefined;
|
||||||
}
|
// }
|
||||||
if (vm.filterId == -1) {
|
// if (vm.activeFilterId == -1) {
|
||||||
//-1 is code for unsaved list view
|
// //-1 is code for unsaved list view
|
||||||
//check if there is a local copy of a listview vm was edited but not saved
|
// //check if there is a local copy of a listview vm was edited but not saved
|
||||||
if (formSettings.saved.dataTable.unsavedListView != null) {
|
// if (formSettings.saved.dataTable.unsavedListView != null) {
|
||||||
//add UNSAVED FILTER if -1
|
// //add UNSAVED FILTER if -1
|
||||||
|
|
||||||
vm.selectLists.savedFilters.unshift({
|
// vm.selectLists.savedFilters.unshift({
|
||||||
name: vm.$ay.t("FilterUnsaved"),
|
// name: vm.$ay.t("FilterUnsaved"),
|
||||||
id: -1
|
// id: -1
|
||||||
});
|
// });
|
||||||
|
|
||||||
vm.listView = formSettings.saved.dataTable.unsavedListView;
|
// vm.listView = formSettings.saved.dataTable.unsavedListView;
|
||||||
} else {
|
// } else {
|
||||||
//filterId is for unsaved but we have no unsaved so fix that up
|
// //activeFilterId is for unsaved but we have no unsaved so fix that up
|
||||||
vm.listView = undefined;
|
// vm.listView = undefined;
|
||||||
vm.filterId = 0;
|
// vm.activeFilterId = 0;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//process TEMP form settings
|
//process TEMP form settings
|
||||||
@@ -1184,16 +1196,16 @@ function loadFormSettings(vm) {
|
|||||||
vm.dataTablePagingOptions.page = formSettings.temp.page;
|
vm.dataTablePagingOptions.page = formSettings.temp.page;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for cached local copy of saved list view in use
|
// //check for cached local copy of saved list view in use
|
||||||
if (vm.filterId > 0) {
|
// if (vm.activeFilterId > 0) {
|
||||||
//0=no list view, -1=unsaved list view so any number greater than zero means there sb a cached local copy of a saved list view
|
// //0=no list view, -1=unsaved list view so any number greater than zero means there sb a cached local copy of a saved list view
|
||||||
if (formSettings.temp && formSettings.temp.cachedListView != null) {
|
// if (formSettings.temp && formSettings.temp.cachedListView != null) {
|
||||||
vm.listView = formSettings.temp.cachedListView;
|
// vm.listView = formSettings.temp.cachedListView;
|
||||||
} else {
|
// } else {
|
||||||
//fetch it and cache it
|
// //fetch it and cache it
|
||||||
return fetchListView(vm, vm.filterId);
|
// return fetchListView(vm, vm.activeFilterId);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//EXAMPLE FROM INTEGRATION TEST OF BETWEEN TWO DATES
|
/*//EXAMPLE FROM INTEGRATION TEST OF BETWEEN TWO DATES
|
||||||
|
|||||||
Reference in New Issue
Block a user