From 60d1fb82fe6f5c6cb5c919226172dc3e051fc1cb Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 2 May 2019 00:07:13 +0000 Subject: [PATCH] --- ayanova/src/api/gzform.js | 24 ++++++-- ayanova/src/api/locale.js | 3 +- ayanova/src/views/inventory-widget-edit.vue | 67 +++++++++++---------- 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/ayanova/src/api/gzform.js b/ayanova/src/api/gzform.js index 434926ae..5098c8b0 100644 --- a/ayanova/src/api/gzform.js +++ b/ayanova/src/api/gzform.js @@ -503,10 +503,26 @@ export default { } }); }, - confirm(vm) { - return vm.$dialog.confirm({ - text: "GZFORM has a question: Do you really want to exit?", - title: "Warning" + //////////////////////////// + // + // + confirmDelete(vm) { + //https://github.com/yariksav/vuetify-dialog#readme + return vm.$dialog.warning({ + text: vm.$gzlocale.get("DeletePrompt"), + title: vm.$gzlocale.get("Delete"), + icon: "fa-exclamation-triangle", + actions: [ + { + text: vm.$gzlocale.get("Cancel"), + key: false + }, + { + text: vm.$gzlocale.get("Delete"), + color: "red", + key: true + } + ] }); } }; diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index abbae22d..3b4518de 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -91,7 +91,8 @@ export default { "ErrorAPI2209", "ErrorServerUnresponsive", "ErrorUserNotAuthenticated", - "ErrorUserNotAuthorized" + "ErrorUserNotAuthorized", + "DeletePrompt" ], decimalValidate(required) { return { required: required, decimal: [2, this.formats.decimalSeparator] }; diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index 18707989..46ef1ffc 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -401,40 +401,41 @@ export default { } }, remove() { - //Prompt: - - //do the delete - this.formState.loading = true; - var url = "Widget/" + this.$route.params.id; - //TODO: check if it's a new record (no ID) or one from server (has id) var vm = this; - this.$gzform.deleteAllErrorBoxErrors(this); - this.$gzapi - .remove(url) - .then(res => { - if (res.error) { - vm.formState.serverError = res.error; - vm.$gzform.setErrorBoxErrors(vm); - } else { - //success, navigate backwards - vm.$router.go(-1); - } - }) - .catch(function handleGetDataFromAPIError(error) { - //Update the form status - vm.$gzform.setFormState({ - vm: vm, - loading: false - }); - vm.$gzHandleFormError(error, vm); - }); + //Prompt: + vm.$gzform.confirmDelete(vm).then(dialogResult => { + if (dialogResult == true) { + //do the delete + vm.formState.loading = true; + var url = "Widget/" + vm.$route.params.id; + //TODO: check if it's a new record (no ID) or one from server (has id) + vm.$gzform.deleteAllErrorBoxErrors(vm); + vm.$gzapi + .remove(url) + .then(res => { + if (res.error) { + vm.formState.serverError = res.error; + vm.$gzform.setErrorBoxErrors(vm); + } else { + //success, navigate backwards + vm.$router.go(-1); + } + }) + .catch(function handleGetDataFromAPIError(error) { + //Update the form status + vm.$gzform.setFormState({ + vm: vm, + loading: false + }); + vm.$gzHandleFormError(error, vm); + }); + } + }); }, duplicate() { - console.log("About to dialog"); - this.$gzform.confirm(this).then(res => { - console.log("The dialog result is:"); - console.log(res); - }); + // this.$gzform.confirmDelete(this).then(res => { + // console.log(res); + // }); // this.$dialog.confirm({ // text: "Do you really want to exit?", @@ -450,7 +451,7 @@ export default { // text: "Cannot delete this item", // title: "Error" // }); - console.log("Done dialog"); + // console.log("Done dialog"); // this.$dialog.notify.info("Test notification", { // position: "top-right", @@ -468,7 +469,7 @@ export default { //check rights //duplicate //navigate to new record - //alert("STUB: DUPLICATE"); + alert("STUB: DUPLICATE"); }, stubTestClick() { this.$gzevent.$emit("menu-replace-item", {