@@ -467,7 +468,7 @@ export default {
async open(tableColumnData) {
this.tableColumnData = tableColumnData;
- await getActiveFilter(vm);
+ await fetchActiveFilter(this);
initEditItem(this);
this.isVisible = true;
return new Promise((resolve, reject) => {
@@ -526,9 +527,7 @@ async function populateFieldDefinitions(vm) {
//
async function fetchActiveFilter(vm) {
///api/v8/data-list-filter/{id}
- let res = await window.$gz.api.get(
- `/api/v8/data-list-filter/${vm.activeFilterId}`
- );
+ let res = await window.$gz.api.get(`data-list-filter/${vm.activeFilterId}`);
if (res.error) {
//throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
diff --git a/ayanova/src/components/data-table.vue b/ayanova/src/components/data-table.vue
index 82fc9e08..d3963c4f 100644
--- a/ayanova/src/components/data-table.vue
+++ b/ayanova/src/components/data-table.vue
@@ -3,7 +3,7 @@
@@ -12,7 +12,7 @@
{{ headers }} -->
0) {
+ } else if (vm.activeFilterId > 0) {
await fetchListView(vm);
saveFormSettings(vm);
}
@@ -788,7 +789,7 @@ export default {
vm.getDataFromApi();
},
beforeUpdate() {
- if (this.clientCriteria != null && this.filterId != 0) {
+ if (this.clientCriteria != null && this.activeFilterId != 0) {
this.resetListView();
}
}
@@ -1071,44 +1072,52 @@ async function initForm(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(
"data-list-filter/list?ListKey=" + vm.dataListKey
);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
- //window.$gz.errorHandler.handleFormError(res.error, vm);
} else {
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
-//
-async function fetchListView(vm) {
- if (!vm.filterId) {
- return;
- }
- let res = await window.$gz.api.get("data-list-view/" + vm.filterId);
- if (res.error) {
- if (res.error.code && res.error.code == "2010") {
- //list not found, probably deleted by another user
- //or on another browser and this one still had it as the last used list view
- vm.filterId = 0; //indicate no list view
- return;
- } else {
- vm.formState.serverError = res.error;
- window.$gz.form.setErrorBoxErrors(vm);
- }
- // window.$gz.errorHandler.handleFormError(res.error, vm);
- } else {
- vm.listView = res.data.listView;
- }
-}
+// //////////////////////////////////////////////////////////
+// //
+// // Fetch and cache list view
+// //
+// async function fetchListView(vm) {
+// if (!vm.activeFilterId) {
+// return;
+// }
+// let res = await window.$gz.api.get("data-list-view/" + vm.activeFilterId);
+// if (res.error) {
+// if (res.error.code && res.error.code == "2010") {
+// //list not found, probably deleted by another user
+// //or on another browser and this one still had it as the last used list view
+// vm.activeFilterId = 0; //indicate no list view
+// return;
+// } else {
+// vm.formState.serverError = res.error;
+// window.$gz.form.setErrorBoxErrors(vm);
+// }
+// // window.$gz.errorHandler.handleFormError(res.error, vm);
+// } else {
+// vm.listView = res.data.listView;
+// }
+// }
////////////////////
//
@@ -1116,18 +1125,18 @@ function saveFormSettings(vm) {
let unsavedlv = vm.listView;
let cachedlv = vm.listView;
- if (vm.filterId == 0) {
+ if (vm.activeFilterId == 0) {
//we aren't using any listview
unsavedlv = 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
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
unsavedlv = undefined;
}
@@ -1136,7 +1145,10 @@ function saveFormSettings(vm) {
temp: { page: vm.dataTablePagingOptions.page, cachedListView: cachedlv },
saved: {
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) {
vm.dataTablePagingOptions.itemsPerPage = formSettings.saved.itemsPerPage;
}
- if (formSettings.saved.dataTable.filterId != null) {
- vm.filterId = formSettings.saved.dataTable.filterId;
+ if (formSettings.saved.dataTable.activeFilterId != null) {
+ vm.activeFilterId = formSettings.saved.dataTable.activeFilterId;
}
- if (vm.filterId == 0) {
- //default view, not unsaved and not saved
- vm.listView = undefined;
- }
- if (vm.filterId == -1) {
- //-1 is code for unsaved list view
- //check if there is a local copy of a listview vm was edited but not saved
- if (formSettings.saved.dataTable.unsavedListView != null) {
- //add UNSAVED FILTER if -1
+ // if (vm.activeFilterId == 0) {
+ // //default view, not unsaved and not saved
+ // vm.listView = undefined;
+ // }
+ // if (vm.activeFilterId == -1) {
+ // //-1 is code for unsaved list view
+ // //check if there is a local copy of a listview vm was edited but not saved
+ // if (formSettings.saved.dataTable.unsavedListView != null) {
+ // //add UNSAVED FILTER if -1
- vm.selectLists.savedFilters.unshift({
- name: vm.$ay.t("FilterUnsaved"),
- id: -1
- });
+ // vm.selectLists.savedFilters.unshift({
+ // name: vm.$ay.t("FilterUnsaved"),
+ // id: -1
+ // });
- vm.listView = formSettings.saved.dataTable.unsavedListView;
- } else {
- //filterId is for unsaved but we have no unsaved so fix that up
- vm.listView = undefined;
- vm.filterId = 0;
- }
- }
+ // vm.listView = formSettings.saved.dataTable.unsavedListView;
+ // } else {
+ // //activeFilterId is for unsaved but we have no unsaved so fix that up
+ // vm.listView = undefined;
+ // vm.activeFilterId = 0;
+ // }
+ // }
}
//process TEMP form settings
@@ -1184,16 +1196,16 @@ function loadFormSettings(vm) {
vm.dataTablePagingOptions.page = formSettings.temp.page;
}
- //check for cached local copy of saved list view in use
- if (vm.filterId > 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
- if (formSettings.temp && formSettings.temp.cachedListView != null) {
- vm.listView = formSettings.temp.cachedListView;
- } else {
- //fetch it and cache it
- return fetchListView(vm, vm.filterId);
- }
- }
+ // //check for cached local copy of saved list view in use
+ // 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
+ // if (formSettings.temp && formSettings.temp.cachedListView != null) {
+ // vm.listView = formSettings.temp.cachedListView;
+ // } else {
+ // //fetch it and cache it
+ // return fetchListView(vm, vm.activeFilterId);
+ // }
+ // }
}
/*//EXAMPLE FROM INTEGRATION TEST OF BETWEEN TWO DATES