From 606f91092fd0438abd6de13d346c5038279d2514 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 19 Jun 2020 23:08:47 +0000 Subject: [PATCH] --- ayanova/src/components/gz-data-table.vue | 56 +++++++++++------------- ayanova/src/components/pick-list.vue | 33 +++++++------- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 64727fd4..3b0076ad 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -548,16 +548,14 @@ export default { } } }, - created() { + async created() { //get pick lists let vm = this; - - initForm(vm).then(() => { - //rehydrate last form settings - //loadFormSettings(vm); - vm.loading = false; - vm.getDataFromApi(); - }); + await initForm(vm); + //rehydrate last form settings + //loadFormSettings(vm); + vm.loading = false; + vm.getDataFromApi(); } }; @@ -724,10 +722,8 @@ async function fetchTranslatedHeaderNames(columnData) { let cm = columnData[i]; headerKeys.push(cm.cm); } - //Now fetch all the keys and await the response before returning - await window.$gz.translation.cacheTranslations(headerKeys).then(() => { - return; - }); + //Now fetch all the keys + await window.$gz.translation.cacheTranslations(headerKeys); } ////////////////////////////////////////////////////////// @@ -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 - return window.$gz.api - .get("data-list-view/viewlist?ListKey=" + vm.dataListKey) - .then(res => { - if (res.error) { - window.$gz.errorHandler.handleFormError(res.error, vm); - } else { - vm.selectLists.listViews = res.data; - window.$gz.form.addNoSelectionItem(vm.selectLists.listViews); - } - }); + let res = await window.$gz.api.get( + "data-list-view/viewlist?ListKey=" + vm.dataListKey + ); + if (res.error) { + window.$gz.errorHandler.handleFormError(res.error, vm); + } else { + vm.selectLists.listViews = res.data; + window.$gz.form.addNoSelectionItem(vm.selectLists.listViews); + } } ////////////////////////////////////////////////////////// // // Fetch and cache list view // -function fetchListView(vm) { +async function fetchListView(vm) { if (!vm.listViewId) { return; } - return window.$gz.api.get("data-list-view/" + vm.listViewId).then(res => { - if (res.error) { - window.$gz.errorHandler.handleFormError(res.error, vm); - } else { - vm.listView = res.data.listView; - } - }); + let res = await window.$gz.api.get("data-list-view/" + vm.listViewId); + if (res.error) { + window.$gz.errorHandler.handleFormError(res.error, vm); + } else { + vm.listView = res.data.listView; + } } //////////////////// diff --git a/ayanova/src/components/pick-list.vue b/ayanova/src/components/pick-list.vue index 78ad5c44..44461508 100644 --- a/ayanova/src/components/pick-list.vue +++ b/ayanova/src/components/pick-list.vue @@ -240,7 +240,7 @@ export default { // } // } }, - getList: function(urlParams) { + getList: async function(urlParams) { let vm = this; if (vm.fetching) { return; @@ -253,22 +253,21 @@ export default { urlParams += "&inactive=true"; } } - window.$gz.api - .get("pick-list/List" + urlParams) - .then(res => { - vm.fetching = false; - //We never expect there to be no data here - if (!res.data) { - throw res; - } - vm.searchResults = res.data; - window.$gz.form.addNoSelectionItem(vm.searchResults); - vm.replaceLastSelection(); - }) - .catch(err => { - window.$gz.errorHandler.handleFormError(err); - vm.fetching = false; - }); + try { + let res = await window.$gz.api.get("pick-list/List" + urlParams); + + vm.fetching = false; + //We never expect there to be no data here + if (!res.data) { + throw res; + } + vm.searchResults = res.data; + window.$gz.form.addNoSelectionItem(vm.searchResults); + vm.replaceLastSelection(); + } catch (err) { + window.$gz.errorHandler.handleFormError(err); + vm.fetching = false; + } }, 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