From 4dce450bbd9567e3aab469ba576c5a7f088903c6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 9 Dec 2019 22:33:20 +0000 Subject: [PATCH] --- ayanova/src/api/form-custom-template.js | 1 + ayanova/src/api/gzapi.js | 5 +++ ayanova/src/views/customize.vue | 43 ++++++++++++++----------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/ayanova/src/api/form-custom-template.js b/ayanova/src/api/form-custom-template.js index 84ace6e9..250a2c1d 100644 --- a/ayanova/src/api/form-custom-template.js +++ b/ayanova/src/api/form-custom-template.js @@ -34,6 +34,7 @@ export default { formKey: formKey, value: addDataKeyNames(JSON.parse(res.data.template)) }); + resolve(); }); } else { diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index 57d41d54..2b480c6d 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -279,6 +279,11 @@ export default { .then(that.status) .then(that.json) .then(response => { + //KEEP this for diagnostics and testing to put a delay on fetches to check if my promise-fu is on point + // setTimeout(() => { + // console.log("gzapi::get->Calling resolve now for " + route); + // resolve(response); // (**) + // }, 2000); resolve(response); }) .catch(function handleGetError(error) { diff --git a/ayanova/src/views/customize.vue b/ayanova/src/views/customize.vue index 27d35b5a..ae2fe0ac 100644 --- a/ayanova/src/views/customize.vue +++ b/ayanova/src/views/customize.vue @@ -110,14 +110,14 @@ export default { beforeCreate() { var vm = this; - initForm(this) - .then(() => { - vm.formState.ready = true; - }) - .catch(err => { - vm.formState.ready = true; - window.$gz.errorHandler.handleFormError(err); - }); + var vv = initForm(this); + + vv.then(() => { + vm.formState.ready = true; + }).catch(err => { + vm.formState.ready = true; + window.$gz.errorHandler.handleFormError(err); + }); }, beforeRouteLeave(to, from, next) { //var vm = this; @@ -297,8 +297,20 @@ function generateMenu(vm) { } function initForm(vm) { - return ensureTemplateIsInStore(vm).then(initDataObject(vm)); - //return initDataObject(vm).then(ensureTemplateIsInStore(vm)); + // var p1 = ensureTemplateIsInStore(vm); + // var p2 = p1.then(initDataObject(vm)); + // return p2; + return ensureTemplateIsInStore(vm).then(() => { + return initDataObject(vm); + }); +} + +//////////////////// +// +function ensureTemplateIsInStore(vm) { + return window.$gz.formCustomTemplate.get( + vm.$route.params.formCustomTemplateKey + ); } //////////////////// @@ -322,6 +334,7 @@ function initDataObject(vm) { //get the formAvailableField record into an object to save typing var faf = res.data[i]; //get the customTemplate record for this field if it exists + var templateItem = (templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue( vm.formCustomTemplateKey, faf.key @@ -347,7 +360,7 @@ function initDataObject(vm) { visible: templateItem.hide !== true, type: templateItem.type }; - //debugger; + vm.obj.push(objItem); } @@ -355,14 +368,6 @@ function initDataObject(vm) { }); } -//////////////////// -// -function ensureTemplateIsInStore(vm) { - return window.$gz.formCustomTemplate.get( - vm.$route.params.formCustomTemplateKey - ); -} - /* OLD (not used, drop) "ObjectCustomFieldCustomGrid": "Custom Fields",