diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index f8d07d61144b98d55877a14979de151f20bcddb2..e8f86000dc4c81d04037a6f5ff78193d98b6bb0e 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})