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

Implement article requests

parent 0c942fbf
No related branches found
No related tags found
No related merge requests found
......@@ -214,19 +214,31 @@ export default {
methods: {
select_result: function(event) {
this.event = event
if(event.articles){
if(event.article_ids){
let source = '/' + this.lang + '/w/' + event.match
this.$router.push(source)
/*
this.search_results = event.articles.map(a => Object.assign(a, {source: source}))
this.article = null
this.error = null
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(`${api_endpoint}/${article.dictionary}/article/${article.id}`)
})).then((response) => {
self.search_results = response.map((element, index) => {
return Object.assign(element.data, {source: source, match: event.match, dictionary: unwrapped[index].dictionary})
})
self.article = null
self.error = null
history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang, error: self.error}, '')
this.$plausible.trackEvent('dropdown selection', {props: {query: event.q, match: event.match}})
})
history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang, error: this.error}, '')
*/
this.waiting_for_articles = true
navigate_to_word(this, event.match)
this.$plausible.trackEvent('dropdown selection', {props: {query: event.q, match: event.match}})
}else{
this.waiting_for_articles = true
this.article = null
......
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