From 0a93dbada80b63edde4140dd4bccc8352049a553 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Wed, 1 Sep 2021 16:49:45 +0200 Subject: [PATCH] Implement article requests --- src/components/DictionaryView.vue | 32 +++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index 24de9672..c4d2e679 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -214,19 +214,31 @@ export default { methods: { select_result: function(event) { this.event = event - if(event.articles){ + if(event.article_ids){ let source = '/' + this.lang + '/w/' + event.match this.$router.push(source) - /* - this.search_results = event.articles.map(a => Object.assign(a, {source: source})) - this.article = null - this.error = null + 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(`${api_endpoint}/${article.dictionary}/article/${article.id}`) + + })).then((response) => { + self.search_results = response.map((element, index) => { + return Object.assign(element.data, {source: source, match: event.match, dictionary: unwrapped[index].dictionary}) + }) + self.article = null + self.error = null + history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang, error: self.error}, '') + this.$plausible.trackEvent('dropdown selection', {props: {query: event.q, match: event.match}}) + + }) + + - history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang, error: this.error}, '') - */ - this.waiting_for_articles = true - navigate_to_word(this, event.match) - this.$plausible.trackEvent('dropdown selection', {props: {query: event.q, match: event.match}}) }else{ this.waiting_for_articles = true this.article = null -- GitLab