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

Move article id query to DictionaryView and include dict parameter

parent 7642c6c5
No related branches found
No related tags found
No related merge requests found
...@@ -64,26 +64,11 @@ ...@@ -64,26 +64,11 @@
}, },
select(item) { select(item) {
if (item) { if (item) {
this.items = []
if (typeof item != 'string') { if (typeof item != 'string') {
this.items = []
this.suggesting = false this.suggesting = false
if (item.match) { this.submit(item)
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 = []
} }
} }
} }
......
...@@ -220,20 +220,21 @@ export default { ...@@ -220,20 +220,21 @@ export default {
methods: { methods: {
select_result: function (event) { select_result: function (event) {
this.event = event this.event = event
if (event.article_ids) { if (event.match) {
let source = '/' + this.lang + '/w/' + event.match let self = this
this.$router.push(source) oda_api.get('articles?', {params: {lord: event.match, dict: this.lang}}).then((response) => {
let unwrapped = [] event.article_ids = response.data
for (const d in event.article_ids) { let source = '/' + this.lang + '/w/' + event.match
if (d == this.lang || this.lang == "bob,nob") { this.$router.push(source)
event.article_ids[d].forEach(i => unwrapped.push({ let unwrapped = []
for (const d in event.article_ids) {
event.article_ids[d].forEach(i => unwrapped.push({
dictionary: d, dictionary: d,
id: i id: i
})) }))
} }
}
let self = this let self = this
Promise.all(unwrapped.map((article) => { Promise.all(unwrapped.map((article) => {
return axios.get(`${oda_dev}/${article.dictionary}/article/${article.id}.json`) return axios.get(`${oda_dev}/${article.dictionary}/article/${article.id}.json`)
...@@ -274,7 +275,7 @@ export default { ...@@ -274,7 +275,7 @@ export default {
error: self.error error: self.error
}, '') }, '')
}) })
} else { })} else {
this.waiting_for_articles = true this.waiting_for_articles = true
this.article = null this.article = null
this.$router.push(`/${this.lang}/search/${event.q}`) this.$router.push(`/${this.lang}/search/${event.q}`)
......
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