From d44df46bb5f032d3249896ca5be4391f40611f81 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Mon, 3 Jan 2022 11:42:15 +0100 Subject: [PATCH] rework return buttons --- src/components/DictionaryView.vue | 15 ++++--- src/components/Menu.vue | 7 ++++ src/components/TopBar.vue | 68 ++++++++++++------------------- src/main.js | 9 ---- 4 files changed, 39 insertions(+), 60 deletions(-) diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index 181070bb..2284a27a 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -12,11 +12,11 @@ </div> <div class="return_to_results" v-if="total_results && article"> - <router-link v-if="previous" :to="previous" @click.native="return_to_results()"> + <router-link v-if="$store.state.searchRoute" :to="$store.state.searchRoute" @click.native="return_to_results()"> <v-icon left class="nav_arrow">chevron_left</v-icon>{{$t("back_to_results")}} </router-link> - <a v-if="!this.previous" href="/"> - <v-icon left class="nav_arrow">chevron_left</v-icon>Søk etter andre ord + <a v-if="!$store.state.searchRoute" href="/"> + <v-icon left class="nav_arrow">search</v-icon>Søk i ordbøkene </a> </div> @@ -221,9 +221,9 @@ function navigate_to_query(self, word) { self.inflection_suggestions = [] } self.waiting_for_articles = false + self.$store.commit('setSearchRoute', self.$route.fullPath) self.replace_history() - self.previous = self.$route.fullPath }) }).catch(error =>{ @@ -247,7 +247,6 @@ export default { monthly_bm: null, monthly_nn: null, event: null, - previous: this.$route.fullPath, scope: "wb", pos_selected: "ALL", article_info: null, @@ -385,7 +384,9 @@ export default { self.$forceUpdate() } - ) + ).then(() => { + this.$store.commit('setSearchRoute', this.$route.fullPath) + }) }, generate_path: function(q) { @@ -435,7 +436,6 @@ export default { } }, details_click: function(item) { - item.article.source = this.$route.fullPath this.article = item.article this.replace_history() }, @@ -511,7 +511,6 @@ export default { } }, created: function() { - console.log("CREATED") let self = this window.onpopstate = function (event) { if (event.state) { diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 51a3ddfb..502a9f16 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -99,6 +99,13 @@ export default { this.$store.commit("setDefaultDict", value) } } + }, + watch: { + $route(to, from) { + if (to.name == "about" && from.name != to.name) { + this.$store.commit('setDictRoute', from.fullPath) + } } + } } </script> diff --git a/src/components/TopBar.vue b/src/components/TopBar.vue index 15de9ae1..50c0e06c 100644 --- a/src/components/TopBar.vue +++ b/src/components/TopBar.vue @@ -1,53 +1,28 @@ <template> <div> <v-app-bar elevate-on-scroll app class = "top-bar" dense dark color="primary"> - <div class="beta" :title="release">{{version_label}}</div> - <v-spacer/> - <v-toolbar-items v-if="false"> - <v-divider vertical/> - <v-btn text width="210" :class="$vuetify.breakpoint.name"><v-icon left>language</v-icon>Norsk (Bokmål)<v-icon right>expand_more</v-icon></v-btn> - - <v-divider vertical/> - <v-menu :close-on-content-click="false" v-model="settingsMenu"> - <template v-slot:activator= "{ on, attrs }"> - <v-btn v-show="$route.name != 'about'" v-bind="attrs" v-on="on" text width="210"><v-icon left>settings</v-icon>{{$t("settings.title")}}<v-icon right>expand_more</v-icon></v-btn> - </template> - <v-card> - <v-card-text> - <LocaleMenu/> - <Settings/> - </v-card-text> - <v-card-actions><v-spacer/> - <v-btn rounded depressed @click='$store.commit("resetStore")'>{{$t('reset')}}</v-btn> - <v-btn rounded depressed @click="settingsMenu=false">{{$t("close")}}</v-btn> - </v-card-actions> - </v-card> - - </v-menu> - - <v-divider vertical/> - <v-btn text width="210" @click="toggleAbout"><v-icon left>{{$route.name=='about'? "chevron_left":"info"}}</v-icon>{{$route.name=='about'? "Tilbake":"Om ordbøkene"}}</v-btn> + <v-app-bar-title class="beta" :title="release" aria-label="Ordbøkene: Bokmålsordboka og Nynorskordboka"><a href ="/">Ordbøkene</a></v-app-bar-title> + <v-spacer/> <v-divider vertical/> + <v-toolbar-items v-if="$route.name == 'about'"> + <v-btn text @click.native="back" v-if="$store.state.dictRoute">{{$t('close')}}<v-icon right>close</v-icon></v-btn> + <v-btn text v-else @click.native="home">Søk i ordbøkene<v-icon right>search</v-icon></v-btn> </v-toolbar-items> <v-toolbar-items> - <v-divider vertical/> - <v-btn text @click="toggleAbout" v-if="$route.name == 'about'"><v-icon left>chevron_left</v-icon>{{$t("back")}}</v-btn> - - </v-toolbar-items> - - - <v-btn id="top_menu" - :aria-expanded="menuOpen? 'true' : 'false'" - aria-haspopup="menu" - width="96px" v-if="$route.name != 'about'" aria-labelledby="menu_label" text @click.native="menuOpen = !menuOpen"> - <span id="menu_label">{{$t('menu.title')}}</span><v-icon right>{{menuOpen? 'close' : 'menu'}}</v-icon></v-btn> - <v-divider vertical/> - - + <v-btn id="top_menu" + v-if="$route.name != 'about'" + :aria-expanded="menuOpen? 'true' : 'false'" + aria-haspopup="menu" + width="96px" + aria-labelledby="menu_label" + text @click.native="menuOpen = !menuOpen"> + <span id="menu_label">{{$t('menu.title')}}</span><v-icon right>{{menuOpen? 'close' : 'menu'}}</v-icon></v-btn> + </v-toolbar-items> + <v-divider vertical/> </v-app-bar> - <v-dialog origin="48px center" content-class="dialogMenu" aria-labelledby="menu_label" v-if="$route.name != 'about'" max-width="1200" width="1200" v-model="menuOpen" hide-overlay :fullscreen="$vuetify.breakpoint.xs" + <v-dialog origin="48px center" content-class="dialogMenu" aria-labelledby="menu_label" max-width="1200" width="1200" v-model="menuOpen" hide-overlay :fullscreen="$vuetify.breakpoint.xs" :close-on-content-click="false" transition="dialog-top-transition"> <Menu @close="menuOpen=false"/> </v-dialog> @@ -79,9 +54,16 @@ export default { } }, methods: { - toggleAbout: function() { - this.$route.name=='about'? this.$router.back(): this.$router.push('/om') + home: function() { + console.log("HOME", this.$store.state.dictRoute) + this.$router.push('/') + }, + back: function() { + console.log("BACK", this.$store.state.dictRoute) + this.$router.push(this.$store.state.dictRoute) + this.$store.commit('setDictRoute', null) } + }, components: { Menu, diff --git a/src/main.js b/src/main.js index 408429a8..51dcfee8 100644 --- a/src/main.js +++ b/src/main.js @@ -151,15 +151,6 @@ const store = new Vuex.Store({ } }) - -router.beforeEach((to, from, next) => { - if (to.name == 'about') { - store.commit('setDictRoute', from.fullPath) - } - next() -}) - - new Vue({ router, vuetify, -- GitLab