From 526a28e77ba5a0631956315c2481c0f167866726 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Fri, 24 Sep 2021 16:33:35 +0200 Subject: [PATCH] Move article id query to DictionaryView and include dict parameter --- src/components/Autocomplete.vue | 19 ++----------------- src/components/DictionaryView.vue | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index 11ccc21..0f40bb3 100644 --- a/src/components/Autocomplete.vue +++ b/src/components/Autocomplete.vue @@ -64,26 +64,11 @@ }, select(item) { if (item) { + this.items = [] if (typeof item != 'string') { - this.items = [] this.suggesting = false - - if (item.match) { - let self = this - self.api.get('articles?', {params: {lord: item.match}}).then((response) => { - item.article_ids = response.data - self.submit(item) - }) - } else { - console.log(item) - this.submit(item) - } - - } - // If blurred - else { - this.items = [] + this.submit(item) } } } diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index a6b588a..3fb2865 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -220,20 +220,21 @@ export default { methods: { select_result: function (event) { this.event = event - if (event.article_ids) { - let source = '/' + this.lang + '/w/' + event.match - this.$router.push(source) - let unwrapped = [] - for (const d in event.article_ids) { - if (d == this.lang || this.lang == "bob,nob") { - event.article_ids[d].forEach(i => unwrapped.push({ + if (event.match) { + let self = this + oda_api.get('articles?', {params: {lord: event.match, dict: this.lang}}).then((response) => { + event.article_ids = response.data + let source = '/' + this.lang + '/w/' + event.match + this.$router.push(source) + let unwrapped = [] + for (const d in event.article_ids) { + event.article_ids[d].forEach(i => unwrapped.push({ dictionary: d, id: i })) + } - - } - + let self = this Promise.all(unwrapped.map((article) => { return axios.get(`${oda_dev}/${article.dictionary}/article/${article.id}.json`) @@ -274,7 +275,7 @@ export default { error: self.error }, '') }) - } else { + })} else { this.waiting_for_articles = true this.article = null this.$router.push(`/${this.lang}/search/${event.q}`) -- GitLab