From 5b94fd25e1a55c7257f120e90692d678891533c4 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 19 Jul 2019 19:48:15 +0000 Subject: [PATCH] --- ayanova/src/api/errorhandler.js | 2 +- .../src/components/inventorywidgetlist.vue | 4 +- ayanova/src/main.js | 2 +- ayanova/src/views/inventory-widget-edit.vue | 79 ++++++++++--------- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/ayanova/src/api/errorhandler.js b/ayanova/src/api/errorhandler.js index a69ce4b6..f4d839b5 100644 --- a/ayanova/src/api/errorhandler.js +++ b/ayanova/src/api/errorhandler.js @@ -35,7 +35,7 @@ function dealWithError(msg, vm) { } } vm.formState.appError = msg; - vm.$gzform.setErrorBoxErrors(vm); + window.$gz.form.setErrorBoxErrors(vm); } } export default { diff --git a/ayanova/src/components/inventorywidgetlist.vue b/ayanova/src/components/inventorywidgetlist.vue index 6954277e..938dae78 100644 --- a/ayanova/src/components/inventorywidgetlist.vue +++ b/ayanova/src/components/inventorywidgetlist.vue @@ -115,7 +115,7 @@ export default { .then(() => { //don't have access to local data object until here that.rights = window.$gz.role.getRights(this, window.$gz.type.Widget); - var formSettings = that.$gzform.getFormSettings(FORM_KEY); + var formSettings = window.$gz.form.getFormSettings(FORM_KEY); /** * { temp: { page: that.localFormSettings.pagination.page }, @@ -242,7 +242,7 @@ export default { that.localFormSettings.pagination && that.localFormSettings.pagination.rowsPerPage ) { - that.$gzform.setFormSettings(FORM_KEY, { + window.$gz.form.setFormSettings(FORM_KEY, { temp: { page: that.localFormSettings.pagination.page }, saved: { rowsPerPage: that.localFormSettings.pagination.rowsPerPage, diff --git a/ayanova/src/main.js b/ayanova/src/main.js index c57ec359..659d0412 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -70,7 +70,7 @@ window.$gz = { //Object.defineProperty(Vue.prototype, "$_", { value: lodash }); //Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale }); //Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi }); -Object.defineProperty(Vue.prototype, "$gzform", { value: gzform }); +//Object.defineProperty(Vue.prototype, "$gzform", { value: gzform }); Object.defineProperty(Vue.prototype, "$gzformcustomtemplate", { value: gzformcustomtemplate }); diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index e3574aa0..8a75d360 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -25,10 +25,10 @@ :counter="255" :label="lt('WidgetName')" :rules="[ - this.$gzform.max255(this, 'name'), - this.$gzform.required(this, 'name') + form().max255(this, 'name'), + form().required(this, 'name') ]" - :error-messages="this.$gzform.serverErrors(this, 'name')" + :error-messages="form().serverErrors(this, 'name')" ref="name" @change="onChange('name')" > @@ -41,8 +41,8 @@ @click:clear="onChange('serial')" :counter="10" :label="lt('WidgetSerial')" - :rules="[this.$gzform.maxLength(this, 'serial', 10)]" - :error-messages="this.$gzform.serverErrors(this, 'serial')" + :rules="[form().maxLength(this, 'serial', 10)]" + :error-messages="form().serverErrors(this, 'serial')" ref="serial" @change="onChange('serial')" > @@ -57,10 +57,10 @@ :label="lt('WidgetCount')" ref="count" :rules="[ - this.$gzform.integerValid(this, 'count'), - this.$gzform.required(this, 'count') + form().integerValid(this, 'count'), + form().required(this, 'count') ]" - :error-messages="this.$gzform.serverErrors(this, 'count')" + :error-messages="form().serverErrors(this, 'count')" required @change="onChange('count')" type="number" @@ -76,10 +76,10 @@ ref="dollarAmount" required :rules="[ - this.$gzform.decimalValid(this, 'dollarAmount'), - this.$gzform.required(this, 'dollarAmount') + form().decimalValid(this, 'dollarAmount'), + form().required(this, 'dollarAmount') ]" - :error-messages="this.$gzform.serverErrors(this, 'dollarAmount')" + :error-messages="form().serverErrors(this, 'dollarAmount')" @change="onChange('dollarAmount')" type="number" > @@ -91,7 +91,7 @@ v-model="obj.startDate" :readonly="this.formState.readOnly" ref="startDate" - :error-messages="this.$gzform.serverErrors(this, 'startDate')" + :error-messages="form().serverErrors(this, 'startDate')" @change="onChange('startDate')" > @@ -99,10 +99,8 @@ @@ -130,10 +128,10 @@ :label="lt('WidgetRoles')" ref="roles" :rules="[ - this.$gzform.integerValid(this, 'roles'), - this.$gzform.required(this, 'roles') + form().integerValid(this, 'roles'), + form().required(this, 'roles') ]" - :error-messages="this.$gzform.serverErrors(this, 'roles')" + :error-messages="form().serverErrors(this, 'roles')" required @change="onChange('roles')" > @@ -144,7 +142,7 @@ v-model="obj.notes" :readonly="this.formState.readOnly" :label="lt('WidgetNotes')" - :error-messages="this.$gzform.serverErrors(this, 'notes')" + :error-messages="form().serverErrors(this, 'notes')" ref="notes" @change="onChange('notes')" auto-grow @@ -157,7 +155,7 @@ v-model="obj.tags" :readonly="this.formState.readOnly" ref="tags" - :error-messages="this.$gzform.serverErrors(this, 'tags')" + :error-messages="form().serverErrors(this, 'tags')" @change="onChange('tags')" > @@ -168,7 +166,7 @@ v-bind:value.sync="obj.customFields" :readOnly="this.formState.readOnly" ref="customFields" - :error-messages="this.$gzform.serverErrors(this, 'customFields')" + :error-messages="form().serverErrors(this, 'customFields')" @change="onChange('customFields')" > @@ -270,7 +268,7 @@ export default { //setup for new record var readOnly = !this.rights.change; //Update the form status - this.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: this, dirty: false, valid: true, @@ -395,9 +393,12 @@ export default { ltFormat() { return window.$gz.locale.format(); }, + form() { + return window.$gz.form; + }, onChange(ref) { if (!this.formState.loading && !this.formState.readOnly) { - this.$gzform.onChange(this, ref); + window.$gz.form.onChange(this, ref); } }, getDataFromApi(recordId) { @@ -407,7 +408,7 @@ export default { } var url = FORM_BASE_URL + recordId; var vm = this; - this.$gzform.deleteAllErrorBoxErrors(this); + window.$gz.form.deleteAllErrorBoxErrors(this); window.$gz.api .get(url) @@ -424,11 +425,11 @@ export default { }); } vm.formState.serverError = res.error; - vm.$gzform.setErrorBoxErrors(vm); + window.$gz.form.setErrorBoxErrors(vm); } else { vm.obj = res.data; //Update the form status - vm.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: vm, dirty: false, valid: true, @@ -441,7 +442,7 @@ export default { }) .catch(function handleGetDataFromAPIError(error) { //Update the form status - vm.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: vm, loading: false }); @@ -455,20 +456,20 @@ export default { var url = FORM_BASE_URL + this.$route.params.id; //clear any errors vm might be around from previous submit - this.$gzform.deleteAllErrorBoxErrors(this); + window.$gz.form.deleteAllErrorBoxErrors(this); window.$gz.api .upsert(url, this.obj) .then(res => { vm.formState.loading = false; if (res.error != undefined) { vm.formState.serverError = res.error; - vm.$gzform.setErrorBoxErrors(vm); + window.$gz.form.setErrorBoxErrors(vm); } else { //Logic for detecting if a post or put: if id then it was a post, if no id then it was a put if (res.data.id) { //Handle "post" of new record (CREATE) vm.obj = res.data; - vm.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: vm, dirty: false, readOnly: res.readOnly ? true : false @@ -481,7 +482,7 @@ export default { } else { //Handle "put" of an existing record (UPDATE) vm.obj.concurrencyToken = res.data.concurrencyToken; - vm.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: vm, dirty: false }); @@ -509,13 +510,13 @@ export default { } else { var url = FORM_BASE_URL + vm.$route.params.id; - vm.$gzform.deleteAllErrorBoxErrors(vm); + window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.api .remove(url) .then(res => { if (res.error != undefined) { vm.formState.serverError = res.error; - vm.$gzform.setErrorBoxErrors(vm); + window.$gz.form.setErrorBoxErrors(vm); } else { //workaround to prevent warning about leaving dirty record //For some reason I couldn't just reset isdirty in formstate @@ -526,7 +527,7 @@ export default { }) .catch(function handleGetDataFromAPIError(error) { //Update the form status - vm.$gzform.setFormState({ + window.$gz.form.setFormState({ vm: vm, loading: false }); @@ -543,7 +544,7 @@ export default { var url = FORM_BASE_URL + "duplicate/" + this.$route.params.id; //clear any errors vm might be around from previous submit - this.$gzform.deleteAllErrorBoxErrors(this); + window.$gz.form.deleteAllErrorBoxErrors(this); window.$gz.api .duplicate(url) .then(res => { @@ -551,7 +552,7 @@ export default { vm.formState.loading = false; if (res.error != undefined) { vm.formState.serverError = res.error; - vm.$gzform.setErrorBoxErrors(vm); + window.$gz.form.setErrorBoxErrors(vm); } else { //Navigate to new record vm.$router.push( @@ -676,7 +677,7 @@ var JUST_DELETED = false; // function initForm(vm) { // return fetchLocaleText(vm).then( // populatePickLists(vm).then( -// vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY) +// window.$gz.formcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY) // ) // ); // }