From d5ab0cf273afcc214954d7504fb4fb1e7f82e6bc Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Thu, 6 Jan 2022 12:02:35 +0100 Subject: [PATCH] update language when switching on front page --- src/components/Autocomplete.vue | 9 ++++++++- src/components/DictionaryView.vue | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index 99c16bf5..4e389409 100644 --- a/src/components/Autocomplete.vue +++ b/src/components/Autocomplete.vue @@ -59,7 +59,7 @@ </template> <v-list> <v-list-item v-for="item in ['bm,nn','bm','nn'].map(l => {return {label: $t(`dicts.${l}`), tag: l}})" :key="item.tag" - active-class="v-list-item--active" :class="$parent.lang == item.tag ? 'v-list-item--active' : ''" @click="$parent.update_lang_form(item.tag)"> + active-class="v-list-item--active" :class="$parent.lang == item.tag ? 'v-list-item--active' : ''" @click="update_lang_form(item.tag)"> <v-list-item-title >{{ item.label }}</v-list-item-title> </v-list-item> @@ -130,6 +130,13 @@ } }, methods: { + update_lang_form(lang) { + this.$emit('update-lang-form', lang) + // Submit if switching on front page + if (this.search && !this.items[0]) { + this.submit({q: this.search, match: this.search, time: Date.now()}) + } + }, get_lang() { return this.$parent.lang }, diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index 942d0e95..302b7d4b 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -1,7 +1,7 @@ <template> <main> <div class="search_container" v-if="!article"> - <Autocomplete v-on:submit="select_result" :api="get_search_endpoint"> + <Autocomplete v-on:submit="select_result" :api="get_search_endpoint" v-on:update-lang-form="update_lang_form"> </Autocomplete> <SearchToolbar v-if="$store.state.showSearchToolbar" @updatePos="update_pos" @updateScope="update_scope"/> -- GitLab