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

re meta#300 navigasjon tilbake til søkeresultater for mobil

parent a95c495f
No related branches found
No related tags found
No related merge requests found
...@@ -60,17 +60,11 @@ export default { ...@@ -60,17 +60,11 @@ export default {
props: { props: {
article: Object article: Object
}, },
data: function() {
return {
source: null
}
},
computed: { computed: {
link_to_self: function() { link_to_self: function() {
return { return {
ref: '/' + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma), ref: '/' + this.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma),
article: this.article, article: this.article
source: this.source
} }
}, },
dictionary: function() { dictionary: function() {
...@@ -96,10 +90,6 @@ export default { ...@@ -96,10 +90,6 @@ export default {
details_click: function(item) { details_click: function(item) {
this.$emit('details-click', item) this.$emit('details-click', item)
} }
},
created: function() {
// make non reactive
this.source = this.$route.path
} }
} }
</script> </script>
......
...@@ -39,8 +39,13 @@ ...@@ -39,8 +39,13 @@
:lang="lang" :lang="lang"
@article-click="article_link_click" @article-click="article_link_click"
@details-click="details_click" @details-click="details_click"
v-if="search_results.length && ! waiting" /> v-if="search_results.length && ! waiting && ! article" />
<div id="single_article_container" v-if="article"> <div id="single_article_container" v-if="article">
<div class="return_to_results" v-if="search_results">
<router-link :to="article.source" @click.native="return_to_results()">
🡠 Tilbake til søkeresultater
</router-link>
</div>
<Article :key="article_key" :article="article" @article-click="article_link_click" /> <Article :key="article_key" :article="article" @article-click="article_link_click" />
</div> </div>
<div class="welcome" v-if="! (article || error || search_results.length || waiting)"> <div class="welcome" v-if="! (article || error || search_results.length || waiting)">
...@@ -179,8 +184,9 @@ export default { ...@@ -179,8 +184,9 @@ export default {
methods: { methods: {
select_result: function(event) { select_result: function(event) {
if(event.articles){ if(event.articles){
this.$router.push('/' + this.lang + '/w/' + event.word) let source = '/' + this.lang + '/w/' + event.word
this.search_results = event.articles this.$router.push(source)
this.search_results = event.articles.map(a => Object.assign(a, {source: source}))
this.article = null this.article = null
this.error = null this.error = null
history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang, error: this.error}, '') history.replaceState({article: this.article, search_results: this.search_results, lang: this.lang, error: this.error}, '')
...@@ -204,9 +210,11 @@ export default { ...@@ -204,9 +210,11 @@ export default {
} }
}, },
details_click: function(item) { details_click: function(item) {
this.article = Object.assign(item.article, {source: item.source}) this.article = item.article
this.search_results = []
history.replaceState({article: this.article, search_results: [], lang: this.lang, error: null}, '') history.replaceState({article: this.article, search_results: [], lang: this.lang, error: null}, '')
},
return_to_results: function() {
this.article = null
} }
}, },
mounted: function(){ mounted: function(){
......
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
this.$emit('article-click', item) this.$emit('article-click', item)
}, },
details_click: function(item) { details_click: function(item) {
this.$emit('details-click', Object.assign(item, {results: this.hits})) this.$emit('details-click', item)
} }
}, },
components: { components: {
......
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