This commit is contained in:
2020-06-19 23:08:47 +00:00
parent 160d84d954
commit 606f91092f
2 changed files with 41 additions and 48 deletions

View File

@@ -548,16 +548,14 @@ export default {
} }
} }
}, },
created() { async created() {
//get pick lists //get pick lists
let vm = this; let vm = this;
await initForm(vm);
initForm(vm).then(() => { //rehydrate last form settings
//rehydrate last form settings //loadFormSettings(vm);
//loadFormSettings(vm); vm.loading = false;
vm.loading = false; vm.getDataFromApi();
vm.getDataFromApi();
});
} }
}; };
@@ -724,10 +722,8 @@ async function fetchTranslatedHeaderNames(columnData) {
let cm = columnData[i]; let cm = columnData[i];
headerKeys.push(cm.cm); headerKeys.push(cm.cm);
} }
//Now fetch all the keys and await the response before returning //Now fetch all the keys
await window.$gz.translation.cacheTranslations(headerKeys).then(() => { await window.$gz.translation.cacheTranslations(headerKeys);
return;
});
} }
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
@@ -766,35 +762,33 @@ function initForm(vm) {
//////////////////// ////////////////////
// //
function populateSelectionLists(vm) { async function populateSelectionLists(vm) {
//http://localhost:7575/api/v8/data-list-view/viewlist?ListKey=TestWidgetDataList //http://localhost:7575/api/v8/data-list-view/viewlist?ListKey=TestWidgetDataList
return window.$gz.api let res = await window.$gz.api.get(
.get("data-list-view/viewlist?ListKey=" + vm.dataListKey) "data-list-view/viewlist?ListKey=" + vm.dataListKey
.then(res => { );
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm); window.$gz.errorHandler.handleFormError(res.error, vm);
} else { } else {
vm.selectLists.listViews = res.data; vm.selectLists.listViews = res.data;
window.$gz.form.addNoSelectionItem(vm.selectLists.listViews); window.$gz.form.addNoSelectionItem(vm.selectLists.listViews);
} }
});
} }
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// //
// Fetch and cache list view // Fetch and cache list view
// //
function fetchListView(vm) { async function fetchListView(vm) {
if (!vm.listViewId) { if (!vm.listViewId) {
return; return;
} }
return window.$gz.api.get("data-list-view/" + vm.listViewId).then(res => { let res = await window.$gz.api.get("data-list-view/" + vm.listViewId);
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm); window.$gz.errorHandler.handleFormError(res.error, vm);
} else { } else {
vm.listView = res.data.listView; vm.listView = res.data.listView;
} }
});
} }
//////////////////// ////////////////////

View File

@@ -240,7 +240,7 @@ export default {
// } // }
// } // }
}, },
getList: function(urlParams) { getList: async function(urlParams) {
let vm = this; let vm = this;
if (vm.fetching) { if (vm.fetching) {
return; return;
@@ -253,22 +253,21 @@ export default {
urlParams += "&inactive=true"; urlParams += "&inactive=true";
} }
} }
window.$gz.api try {
.get("pick-list/List" + urlParams) let res = await window.$gz.api.get("pick-list/List" + urlParams);
.then(res => {
vm.fetching = false; vm.fetching = false;
//We never expect there to be no data here //We never expect there to be no data here
if (!res.data) { if (!res.data) {
throw res; throw res;
} }
vm.searchResults = res.data; vm.searchResults = res.data;
window.$gz.form.addNoSelectionItem(vm.searchResults); window.$gz.form.addNoSelectionItem(vm.searchResults);
vm.replaceLastSelection(); vm.replaceLastSelection();
}) } catch (err) {
.catch(err => { window.$gz.errorHandler.handleFormError(err);
window.$gz.errorHandler.handleFormError(err); vm.fetching = false;
vm.fetching = false; }
});
}, },
doSearch: _.debounce(function(searchFor) { doSearch: _.debounce(function(searchFor) {
//NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly //NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly