From 10437c4ca414d26e0a448950d3fd99f872211e8f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 6 Dec 2019 21:58:45 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 16 +++++++++++-- ayanova/src/views/customize.vue | 41 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 4d4593b1..b2e34411 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -44,10 +44,22 @@ CURRENT ROADMAP CURRENT TODOs =-=-=-=-=-=-= + +Happy monday!! +In the midst of custom form saving which also requires a little modification in the server see FormCustomBiz GetAsync for details +then back here to code out the PUT route save of the form and also update local store. + TODO: Form customization + - When go to save then synthesize the record to send back - - Update the Store on success - - Do not add any custom fields not set to be displayed, their mere presence in teh template means they are to be displayed + - SAVE + - Update the Store on success + - Do not add any custom fields not set to be displayed, their mere presence in teh template means they are to be displayed + - POST vs PUT? Is post ever appropriate? Shouldn't every form have a custom if it can already and if it's fetched and doesn't exist make one? + - Maybe need to modify the db init code in server to also create formCustom for every possible formCustom object and then only have a PUT route, no post? + - Perhaps GET route will create one automatically if it's something that should exist but doesn't and return that? Dynamically? + - Saves data storage for unused forms, but really that won't be shit anyway so...? + TODO: HELP LINKS - Make sure each form has a unique help link and also make a stub page in the documentation for that help link to be filled in later or now if applicable diff --git a/ayanova/src/views/customize.vue b/ayanova/src/views/customize.vue index 9e898be1..27d35b5a 100644 --- a/ayanova/src/views/customize.vue +++ b/ayanova/src/views/customize.vue @@ -193,6 +193,47 @@ export default { //nothing to scan here just set form dirty this.formState.dirty = true; enableSaveButton(); + }, + submit() { + var vm = this; + var url = API_BASE_URL + this.$route.params.id; + + //clear any errors vm might be around from previous submit + 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; + 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; + window.$gz.form.setFormState({ + vm: vm, + dirty: false, + 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: + vm.$router.replace(vm.$route.fullPath.slice(0, -1) + res.data.id); + } else { + //Handle "put" of an existing record (UPDATE) + vm.obj.concurrencyToken = res.data.concurrencyToken; + window.$gz.form.setFormState({ + vm: vm, + dirty: false + }); + } + } + }) + .catch(function handleSubmitError(error) { + vm.formState.loading = false; + window.$gz.errorHandler.handleFormError(error, vm); + }); } } };