This commit is contained in:
2020-02-21 19:16:16 +00:00
parent 75a03c20da
commit 8f6403f843
2 changed files with 89 additions and 18 deletions

View File

@@ -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) {

View File

@@ -356,8 +356,34 @@
</div>
<!-- ENUM BUILDER -->
<div v-if="item.uiFieldDataType === 10">
ENUM BUILDER
{{ item.enumType }}
<v-select
v-model="item.tempFilterOperator"
:items="pickLists.enumFilterOperators"
item-text="name"
item-value="id"
:label="lt('Filter')"
prepend-icon="fa-filter"
></v-select>
<v-select
v-if="
item.tempFilterOperator != null &&
item.tempFilterOperator != '*NOVALUE*' &&
item.tempFilterOperator != '*HASVALUE*'
"
v-model="item.tempFilterValue"
:items="enumPickList(item.enumType)"
item-text="name"
item-value="id"
></v-select>
<v-btn
large
block
v-if="item.tempFilterOperator != null"
@click="addFilterCondition(item)"
><v-icon large>fa-plus</v-icon></v-btn
>
</div>
</div>
@@ -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 = ">";