From 77f2149627026a8195a7662fd6e18b82d1262009 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 24 Feb 2020 19:35:40 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 5 +++ ayanova/src/views/ay-data-list-view.vue | 39 ++++++++++++++++--- .../src/views/test-inventory-widget-edit.vue | 2 +- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index f18a1c2c..b6ad1029 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -278,6 +278,11 @@ TAGS - At server if equality compare value is an array of strings then it's assu ---------------------- NON DATALISTVIEW STUFF ---------------------------- TODO: "Unsaved filter" being displayed, sb "Unsaved listview" + +TODO: No way to make a new widget now!!! +TODO: new widget save re-fetches unnecessarily + - Instead should just use the data that came back with the save as it has all that's required + - should manipulate the history api instead to seem like it never was at zero record ID before save TODO: Switch control has issues in mobile view throws error "touch is undefined" - Update and see if fixes or else switch to some other component TODO: HELP link on listVieweditor not working diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 8aadf9a6..3a31bca2 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -709,9 +709,27 @@ export default { }, submit() { if (this.canSave) { - this.formState.loading = true; var vm = this; - var url = API_BASE_URL + this.$route.params.id; + vm.formState.loading = true; + + var url = API_BASE_URL; + + var lvSave = { + id: 0, + userId: vm.obj.userId || 1, + name: vm.obj.name, + public: vm.obj.public, + listKey: vm.dataListKey, + listView: generateListViewFromEdited(vm) + }; + + //are we working off a pre-existing listview (save over)? + if (vm.listViewId > 0) { + lvSave.id = vm.listViewId; + lvSave.concurrencyToken = vm.obj.concurrencyToken; + url = url + vm.listViewId; + } + /* { "id": 0, @@ -735,7 +753,7 @@ export default { //clear any errors vm might be around from previous submit window.$gz.form.deleteAllErrorBoxErrors(this); window.$gz.api - .upsert(url, this.obj) + .upsert(url, lvSave) .then(res => { vm.formState.loading = false; if (res.error != undefined) { @@ -745,7 +763,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; + + //FOr listview this is the big one to handle as it's so funky + //NOPE vm.obj = res.data; + + window.$gz.form.setFormState({ vm: vm, dirty: false, @@ -754,7 +776,14 @@ export default { //change url to new record but don't actually navigate, replace current url with same url but with the actual id at the end instead of zero: vm.$router.replace( - vm.$route.fullPath.slice(0, -1) + res.data.id + + //NOPE: vm.$route.fullPath.slice(0, -1) + res.data.id + //this is the format for listview: + //ay-data-list-view/-1/TestWidgetDataList/test-widgets + //or 0 if it's coming from the default listview + //or id number if it's got one which we don't care about here + //so mission is to replace the 0 or -1 with the real id in the url + ); } else { //Handle "put" of an existing record (UPDATE) diff --git a/ayanova/src/views/test-inventory-widget-edit.vue b/ayanova/src/views/test-inventory-widget-edit.vue index 12ab177d..a105d0a5 100644 --- a/ayanova/src/views/test-inventory-widget-edit.vue +++ b/ayanova/src/views/test-inventory-widget-edit.vue @@ -507,7 +507,7 @@ export default { readOnly: res.readOnly ? true : false }); - //change url to new record but don't actually navigate, replace current url with same url but with the actual id at the end instead of zero: + //change url to new record in history and actually navigate but with the actual id at the end instead of zero: vm.$router.replace( vm.$route.fullPath.slice(0, -1) + res.data.id );