diff --git a/ayanova/src/api/enums.js b/ayanova/src/api/enums.js index 835cf36f..29559a0a 100644 --- a/ayanova/src/api/enums.js +++ b/ayanova/src/api/enums.js @@ -28,25 +28,32 @@ export default { // // Fetches enum list from server // and puts in store. if necessary + // ACCEPTS an ARRAY or a single STRING KEY // async fetchEnumList(enumKey) { - //check if list - //if not then fetch it and store it - enumKey = enumKey.toLowerCase(); + if (!window.$gz._.isArray(enumKey)) { + enumKey = [enumKey]; + } - if (!window.$gz._.has(window.$gz.store.state.enums, enumKey)) { - var that = this; + for (var i = 0; i < enumKey.length; i++) { + //check if list + //if not then fetch it and store it + var k = enumKey[i].toLowerCase(); - await that.fetch(enumKey).then(dat => { - //massage the data as necessary - var e = { enumKey: enumKey, items: {} }; - for (var i = 0; i < dat.length; i++) { - var o = dat[i]; - e.items[o.id] = o.name; - } - //stuff the data into the store - window.$gz.store.commit("setEnum", e); - }); + if (!window.$gz._.has(window.$gz.store.state.enums, k)) { + var that = this; + + await that.fetch(k).then(dat => { + //massage the data as necessary + var e = { enumKey: k, items: {} }; + for (var i = 0; i < dat.length; i++) { + var o = dat[i]; + e.items[o.id] = o.name; + } + //stuff the data into the store + window.$gz.store.commit("setEnum", e); + }); + } } }, fetch(enumKey) { diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index ae1b0685..cf1c8d51 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -356,8 +356,34 @@
- ENUM BUILDER - {{ item.enumType }} + + + + + fa-plus
@@ -485,7 +511,8 @@ export default { integerFilterOperators: [], boolFilterOperators: [], decimalFilterOperators: [], - tagFilterOperators: [] + tagFilterOperators: [], + enumFilterOperators: [] }, formState: { ready: false, @@ -512,6 +539,9 @@ export default { lt: function(ltkey) { return window.$gz.locale.get(ltkey); }, + enumPickList: function(enumKey) { + return window.$gz.enums.getPickList(enumKey); + }, includeChanged: function(item) { //Note: stock items can't be changed so no need to take that into account if (item.required && item.visible == false) { @@ -858,6 +888,7 @@ function initForm(vm) { await fetchLocalizedFieldNames(vm); await setEffectiveListView(vm); await initDataObject(vm); + await fetchEnums(vm); } catch (err) { reject(err); } @@ -1051,6 +1082,18 @@ function populatePickLists(vm) { name: vm.lt("GridRowFilterDropDownEquals"), id: "=" }); + + vm.pickLists.enumFilterOperators.push( + ...[ + { name: vm.lt("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" }, + { + name: vm.lt("GridRowFilterDropDownNonBlanksItem"), + id: "*HASVALUE*" + }, + { name: vm.lt("GridRowFilterDropDownEquals"), id: "=" }, + { name: vm.lt("GridRowFilterDropDownNotEquals"), id: "!=" } + ] + ); } //////////////////// @@ -1223,6 +1266,27 @@ function initDataObject(vm) { //eoc } +////////////////////////////////////////////////////////// +// +// Ensures localized enum lists are available pre-cached +// +function fetchEnums(vm) { + //build an array of all enums then execute method + var enumKeys = []; + for (var i = 0; i < vm.fieldDefinitions.length; i++) { + var fld = vm.fieldDefinitions[i]; + if (fld.uiFieldDataType == 10) { + enumKeys.push(fld.enumType); + } + } + if (enumKeys.length > 0) { + // console.log("fetchEnums::calling fetchenumlist for:"); + // console.log(enumKeys); + return window.$gz.enums.fetchEnumList(enumKeys); + } + return Promise.resolve(); +} + /* public const string OpEquality = "="; public const string OpGreaterThan = ">";