From 496d26eb8cd68aa1bbb2ebe27672a6e50883e4f2 Mon Sep 17 00:00:00 2001 From: "Henrik.Askjer" <henrik.askjer@uib.no> Date: Mon, 30 Aug 2021 11:02:38 +0200 Subject: [PATCH] Various fixes --- src/components/Autocomplete.vue | 37 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index f8d07d6..e8f8600 100644 --- a/src/components/Autocomplete.vue +++ b/src/components/Autocomplete.vue @@ -53,7 +53,7 @@ debounced: debounce(function(q, self) { self.loading = true return axios.get(self.endpoint + 'suggest?', { params: {q: q, - dict: this.$parent.lang, + dict: self.$parent.lang, n: 9}} ) .then( function(response) { @@ -89,35 +89,35 @@ if (typeof item != 'string') { let self = this console.log(item.lang) + if (item.articles) { axios.get(self.endpoint + 'articles?', {params: {lord: item.match, - dict: item.lang.join(",")}}) + dict: self.$parent.lang}}) .then( function(response) { - if (item.articles) { - console.log(item) ['bob', 'nob'].forEach((dict_tag) => { - alert(dict_tag) - response[dict_tag].forEach((article_id) => { + response.data[dict_tag].forEach((article_id) => { let article = {} article.article_id = article_id article.dictionary = dict_tag + //article.source = `/${self.$parent.lang}/w/${item.match}` + article.match = item.match item.articles.push(article) + }) }) - }) - } - console.log(item) + } + ) + } + console.log(item) - self.$emit('submit', item) - this.items = [] - this.suggesting = false + self.$emit('submit', item) - } - ) - - setTimeout(() => { - self.$refs.autocomplete.$refs.input.select() - }, 1) + setTimeout(() => { + self.$refs.autocomplete.$refs.input.select() + this.items = [] + this.suggesting = false + }, 1) + } // If blurred else { @@ -129,6 +129,7 @@ methods: { run_query(q) { this.suggesting = true + // Put full text search in the list while processing suggestions if (this.items[0]) { if (this.items[0].lang) { this.items.unshift({q: q, label: q}) -- GitLab