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