未验证 提交 0ebf0568 编写于 作者: N Nicky Chan 提交者: GitHub

Fix initial query state (#489)

* Runs state should be reflected when query changes caused by back navigation

* Maintain run state after refresh
上级 2e756930
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
depressed depressed
@mouseover="runsSelectorOpen = true" @mouseover="runsSelectorOpen = true"
@mouseout="runsSelectorOpen = false" @mouseout="runsSelectorOpen = false"
:ripple="false"
:color="runsSelectorOpen ? 'dark_primary' : 'primary'" :color="runsSelectorOpen ? 'dark_primary' : 'primary'"
:class="runsSelectorOpen ? 'runs-selected-menu-open' : 'runs-selected-menu'" :class="runsSelectorOpen ? 'runs-selected-menu-open' : 'runs-selected-menu'"
> <span class="runs-selected-text">Runs: {{ runs.length == 0 ? 'None selected' : runs.join(', ') }} </span> > <span class="runs-selected-text">Runs: {{ runs.length == 0 ? 'None selected' : runs.join(', ') }} </span>
...@@ -43,7 +44,7 @@ ...@@ -43,7 +44,7 @@
:key="item.name" :key="item.name"
flat flat
dark dark
:class="selected === item.name ? 'menu-item-selected': 'menu-item'" :class="selected.toLowerCase() === item.name.toLowerCase() ? 'menu-item-selected': 'menu-item'"
@click="handleItemClick(item)" @click="handleItemClick(item)"
>{{ item.title }}</v-btn> >{{ item.title }}</v-btn>
</v-toolbar-items> </v-toolbar-items>
...@@ -109,15 +110,24 @@ export default { ...@@ -109,15 +110,24 @@ export default {
}; };
}, },
created() { created() {
this.runs = this.$route.query.runs; //maintain runs state after refresh
getRuns().then(({errno, data}) => { getRuns().then(({errno, data}) => {
this.availableRuns = 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: { watch: {
runs: function(val) { 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: { methods: {
handleItemClick: function(item) { handleItemClick: function(item) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册