Added auto-open object and also some fixes for vuex store issues revealed when adding this feature

This commit is contained in:
2020-05-15 19:38:27 +00:00
parent c866ad684f
commit 49a0ee4c78
6 changed files with 39 additions and 20 deletions

View File

@@ -276,22 +276,6 @@ export default {
window.$gz.eventBus.$off();
},
mounted() {
//Open object after login?
if (window.location.search) {
//https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
var searchParams = new URLSearchParams(window.location.search);
var openObject = {};
//data should be format for open-object-handler
// { type: [AYATYPE], id: [RECORDID] }
if (searchParams.has("type")) {
openObject.type = searchParams.get("type");
if (searchParams.has("id")) {
openObject.type = searchParams.get("id");
}
window.$gz.store.commit("setOpenObject", openObject);
}
}
this.$root.$gzconfirm = this.$refs.gzconfirm.open;
this.$root.$gznotify = this.$refs.gznotify.addNotification;
@@ -300,6 +284,24 @@ export default {
//this smells bad but it works
this.$root.$gz = window.$gz;
//Capture open object type and id if present
//localhost:8080/login?type=2&id=22
if (window.location.search) {
//https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
var searchParams = new URLSearchParams(window.location.search);
var openObject = {};
//data should be format for open-object-handler
// { type: [AYATYPE], id: [RECORDID] }
if (searchParams.has("type")) {
openObject.type = Number(searchParams.get("type"));
if (searchParams.has("id")) {
openObject.id = Number(searchParams.get("id"));
}
window.$gz.store.commit("setOpenObject", openObject);
}
}
//redirect to login if not authenticated
if (!this.$store.state.authenticated) {
this.$router.push("login");