This commit is contained in:
@@ -15,8 +15,7 @@ LISTVIEW REPLACE CURRENT <----HERE not THERE ---v
|
|||||||
CLIENT
|
CLIENT
|
||||||
|
|
||||||
Translation keys
|
Translation keys
|
||||||
Add the missing keys to server or find a suitable one to use
|
|
||||||
Reset, SaveCopy
|
|
||||||
|
|
||||||
pore over the translation keys in the filter manager, datatable and filter control
|
pore over the translation keys in the filter manager, datatable and filter control
|
||||||
there are definitely some extra ones in there
|
there are definitely some extra ones in there
|
||||||
|
|||||||
@@ -599,8 +599,12 @@ export default {
|
|||||||
ObjectType: ayaType,
|
ObjectType: ayaType,
|
||||||
selectedRowIds: selectedRowIds,
|
selectedRowIds: selectedRowIds,
|
||||||
dataListKey: vm.dataListKey,
|
dataListKey: vm.dataListKey,
|
||||||
listView: untokenizeListView(vm.listView),
|
// listView: untokenizeListView(vm.listView),
|
||||||
clientCriteria: vm.clientCriteria
|
filterId: vm.activeFilterId,
|
||||||
|
clientCriteria: vm.clientCriteria,
|
||||||
|
clientTimeStamp: window.$gz.locale.clientLocalZoneTimeStamp(
|
||||||
|
vm.timeZoneName
|
||||||
|
)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
handleSelectChange() {
|
handleSelectChange() {
|
||||||
@@ -726,7 +730,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let res = await window.$gz.api.upsert("data-list", {
|
let res = await window.$gz.api.post("data-list", {
|
||||||
offset: listOptions.Offset,
|
offset: listOptions.Offset,
|
||||||
limit: listOptions.Limit,
|
limit: listOptions.Limit,
|
||||||
dataListKey: vm.dataListKey,
|
dataListKey: vm.dataListKey,
|
||||||
@@ -787,6 +791,8 @@ export default {
|
|||||||
vm.getDataFromApi();
|
vm.getDataFromApi();
|
||||||
},
|
},
|
||||||
beforeUpdate() {
|
beforeUpdate() {
|
||||||
|
//WTF is beforeUpdate doing and what is resetlistview doing??
|
||||||
|
console.log("data-table: BEFORE UPDATE CALLED");
|
||||||
if (this.clientCriteria != null && this.activeFilterId != 0) {
|
if (this.clientCriteria != null && this.activeFilterId != 0) {
|
||||||
this.resetListView();
|
this.resetListView();
|
||||||
}
|
}
|
||||||
@@ -1098,60 +1104,15 @@ async function fetchSavedFilterList(vm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////
|
|
||||||
// //
|
|
||||||
// // 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;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
//
|
//
|
||||||
function saveFormSettings(vm) {
|
function saveFormSettings(vm) {
|
||||||
let unsavedlv = vm.listView;
|
|
||||||
let cachedlv = vm.listView;
|
|
||||||
|
|
||||||
if (vm.activeFilterId == 0) {
|
|
||||||
//we aren't using any listview
|
|
||||||
unsavedlv = undefined;
|
|
||||||
cachedlv = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.activeFilterId == -1) {
|
|
||||||
//we have an unsaved one in use so there is no need for a cached one
|
|
||||||
cachedlv = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.activeFilterId > 0) {
|
|
||||||
//we are using a saved lv so save cached one and clear anything in unsaved one
|
|
||||||
unsavedlv = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.$gz.form.setFormSettings(vm.formKey, {
|
window.$gz.form.setFormSettings(vm.formKey, {
|
||||||
temp: { page: vm.dataTablePagingOptions.page, cachedListView: cachedlv },
|
temp: { page: vm.dataTablePagingOptions.page },
|
||||||
saved: {
|
saved: {
|
||||||
itemsPerPage: vm.dataTablePagingOptions.itemsPerPage,
|
itemsPerPage: vm.dataTablePagingOptions.itemsPerPage,
|
||||||
dataTable: {
|
dataTable: {
|
||||||
activeFilterId: vm.activeFilterId,
|
activeFilterId: vm.activeFilterId
|
||||||
unsavedListView: unsavedlv
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1168,30 +1129,12 @@ function loadFormSettings(vm) {
|
|||||||
vm.dataTablePagingOptions.itemsPerPage = formSettings.saved.itemsPerPage;
|
vm.dataTablePagingOptions.itemsPerPage = formSettings.saved.itemsPerPage;
|
||||||
}
|
}
|
||||||
if (formSettings.saved.dataTable.activeFilterId != null) {
|
if (formSettings.saved.dataTable.activeFilterId != null) {
|
||||||
|
console.log(
|
||||||
|
"data-table:loadFormSettings, has activeFilterId saved and is:",
|
||||||
|
formSettings.saved.dataTable.activeFilterId
|
||||||
|
);
|
||||||
vm.activeFilterId = formSettings.saved.dataTable.activeFilterId;
|
vm.activeFilterId = formSettings.saved.dataTable.activeFilterId;
|
||||||
}
|
}
|
||||||
// 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.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
|
//process TEMP form settings
|
||||||
@@ -1199,113 +1142,92 @@ function loadFormSettings(vm) {
|
|||||||
if (formSettings.temp && formSettings.temp.page) {
|
if (formSettings.temp && formSettings.temp.page) {
|
||||||
vm.dataTablePagingOptions.page = formSettings.temp.page;
|
vm.dataTablePagingOptions.page = formSettings.temp.page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// //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
|
// ////////////////////
|
||||||
// dynamic fitem = new JObject();
|
// //
|
||||||
// fitem.op = Util.OpGreaterThanOrEqualTo;
|
// function untokenizeListView(lvJson) {
|
||||||
// fitem.value = new DateTime(2019, 3, 12, 10, 0, 0).ToOffsetAdjustedUniversalTime();
|
// //if it has one or more tokens
|
||||||
// items.Add(fitem);
|
// //iterate the array and build a new array with substituted tokens with the correct date and time in them
|
||||||
|
|
||||||
// fitem = new JObject();
|
// //format of a date token filter
|
||||||
// fitem.op = Util.OpLessThanOrEqualTo;
|
// //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
||||||
// fitem.value = new DateTime(2019, 3, 12, 11, 0, 0).ToOffsetAdjustedUniversalTime();
|
// if (lvJson == null) {
|
||||||
// items.Add(fitem); */
|
// return lvJson;
|
||||||
////////////////////
|
// }
|
||||||
//
|
// //See if it has any date tokens
|
||||||
function untokenizeListView(lvJson) {
|
// if (lvJson.indexOf('"token":true') == -1) {
|
||||||
//if it has one or more tokens
|
// return lvJson;
|
||||||
//iterate the array and build a new array with substituted tokens with the correct date and time in them
|
// }
|
||||||
|
|
||||||
//format of a date token filter
|
// //we have one or more tokens, substitute them in the filter array
|
||||||
//[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
// let ret = [];
|
||||||
if (lvJson == null) {
|
// let lv = JSON.parse(lvJson);
|
||||||
return lvJson;
|
|
||||||
}
|
|
||||||
//See if it has any date tokens
|
|
||||||
if (lvJson.indexOf('"token":true') == -1) {
|
|
||||||
return lvJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
//we have one or more tokens, substitute them in the filter array
|
// //iterate the incoming and copy to the outgoing directly
|
||||||
let ret = [];
|
// //except if a date token filter then substitute our own filter object in place
|
||||||
let lv = JSON.parse(lvJson);
|
// for (let ilv = 0; ilv < lv.length; ilv++) {
|
||||||
|
// //listview object
|
||||||
|
// let lvo = lv[ilv];
|
||||||
|
// //instantiate return object
|
||||||
|
// let reto = {};
|
||||||
|
// //copy over field name to return object
|
||||||
|
// reto.fld = lvo.fld;
|
||||||
|
// //sort?
|
||||||
|
// if (lvo.sort) {
|
||||||
|
// reto.sort = lvo.sort;
|
||||||
|
// }
|
||||||
|
// //does it have a filter?
|
||||||
|
// if (lvo.filter) {
|
||||||
|
// //yes, so copy / transform as required
|
||||||
|
|
||||||
//iterate the incoming and copy to the outgoing directly
|
// //create an empty filter items array on return object
|
||||||
//except if a date token filter then substitute our own filter object in place
|
// reto.filter = { items: [] };
|
||||||
for (let ilv = 0; ilv < lv.length; ilv++) {
|
|
||||||
//listview object
|
|
||||||
let lvo = lv[ilv];
|
|
||||||
//instantiate return object
|
|
||||||
let reto = {};
|
|
||||||
//copy over field name to return object
|
|
||||||
reto.fld = lvo.fld;
|
|
||||||
//sort?
|
|
||||||
if (lvo.sort) {
|
|
||||||
reto.sort = lvo.sort;
|
|
||||||
}
|
|
||||||
//does it have a filter?
|
|
||||||
if (lvo.filter) {
|
|
||||||
//yes, so copy / transform as required
|
|
||||||
|
|
||||||
//create an empty filter items array on return object
|
// //"any" property set?
|
||||||
reto.filter = { items: [] };
|
// if (lvo.filter.any) {
|
||||||
|
// reto.filter.any = true;
|
||||||
|
// }
|
||||||
|
|
||||||
//"any" property set?
|
// //iterate the filter items in the source lvo object
|
||||||
if (lvo.filter.any) {
|
// for (let j = 0; j < lvo.filter.items.length; j++) {
|
||||||
reto.filter.any = true;
|
// //get this filter item
|
||||||
}
|
// let fi = lvo.filter.items[j];
|
||||||
|
// //no token shortcut
|
||||||
|
// if (!fi.token) {
|
||||||
|
// //just copy it out
|
||||||
|
// reto.filter.items.push(fi);
|
||||||
|
// } else {
|
||||||
|
// //it has a date token so let's build it out
|
||||||
|
// //filter item value contains the token, op is always equals
|
||||||
|
// let filterDates = relativeDatefilterCalculator.tokenToDates(fi.value);
|
||||||
|
// //create and add a new filter item for each not undefined value
|
||||||
|
// //{ after: undefined, before: undefined }
|
||||||
|
// //AFTER DATE?
|
||||||
|
// if (filterDates.after) {
|
||||||
|
// reto.filter.items.push({
|
||||||
|
// op: ">", //was GreaterThanOrEqualTo but that doesn't make sense, it's only greater than was seeing wrong return data as relative date filter already adjusts for boundaries
|
||||||
|
// value: filterDates.after
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// //BEFORE DATE?
|
||||||
|
// if (filterDates.before) {
|
||||||
|
// reto.filter.items.push({
|
||||||
|
// op: "<", //was LessThanOrEqualTo but see above for after ===-----^
|
||||||
|
// value: filterDates.before
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
//iterate the filter items in the source lvo object
|
// //end of has filter if condition
|
||||||
for (let j = 0; j < lvo.filter.items.length; j++) {
|
// }
|
||||||
//get this filter item
|
|
||||||
let fi = lvo.filter.items[j];
|
|
||||||
//no token shortcut
|
|
||||||
if (!fi.token) {
|
|
||||||
//just copy it out
|
|
||||||
reto.filter.items.push(fi);
|
|
||||||
} else {
|
|
||||||
//it has a date token so let's build it out
|
|
||||||
//filter item value contains the token, op is always equals
|
|
||||||
let filterDates = relativeDatefilterCalculator.tokenToDates(fi.value);
|
|
||||||
//create and add a new filter item for each not undefined value
|
|
||||||
//{ after: undefined, before: undefined }
|
|
||||||
//AFTER DATE?
|
|
||||||
if (filterDates.after) {
|
|
||||||
reto.filter.items.push({
|
|
||||||
op: ">", //was GreaterThanOrEqualTo but that doesn't make sense, it's only greater than was seeing wrong return data as relative date filter already adjusts for boundaries
|
|
||||||
value: filterDates.after
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//BEFORE DATE?
|
|
||||||
if (filterDates.before) {
|
|
||||||
reto.filter.items.push({
|
|
||||||
op: "<", //was LessThanOrEqualTo but see above for after ===-----^
|
|
||||||
value: filterDates.before
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//end of has filter if condition
|
// //push the return object into the return array
|
||||||
}
|
// ret.push(reto);
|
||||||
|
// //end of iterate lv loop
|
||||||
|
// }
|
||||||
|
|
||||||
//push the return object into the return array
|
// return JSON.stringify(ret);
|
||||||
ret.push(reto);
|
// } //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
||||||
//end of iterate lv loop
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.stringify(ret);
|
|
||||||
} //[{"fld":"widgetname"},{"fld":"widgetstartdate","filter":{"items":[{"op":"=","value":"*past90days*","token":true}]}},{"fld":"widgetenddate"}]
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user