diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 7b15d4e9..95c53f80 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -65,15 +65,13 @@ CURRENT TODOs @@@@@@@@@@@ ROADMAP STAGE 2: - -todo: Test widget form as bizamdinlimited read only mode because I think several things are not right in read only mode - - remove clear button and option if read only - - make sure can't use any of the controls the make changes - todo: bug regression, customize form shows dirty immediately after good save? - this is similar to other shit I saw, maybe there was a change that somehow broke the isdirty code - check all saveable forms for this issue +todo: readonly on all forms make sure it's ok, because on customize form I see no save but can edit + - (logged in as bizadminlimited) + todo: BUG Something fucked with history? When I click on a widget's history button in admin user history view it shows two created record with differing timestamps - note, it doesn't seem to do it on the most recent widgets, but only on the first few created for some reason?! diff --git a/ayanova/src/views/adm-global-select-templates.vue b/ayanova/src/views/adm-global-select-templates.vue index 8f7ab0c7..533c63f7 100644 --- a/ayanova/src/views/adm-global-select-templates.vue +++ b/ayanova/src/views/adm-global-select-templates.vue @@ -47,7 +47,7 @@ { - vm.formState.ready = true; - vm.readOnly = !vm.rights.change; + vm.formState.readOnly = !vm.rights.change; window.$gz.eventBus.$on("menu-click", clickHandler); //NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here //modify the menu as necessary @@ -94,8 +93,11 @@ export default { window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save"); }) .catch(err => { - vm.formState.ready = true; window.$gz.errorHandler.handleFormError(err, vm); + }) + .finally(function() { + vm.formState.ready = true; + vm.formState.loading = false; }); }, data() { @@ -120,7 +122,25 @@ export default { rights: window.$gz.role.getRights(window.$gz.type.FormCustom) }; }, + //WATCHERS + watch: { + formState: { + handler: function(val) { + //,oldval is available here too if necessary + if (this.formState.loading) { + return; + } + //enable / disable save button + if (val.dirty && val.valid && !val.readOnly) { + window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save"); + } else { + window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save"); + } + }, + deep: true + } + }, methods: { visibleChanged: function(item) { //Note: stock items can't be changed so no need to take that into account @@ -128,7 +148,6 @@ export default { item.required = false; } this.formState.dirty = true; - enableSaveButton(); }, requiredChanged: function(item) { //Note: stock items can't be changed so no need to take that into account @@ -136,15 +155,15 @@ export default { item.visible = true; } this.formState.dirty = true; - enableSaveButton(); }, dataTypeChanged: function(item) { //nothing to scan here just set form dirty this.formState.dirty = true; - enableSaveButton(); }, submit() { let vm = this; + + vm.formState.loading = true; let url = API_BASE_URL + vm.formCustomTemplateKey; //clear any errors vm might be around from previous submit @@ -195,7 +214,6 @@ export default { window.$gz.api .upsert(url, newObj) .then(res => { - vm.formState.loading = false; if (res.error) { vm.formState.serverError = res.error; window.$gz.form.setErrorBoxErrors(vm); @@ -220,17 +238,15 @@ export default { } }) .catch(function handleSubmitError(error) { - vm.formState.loading = false; window.$gz.errorHandler.handleFormError(error, vm); + }) + .finally(function() { + vm.formState.loading = false; }); } } }; -function enableSaveButton() { - window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save"); -} - ///////////////////////////// // // diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 5cc55d27..504b2f84 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -10,7 +10,7 @@