diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 20ae2de5..12fa167e 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -96,6 +96,7 @@ All platforms and browsers End to end action - Code for new record to the server +TODO: can I send a message via event bus which shows a popup notification? So I'm not tempted to use alert boxes all over the place [ErrorNotAuthorized] etc TODO: INVESTIGATE - DO I need to institute a back button? (in APP MODE?? installed to "desktop" on device will I be able to easily navigate without back and forward buttons) TODO: Delete widget button and rights stuff TODO: History button, other AyaNova 7 example buttons all need to be there or their equivalent, do we need a top menu type thing? diff --git a/ayanova/src/api/gzapi.js b/ayanova/src/api/gzapi.js index 8e4c310c..17256a4b 100644 --- a/ayanova/src/api/gzapi.js +++ b/ayanova/src/api/gzapi.js @@ -3,6 +3,8 @@ import store from "../store"; import router from "../router"; import auth from "./auth"; import errorHandler from "./errorhandler"; +import gzevent from "./eventbus"; +import gzlocale from "./locale" function stringifyPrimitive(v) { switch (typeof v) { @@ -30,7 +32,8 @@ function devShowUnknownError(error) { // eslint-disable-next-line console.log(error); // eslint-disable-next-line - alert( + gzevent.$emit( + "popup-message", "DEV ERROR gzapi::devShowUnknownError - unexpected error during api operation see console " ); } @@ -45,14 +48,18 @@ function handleError(action, error, route, reject) { "API error: " + action + " route =" + route + ", message =" + error.message; store.commit("logItem", errorMessage); - //BUGBUG?? What if the 401 is just a rights issue and not because they have no authentication at all?? - //perhaps that would never happen + //TODO HANDLE 403 not authorized + //popup then reject then go back in navigation or home, maybe home to be safe + //gzlocale.get("Save") + + //Handle 401 not authenticated if (error.message && error.message.includes("NotAuthenticated")) { store.commit("logItem", "User is not authorized, redirecting to login"); auth.logout(); router.push("/login"); return reject("[ErrorUserNotAuthenticated]"); } + //is it a network error? //https://medium.com/@vinhlh/how-to-handle-networkerror-when-using-fetch-ff2663220435 if (error instanceof TypeError) { @@ -84,7 +91,6 @@ export default { return Promise.reject(new Error("[ErrorUserNotAuthorized]")); } - if (response.status >= 200 && response.status < 300) { return Promise.resolve(response); } else { diff --git a/ayanova/src/api/gzmenu.js b/ayanova/src/api/gzmenu.js index 509df4d6..1d9f2c0c 100644 --- a/ayanova/src/api/gzmenu.js +++ b/ayanova/src/api/gzmenu.js @@ -184,6 +184,10 @@ export default { vm.$gzevent.$on("menu-click", function handleMenuClick(menuitem) { self.handleAppClick(vm, menuitem); }); + + vm.$gzevent.$on("popup-message", function handlePopupMessage(msg) { + alert(msg); + }); } //new functions above here }; diff --git a/ayanova/src/views/inventory-widget-edit.vue b/ayanova/src/views/inventory-widget-edit.vue index 4dd2e783..a030400d 100644 --- a/ayanova/src/views/inventory-widget-edit.vue +++ b/ayanova/src/views/inventory-widget-edit.vue @@ -397,12 +397,16 @@ export default { alert("STUB: DELETE"); }, duplicate() { - this.$gzrole.getRights(this, this.$gztype.Widget, this.obj.ownerId); + //this.$gzrole.getRights(this, this.$gztype.Widget, this.obj.ownerId); + this.$gzevent.$emit( + "popup-message", + "This is a test popup message\r\nDUPLICATE ALL THE THINGS!" + ); //only if not dirty //check rights //duplicate //navigate to new record - alert("STUB: DUPLICATE"); + //alert("STUB: DUPLICATE"); }, stubTestClick() { this.$gzevent.$emit("menu-replace-item", {