From c866ad684f0b0a239fe453981079a326c5d3c62a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 15 May 2020 18:29:22 +0000 Subject: [PATCH] --- ayanova/src/App.vue | 4 ++++ ayanova/src/api/open-object-handler.js | 12 +++++++++++- ayanova/src/store.js | 5 ++++- ayanova/src/views/login.vue | 10 +++++++--- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ayanova/src/App.vue b/ayanova/src/App.vue index 446eb8c0..3bfa937c 100644 --- a/ayanova/src/App.vue +++ b/ayanova/src/App.vue @@ -303,6 +303,10 @@ export default { //redirect to login if not authenticated if (!this.$store.state.authenticated) { this.$router.push("login"); + } else { + //this can be safely called any time, it checks if there is an open object in store and + //opens it or if not just returns + window.$gz.eventBus.$emit("openobject", null); } //FUTURE: If need to detect a reload, this works reliably diff --git a/ayanova/src/api/open-object-handler.js b/ayanova/src/api/open-object-handler.js index 858befca..767f4d70 100644 --- a/ayanova/src/api/open-object-handler.js +++ b/ayanova/src/api/open-object-handler.js @@ -7,7 +7,17 @@ export default { // Deal with a request to open an object (from main datatables mainly) // called from App.vue handleOpenObjectClick(vm, tid) { - //expects extra data (tid) to be { type: [AYATYPE], id: [RECORDID] } + //expects extra data (tid) to be one of { type: [AYATYPE], id: [RECORDID] } + //or null which is what is called when asking to check if there is a direct openObject in store and open it + + if (tid == null) { + let op = vm.$store.state.openObject; + if (op && op.type) { + tid = op; + window.$gz.store.commit("clearOpenObject"); + } else return; //bail out, nothing to open here + } + //NOTE: for new objects all edit pages assume record ID 0 means create rather than open if (tid.type && tid.id != null) { diff --git a/ayanova/src/store.js b/ayanova/src/store.js index efd3e12b..25232cc6 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -10,7 +10,7 @@ Vue.use(Vuex); export default new Vuex.Store({ plugins: [createPersistedState()], state: { - openObject: {}, + openObject: null, lastClientVersion: "", authenticated: false, apiUrl: "", @@ -128,6 +128,9 @@ export default new Vuex.Store({ //data should be format for open-object-handler // { type: [AYATYPE], id: [RECORDID] } state.openObject = data; + }, + clearOpenObject(state) { + state.openObject = null; } }, actions: {} diff --git a/ayanova/src/views/login.vue b/ayanova/src/views/login.vue index 08343ee3..8cf32a31 100644 --- a/ayanova/src/views/login.vue +++ b/ayanova/src/views/login.vue @@ -226,8 +226,8 @@ export default { window.$gz.api .get("notify/hello") .then(res => { - if (res.data) { - // console.log("res.data:", res.data); + if (res.data != null) { + // console.log("res.data:", res.data); vm.trialMode = !res.data; } }) @@ -260,7 +260,11 @@ export default { auth .authenticate(vm.input.username, vm.input.password) .then(() => { - vm.$router.push(vm.$store.state.homePage); + if (vm.$store.state.openObject) { + window.$gz.eventBus.$emit("openobject", null); + } else { + vm.$router.push(vm.$store.state.homePage); + } }) .catch(function handleCaughtLoginError(error) { //bad creds?