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

Get article IDs

parent 0de9f409
No related branches found
No related tags found
No related merge requests found
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,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]} let hit = {q: q, match: item[0], label: item[0], articles: []}
hit.lang = item[1] hit.lang = item[1]
hits.push(hit) hits.push(hit)
...@@ -87,13 +87,36 @@ ...@@ -87,13 +87,36 @@
select(item) { select(item) {
if (item) { if (item) {
if (typeof item != 'string') { if (typeof item != 'string') {
this.$emit('submit', item)
let self = this 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(() => { setTimeout(() => {
self.$refs.autocomplete.$refs.input.select() self.$refs.autocomplete.$refs.input.select()
this.items = []
this.suggesting = false
}, 1) }, 1)
} }
// If blurred // If blurred
...@@ -115,7 +138,8 @@ ...@@ -115,7 +138,8 @@
} }
} }
this.debounced(q, this) this.debounced(q, this)
} },
}, },
} }
</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