Skip to content
Snippets Groups Projects
Commit b8ce2cd3 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

tospråklige søk virker, men "alle resultater" må splittes i to deler

parent 163d8920
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ export default { ...@@ -95,7 +95,7 @@ export default {
self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}}
axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q + ' ' + event.q + '*&sort=_score') axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q + ' ' + event.q + '*&sort=_score')
.then(function(response){ .then(function(response){
self.$router.push('/' + self.lang + '/search?q=' + event.q) self.$router.push('/' + `/search?q=${event.q}&lang=${self.lang}`)
self.search_results = response.data.hits.hits self.search_results = response.data.hits.hits
self.waiting = false self.waiting = false
history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '') history.replaceState({article: self.article, search_results: self.search_results, lang: self.lang}, '')
......
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
}, },
computed: { computed: {
previewHeader: function(){ previewHeader: function(){
return this.searchHit.text || return this.searchHit.text && this.searchHit.text + " (" + (this.searchHit._index == "nob" ? "bokmål" : "nynorsk") + ")" ||
(this.searchHit._source && this.searchHit._source.lemmas.map(l => `<span class="homograph">${l.hgno ? String.fromCharCode(0x215f + l.hgno) + ' ' : ''}</span>${l.lemma}`) || []).join(',') || (this.searchHit._source && this.searchHit._source.lemmas.map(l => `<span class="homograph">${l.hgno ? String.fromCharCode(0x215f + l.hgno) + ' ' : ''}</span>${l.lemma}`) || []).join(',') ||
"Alle søkeresultater..." "Alle søkeresultater..."
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<section> <section>
<h2 v-if="hits.length">Søkeresultater</h2> <h2 v-if="hits.length">Søkeresultater</h2>
<ul class="hits"> <ul class="hits">
<Preview v-for="(result, index) in hits" :key="index" :searchHit="result" @click.native="article_link_click(result._source)"> <Preview v-for="(result, index) in hits" :key="index" :searchHit="result" @click.native="article_link_click(result)">
</Preview> </Preview>
</ul> </ul>
</section> </section>
...@@ -32,9 +32,9 @@ export default { ...@@ -32,9 +32,9 @@ export default {
} }
}, },
methods: { methods: {
article_link_click: function(article) { article_link_click: function(result) {
this.$router.push('' + article.article_id) this.$router.push('/' + result._index + '/' + result._id)
this.$emit('search-hit-click', article) this.$emit('search-hit-click', result._source)
} }
}, },
components: { components: {
......
...@@ -20,7 +20,7 @@ const router = new VueRouter({ ...@@ -20,7 +20,7 @@ const router = new VueRouter({
props: true }, // Pass route.params to props props: true }, // Pass route.params to props
{ {
name: 'search', name: 'search',
path: '/:lang/search', path: '/search',
component: App, component: App,
props: true} props: true}
] ]
......
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