From 8f098e16318d2dce92defea8fd80de7a8cbca0bf Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Tue, 28 Sep 2021 09:50:45 +0200 Subject: [PATCH] Add article source if needed --- src/components/DictionaryView.vue | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue index 2ef5728..5a757e9 100644 --- a/src/components/DictionaryView.vue +++ b/src/components/DictionaryView.vue @@ -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) .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.error = null }) @@ -145,8 +145,7 @@ function navigate_to_search(self, query) { function navigate_to_word(self, word) { let event = self.event ? self.event : {q: word, - match: word, - source: self.$route.path} + match: word} // Get article IDs @@ -168,7 +167,6 @@ function navigate_to_word(self, word) { .then((response) => { self.search_results = response.map((element, index) => { return Object.assign(element.data, { - source: event.source, match: event.match, dictionary: unwrapped[index].dictionary }) @@ -240,15 +238,17 @@ export default { select_result: function (event) { this.event = event if (event.match) { - event.source = '/' + this.lang + '/w/' + event.match - this.$router.push(event.source) + let route = `/${this.lang}/search/${event.match}` + this.$router.push(route) navigate_to_word(this) } else { this.waiting_for_articles = true this.article = null - this.$router.push(`/${this.lang}/search/${event.q}`) - navigate_to_search(this, event.q) + event.match = '<fritekstsøk>' + let route = `/${this.lang}/search/${event.q}` + this.$router.push(route) + navigate_to_search(this, event.q) } // Tracking this.$plausible.trackEvent(event.update_lang ? "language" : 'dropdown selection', { @@ -278,6 +278,7 @@ export default { } }, details_click: function(item) { + item.article.source = this.$route.path this.article = item.article history.replaceState({article: this.article, search_results: [], lang: this.lang, error: null}, '') }, @@ -305,7 +306,7 @@ export default { navigate_to_word(self, self.$route.params.word) } 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') { self.lang = self.$route.params.lang -- GitLab