This commit is contained in:
2019-04-30 21:10:34 +00:00
parent 3495a56d04
commit caef1186db
4 changed files with 21 additions and 6 deletions

View File

@@ -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?

View File

@@ -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 {

View File

@@ -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
};

View File

@@ -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", {