diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue index 11ccc2182a44e98e518e691f050f28a4725b9605..0f40bb388083a57dba9e3b408cf32aa623ecdde6 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 a6b588a7ad5fb33fe48481753b76628e71b4e693..3fb286571394eeea127cb0f2306ccf36b859bf83 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}`)