From e5ec60e19709bb2e236bb82397df1dd1355d4ce2 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Tue, 12 Oct 2021 09:17:02 +0200 Subject: [PATCH] carry out search when selecting part of speech. Pusj to router --- src/components/DictionaryView.vue | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index d850a523..e8f782d7 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -31,7 +31,7 @@ </v-radio-group> </div> <div class="pos_select_container"> - <v-select + <v-select @change="update_pos" dense rounded disable-lookup @@ -194,7 +194,7 @@ function navigate_to_query(self, word) { let query = self.event ? self.event : {q: word} // Get article IDs - api.get('articles?', {params: {w: query.match || query.q, dict: self.lang, scope: "w", stage: self.stage}}).then((response) => { + api.get('articles?', {params: {w: query.match || query.q, dict: self.lang, scope: "w", stage: self.stage, wc: self.pos_selected.tag}}).then((response) => { let article_ids = response.data let unwrapped = [] for (const d in article_ids) { @@ -332,6 +332,23 @@ export default { navigate_to_query(this, query) } }, + update_pos: function (pos) { + this.pos_selected = pos + let name = null + let query = null + if(this.$route.name == 'word') { + name = "w" + query = this.$route.params.word + this.$router.push(`/${this.lang}/${name}/${query}/${pos.tag.toLowerCase()}`) + navigate_to_query(this, query) + } + else if (this.$route.name == 'search') { + name = "search" + query = this.$route.params.query + this.$router.push(`/${this.lang}/${query}/${pos.tag.toLowerCase()}`) + navigate_to_query(this, query) + } + }, article_link_click: function(item) { if (this.article && this.article.article_id == item.article_id){ this.article_key++ -- GitLab