From 0ebf05681baaef1aae3f15188c83ee241b7bffa2 Mon Sep 17 00:00:00 2001 From: Nicky Chan Date: Tue, 21 Aug 2018 16:06:12 -0700 Subject: [PATCH] Fix initial query state (#489) * Runs state should be reflected when query changes caused by back navigation * Maintain run state after refresh --- frontend/src/common/component/AppMenu.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/src/common/component/AppMenu.vue b/frontend/src/common/component/AppMenu.vue index dd89c17c..6b36578c 100644 --- a/frontend/src/common/component/AppMenu.vue +++ b/frontend/src/common/component/AppMenu.vue @@ -16,6 +16,7 @@ depressed @mouseover="runsSelectorOpen = true" @mouseout="runsSelectorOpen = false" + :ripple="false" :color="runsSelectorOpen ? 'dark_primary' : 'primary'" :class="runsSelectorOpen ? 'runs-selected-menu-open' : 'runs-selected-menu'" > Runs: {{ runs.length == 0 ? 'None selected' : runs.join(', ') }} @@ -43,7 +44,7 @@ :key="item.name" flat dark - :class="selected === item.name ? 'menu-item-selected': 'menu-item'" + :class="selected.toLowerCase() === item.name.toLowerCase() ? 'menu-item-selected': 'menu-item'" @click="handleItemClick(item)" >{{ item.title }} @@ -109,15 +110,24 @@ export default { }; }, created() { + this.runs = this.$route.query.runs; //maintain runs state after refresh getRuns().then(({errno, data}) => { this.availableRuns = data; - this.runs = data; + if (!this.runs) this.runs = data; + //use replace here instead of push so that user cannot go back to empty run state + this.$router.replace( { path: this.initialRoute, query: { runs: this.runs }}); }); }, watch: { runs: function(val) { - this.$router.push( {query: { runs: this.runs }}); + if (this.runs) { + this.$router.push( {query: { runs: this.runs }}); + } }, + '$route' (to, from) { //this will get called when back button is hit that changes path or query + this.runs = this.$route.query.runs; + this.selected = this.$route.name; + } }, methods: { handleItemClick: function(item) { -- GitLab