From 5482ef30cd30537d78a83ac9d69f6e697ca6f506 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 25 Feb 2020 23:25:55 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 12 ++++----- ayanova/src/api/gzform.js | 14 ++++++++++- ayanova/src/components/gz-data-table.vue | 2 ++ ayanova/src/views/ay-data-list-view.vue | 25 ++++++++++++++----- .../src/views/test-inventory-widget-edit.vue | 11 +++----- 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 3d4221eb..dd450d8e 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -43,15 +43,15 @@ CURRENT TODOs =-=-=-=-=-=-= -todo: keeping negative symbol when unsaved and duplicate - - route replace shit not proper? (no) - - how on earth does it work with a multi digit duplicate in widget edit form - duplicate ok because it just goes to the new record - it's really used only with a zero as the record id which is one digit so always works to replace - since a listview can be -1 it needs to use the replace to last slash method it was using prior instead + + TODO: when filter saved sb the one used when you return to the form no exceptions - right now it returns to the "unsaved", maybe it's not setting formsettings correctly on leave if saved + - actually caused by formstate dirty on exit of listVieweditor + - Is form submit POST route actually reloading the listVieweditor as expected? Looks like not? + +TODO: no data should only show if not loading on datatable todo: default "df" thing isn't really working at the moment, I can remove the Name column from widgets and then I can't open a widget from teh grid - see if "df" has any purpose other than my initial though of an openable option for the record diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index 7e891ff8..f32afb8f 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -654,10 +654,17 @@ export default { // and temporary ones are stored in session storage and don't persist a refresh // getFormSettings(formKey) { - return { + var formSettings = { temp: JSON.parse(sessionStorage.getItem(formKey)), saved: window.$gz.store.state.formSettings[formKey] }; + + console.log( + "gzForm::getFormSettings list view id is:" + + window.$gz.store.state.formSettings["test-widgets"].dataTable.listViewId + ); + + return formSettings; }, //////////////////////////////////// // Set form settings @@ -682,6 +689,11 @@ export default { if (formSettings.temp) { sessionStorage.setItem(formKey, JSON.stringify(formSettings.temp)); } + console.trace(); + console.log( + "gzForm::setFormSettings at bottom after commit, listviewid in store is:" + + window.$gz.store.state.formSettings["test-widgets"].dataTable.listViewId + ); }, //////////////////////////////////// // Add no selection item // Used by forms that need the option of an unselected diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index df56011a..3aa7f6fa 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -783,7 +783,9 @@ function saveFormSettings(vm) { function loadFormSettings(vm) { //console.log("loadFormSettings::TOP"); // debugger; + console.log("gz-data-table::loadFormSettings getting form settings"); var formSettings = window.$gz.form.getFormSettings(vm.formKey); + //process SAVED formsettings if (formSettings.saved) { if (formSettings.saved.itemsPerPage) { diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 4394afb6..92736bda 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -429,14 +429,15 @@ const API_BASE_URL = "DataListView/"; var JUST_DELETED = false; export default { // beforeRouteEnter(to, from, next) { - // var ltKeysRequired = ["DataListView", "GridFilterName"]; - - // window.$gz.locale.fetch(ltKeysRequired).then(next); + // console.log("ay-data-list-view::beforeRouteEnter hit"); + // next(); // }, //unsaved changes are actually valid for this form so no need to warn beforeRouteLeave(to, from, next) { + console.log("ay-data-list-view::beforeRouteLeave hit"); var vm = this; if (this.formState.dirty && !JUST_DELETED) { + console.log("before route leave: setting to unsaved list view "); //Put in unsaved listview var formSettings = window.$gz.form.getFormSettings(vm.formKey); formSettings.saved.dataTable.unsavedListView = JSON.stringify( @@ -455,15 +456,14 @@ export default { }, created() { var vm = this; - + console.log("ay-data-list-view::created hit"); //set route values in data object so init form can handle vm.dataListKey = this.$route.params.dataListKey; vm.listViewId = this.$route.params.listViewId; vm.formKey = this.$route.params.formKey; - //console.log("Created TOP calling initform..."); + initForm(vm) .then(() => { - //console.log("CREATED: back from initform"); // path: "/ay-data-list-view/:listViewId/:dataListKey", vm.formState.ready = true; @@ -755,9 +755,15 @@ export default { 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 + // debugger; if (res.data.id) { //Handle "post" of new record (CREATE) + console.log( + "ay-data-list-view::submit, updating form settings, res.data.id is: " + + res.data.id + ); + //Update the formSettings now that it's saved var formSettings = window.$gz.form.getFormSettings(vm.formKey); formSettings.temp.cachedListview = lvSave.listView; @@ -765,6 +771,13 @@ export default { formSettings.saved.dataTable.listViewId = res.data.id; window.$gz.form.setFormSettings(vm.formKey, formSettings); + //No longer dirty + window.$gz.form.setFormState({ + vm: vm, + dirty: false + //, readOnly: res.readOnly ? true : false + }); + //change url to new record vm.$router.replace( window.$gz.api.replaceAfterLastSlash( diff --git a/ayanova/src/views/test-inventory-widget-edit.vue b/ayanova/src/views/test-inventory-widget-edit.vue index 6639c841..fdb48414 100644 --- a/ayanova/src/views/test-inventory-widget-edit.vue +++ b/ayanova/src/views/test-inventory-widget-edit.vue @@ -500,14 +500,11 @@ export default { //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; - // window.$gz.form.setFormState({ - // vm: vm, - // dirty: false, - // readOnly: res.readOnly ? true : false - // }); - //change url to new record in history and trigger navigate but with the id at the end instead of zero: + //change url to new record in history + //NOTE: will not cause a new navigate, almost nothing does unless forced with a KEY property or using router.GO() + //but will trigger navigation guard beforeRouteUpdate which we use here in this form + //to fetch data again vm.$router.replace( vm.$route.fullPath.slice(0, -1) + res.data.id );