Skip to content
Snippets Groups Projects
Commit 183c4c54 authored by Henrik Askjer's avatar Henrik Askjer
Browse files

get articles

parent e2d5fc9d
No related branches found
No related tags found
No related merge requests found
...@@ -62,37 +62,17 @@ ...@@ -62,37 +62,17 @@
select(item) { select(item) {
if (item) { if (item) {
if (typeof item != 'string') { if (typeof item != 'string') {
let self = this this.items = []
/* this.suggesting = false
if (item.articles) { if (item.article_promise) {
axios.get(self.endpoint + 'articles?', {params: {lord: item.match, item.article_promise.then((response) => {
dict: self.$parent.lang}}) item.article_ids = response.data
.then( this.submit(item)
function(response) { })
['bob', 'nob'].forEach((dict_tag) => { }
response.data[dict_tag].forEach((article_id) => { else {
let article = {} this.submit(item)
article.article_id = article_id
article.dictionary = dict_tag
article.match = item.match
item.articles.push(article)
})
})
}
)
} }
*/
this.items = []
this.suggesting = false
self.$emit('submit', item)
setTimeout(() => {
self.$refs.autocomplete.$refs.input.select()
this.items = []
this.suggesting = false
}, 1)
} }
// If blurred // If blurred
else { else {
...@@ -123,7 +103,7 @@ ...@@ -123,7 +103,7 @@
let hits = [] let hits = []
response.data.forEach((item, i) => { response.data.forEach((item, i) => {
let hit = {q: q, match: item[0], label: item[0], articles: []} let hit = {q: q, match: item[0], label: item[0], article_promise: self.get_articles(item[0])}
hit.lang = item[1] hit.lang = item[1]
hits.push(hit) hits.push(hit)
...@@ -132,12 +112,25 @@ ...@@ -132,12 +112,25 @@
hits.push({q: q, label: q + ' '}) hits.push({q: q, label: q + ' '})
self.items = hits self.items = hits
} }
self.loading = false self.loading = false
}) })
}, },
get_articles(match) {
let self = this
return axios.get(self.endpoint + 'articles?', {params: {lord: match, dict: self.$parent.lang}})
},
submit(item) {
this.$emit('submit', item)
let self = this
setTimeout(() => {
self.$refs.autocomplete.$refs.input.select()
this.items = []
this.suggesting = false
}, 1)
}
}, },
} }
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment