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

Add article source if needed

parent 4c5bf2b7
No related branches found
No related tags found
No related merge requests found
...@@ -97,7 +97,7 @@ function navigate_to_article(self, source) { ...@@ -97,7 +97,7 @@ function navigate_to_article(self, source) {
} }
axios.get(oda_dev + '/' + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config) axios.get(oda_dev + '/' + self.$route.params.lang + '/article/' + self.$route.params.id + ".json", config)
.then(function(response){ .then(function(response){
self.article = Object.assign(response.data, {'dictionary': self.$route.params.lang, source: source, results: self.search_results}) self.article = Object.assign(response.data, {'dictionary': self.$route.params.lang, results: self.search_results})
self.search_results = [] self.search_results = []
self.error = null self.error = null
}) })
...@@ -145,8 +145,7 @@ function navigate_to_search(self, query) { ...@@ -145,8 +145,7 @@ function navigate_to_search(self, query) {
function navigate_to_word(self, word) { function navigate_to_word(self, word) {
let event = self.event ? self.event : {q: word, let event = self.event ? self.event : {q: word,
match: word, match: word}
source: self.$route.path}
// Get article IDs // Get article IDs
...@@ -168,7 +167,6 @@ function navigate_to_word(self, word) { ...@@ -168,7 +167,6 @@ function navigate_to_word(self, word) {
.then((response) => { .then((response) => {
self.search_results = response.map((element, index) => { self.search_results = response.map((element, index) => {
return Object.assign(element.data, { return Object.assign(element.data, {
source: event.source,
match: event.match, match: event.match,
dictionary: unwrapped[index].dictionary dictionary: unwrapped[index].dictionary
}) })
...@@ -240,15 +238,17 @@ export default { ...@@ -240,15 +238,17 @@ export default {
select_result: function (event) { select_result: function (event) {
this.event = event this.event = event
if (event.match) { if (event.match) {
event.source = '/' + this.lang + '/w/' + event.match let route = `/${this.lang}/search/${event.match}`
this.$router.push(event.source) this.$router.push(route)
navigate_to_word(this) navigate_to_word(this)
} 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}`)
navigate_to_search(this, event.q)
event.match = '<fritekstsøk>' event.match = '<fritekstsøk>'
let route = `/${this.lang}/search/${event.q}`
this.$router.push(route)
navigate_to_search(this, event.q)
} }
// Tracking // Tracking
this.$plausible.trackEvent(event.update_lang ? "language" : 'dropdown selection', { this.$plausible.trackEvent(event.update_lang ? "language" : 'dropdown selection', {
...@@ -278,6 +278,7 @@ export default { ...@@ -278,6 +278,7 @@ export default {
} }
}, },
details_click: function(item) { details_click: function(item) {
item.article.source = this.$route.path
this.article = item.article this.article = item.article
history.replaceState({article: this.article, search_results: [], lang: this.lang, error: null}, '') history.replaceState({article: this.article, search_results: [], lang: this.lang, error: null}, '')
}, },
...@@ -305,7 +306,7 @@ export default { ...@@ -305,7 +306,7 @@ export default {
navigate_to_word(self, self.$route.params.word) navigate_to_word(self, self.$route.params.word)
} }
else if(self.$route.name == 'lookup'){ else if(self.$route.name == 'lookup'){
navigate_to_article(self, self.$route.params.id) navigate_to_article(self, self.$route.path)
} }
else if (self.$route.name == 'search') { else if (self.$route.name == 'search') {
self.lang = self.$route.params.lang self.lang = self.$route.params.lang
......
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