diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index 9e754e4a30be80b4046e4316297812d92f8a6c3e..f8d07d61144b98d55877a14979de151f20bcddb2 100644 --- a/src/components/Autocomplete.vue +++ b/src/components/Autocomplete.vue @@ -61,7 +61,7 @@ let hits = [] response.data.forEach((item, i) => { - let hit = {q: q, match: item[0], label: item[0]} + let hit = {q: q, match: item[0], label: item[0], articles: []} hit.lang = item[1] hits.push(hit) @@ -87,13 +87,36 @@ select(item) { if (item) { if (typeof item != 'string') { - this.$emit('submit', item) - let self = this + console.log(item.lang) + axios.get(self.endpoint + 'articles?', {params: {lord: item.match, + dict: item.lang.join(",")}}) + .then( + function(response) { + if (item.articles) { + console.log(item) + ['bob', 'nob'].forEach((dict_tag) => { + alert(dict_tag) + response[dict_tag].forEach((article_id) => { + let article = {} + article.article_id = article_id + article.dictionary = dict_tag + item.articles.push(article) + + }) + }) + } + console.log(item) + + self.$emit('submit', item) + this.items = [] + this.suggesting = false + + } + ) + setTimeout(() => { self.$refs.autocomplete.$refs.input.select() - this.items = [] - this.suggesting = false }, 1) } // If blurred @@ -115,7 +138,8 @@ } } this.debounced(q, this) - } + }, + }, } </script>