diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 2d5f6598..d4ae5473 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -72,7 +72,7 @@ All platforms and browsers - TO TEST: Calendar on iPad in two occasions with ff and opera the calendar date could not be selected until a time was changed then the date worked. Before that it would always stay the same no matter what selection was made and the UI would not show a change on select or press of date either. - Navigation guard: navigate away with unsaved changes should warn and prevent but have option to continue anyway - + - Logout needs the same request ### RETEST ALL DEVICES WHEN GET TO HERE ##### diff --git a/ayanova/src/api/gzdialog.js b/ayanova/src/api/gzdialog.js index 5739109d..3402aa7c 100644 --- a/ayanova/src/api/gzdialog.js +++ b/ayanova/src/api/gzdialog.js @@ -53,9 +53,8 @@ export default { }); }); }, - - //////////////////////////// - // + ///////////////////////////////////// + // Are you sure you want to delete? // confirmDelete(vm) { //https://github.com/yariksav/vuetify-dialog#readme @@ -75,6 +74,26 @@ export default { } ] }); + }, ///////////////////////////////////// + // Are you sure you want to delete? + // + confirmLeaveUnsaved(vm) { + return vm.$dialog.warning({ + text: vm.$gzlocale.get("AreYouSureUnsavedChanges"), + title: vm.$gzlocale.get("Leave"), + icon: "fa-exclamation-triangle", + actions: [ + { + text: vm.$gzlocale.get("Cancel"), + key: false + }, + { + text: vm.$gzlocale.get("Leave"), + color: "red", + key: true + } + ] + }); } //new functions above here }; diff --git a/ayanova/src/api/gzmenu.js b/ayanova/src/api/gzmenu.js index b51421f1..7fa5b48f 100644 --- a/ayanova/src/api/gzmenu.js +++ b/ayanova/src/api/gzmenu.js @@ -1,5 +1,5 @@ /* Xeslint-disable */ -import { processLogout } from "./authutil"; +//import { processLogout } from "./authutil"; ///////////////////////////////// // Menu utils and handlers @@ -123,8 +123,20 @@ export default { window.open(helpurl, "_blank"); break; case "logout": - processLogout(); vm.$router.push({ name: "login" }); + // if (vm.formState && vm.formState.dirty) { + // vm.$gzdialog.confirmLeaveUnsaved(vm).then(dialogResult => { + // if (dialogResult == true) { + // processLogout(); + // vm.$router.push({ name: "login" }); + // } else { + // return; + // } + // }); + // } else { + // processLogout(); + // vm.$router.push({ name: "login" }); + // } break; case "nav": vm.$router.push({ name: item.data }); diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js index 3b4518de..e8ba5367 100644 --- a/ayanova/src/api/locale.js +++ b/ayanova/src/api/locale.js @@ -92,7 +92,9 @@ export default { "ErrorServerUnresponsive", "ErrorUserNotAuthenticated", "ErrorUserNotAuthorized", - "DeletePrompt" + "DeletePrompt", + "AreYouSureUnsavedChanges", + "Leave" ], decimalValidate(required) { return { required: required, decimal: [2, this.formats.decimalSeparator] }; diff --git a/ayanova/src/components/inventorywidgetlist.vue b/ayanova/src/components/inventorywidgetlist.vue index debb5c4c..da6f346a 100644 --- a/ayanova/src/components/inventorywidgetlist.vue +++ b/ayanova/src/components/inventorywidgetlist.vue @@ -10,17 +10,14 @@ transition="scale-transition" class="multi-line" outline - >{{ formState.errorBoxMessage }} + >{{ formState.errorBoxMessage }}
fa-splotch - - {{ this.$gzlocale.get("WidgetList") }} - + {{ this.$gzlocale.get("WidgetList") }} @@ -51,17 +48,13 @@ diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index df88034b..02038668 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -13,8 +13,7 @@ transition="scale-transition" class="multi-line" outline - >{{ formState.errorBoxMessage }} + >{{ formState.errorBoxMessage }} READY: {{ formState.ready }} -
+
LOADING: {{ formState.loading }} -
+
DIRTY: {{ formState.dirty }} -
+
VALID: {{ formState.valid }} -
+
READONLY: {{ formState.readOnly }} -
+
@@ -261,7 +260,7 @@ export default { ]; var vm = this; this.$gzlocale - .fetch(ltKeysRequired) + .fetch(ltKeysRequired) .then(() => (vm.formState.ready = true)) .catch(err => { vm.formState.ready = true; @@ -272,6 +271,20 @@ export default { this.$gzevent.$on("menu-click", clickHandler); this.getDataFromApi(); }, + beforeRouteLeave(to, from, next) { + var vm = this; + if (this.formState.dirty) { + vm.$gzdialog.confirmLeaveUnsaved(vm).then(dialogResult => { + if (dialogResult == true) { + next(); + } else { + next(false); + } + }); + } else { + next(); + } + }, beforeDestroy() { this.$gzevent.$off("menu-click", clickHandler); }, @@ -403,7 +416,6 @@ export default { }, remove() { var vm = this; - //Prompt: vm.$gzdialog.confirmDelete(vm).then(dialogResult => { if (dialogResult == true) { //do the delete