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

complete collapse settings

parent 35dedc2d
No related branches found
No related tags found
No related merge requests found
<template> <template>
<article v-bind:class="{'v-sheet v-card rounded-xl': !articleLookup, dictionary, 'collapsable': collapsable, 'collapsed': collapsed}" v-if="article"> <article v-bind:class="{'v-sheet v-card rounded-xl': !articleLookup, dictionary, 'collapsable': collapsable, 'collapsed': collapsed}" v-if="article">
<Header :title_id="title_id" :lemmas="article.lemmas" :dictionary="dictionary" :article_id="article.article_id" /> <Header :title_id="title_id" :lemmas="article.lemmas" :dictionary="dictionary" :article_id="article.article_id" @toggle-collapse = "toggle_collapse"/>
<InflectionButton :lemmas="article.lemmas" :dictionary="dictionary" :article_id="article.article_id"/> <InflectionButton :lemmas="article.lemmas" :dictionary="dictionary" :article_id="article.article_id"/>
<div class="article_content" :class="$vuetify.breakpoint.name" v-if="!collapsed"> <div class="article_content" :class="$vuetify.breakpoint.name" v-if="!collapsed">
...@@ -81,23 +81,48 @@ export default { ...@@ -81,23 +81,48 @@ export default {
}, },
data: function() { data: function() {
return { return {
collapsed: this.$parent.$options.name == 'SearchResults' && (this.$parent.results_bm.length + this.$parent.results_nn.length > 2) is_collapsed: true
} }
}, },
computed: {
computed: { collapsable: function() {
snippet: function() { if (this.$parent.$options.name != 'SearchResults') {
if (this.article.body.definitions) { this.is_collapsed = false
return this.parse_definitions(this.article.body.definitions) return false
}
let collapsable = this.$store.state.collapseArticles
if (collapsable == 'never') {
this.is_collapsed = false
}
if (collapsable == 'always') {
this.is_collapsed = true
}
if (collapsable == 'auto') {
this.is_collapsed = this.$parent.$options.name == 'SearchResults' && (this.$parent.results_bm.length + this.$parent.results_nn.length > 2)
} }
return null
return this.$store.state.collapseArticles == 'always' || this.is_collapsed//getters.collapsable(this.$parent.$options.name, this.$parent.results_bm.length + this.$parent.results_nn.length)
}, },
collapsable: function() { collapsed: {
return this.$parent.$options.name == 'SearchResults' && (this.$parent.results_bm.length + this.$parent.results_nn.length > 2) get() {
if (this.$parent.$options.name != 'SearchResults') {
return false
}
if (!this.collapsable) {
this.is_collapsed = false
}
return this.is_collapsed
},
set(value) {
this.is_collapsed = value
}
},
snippet: function() {
if (this.collapsable && this.article.body.definitions) {
return this.parse_definitions(this.article.body.definitions)
}
return null
}, },
link_to_self: function() { link_to_self: function() {
return { return {
...@@ -190,14 +215,11 @@ export default { ...@@ -190,14 +215,11 @@ export default {
return definitions return definitions
}, },
expand: function() { toggle_collapse: function() {
if (this.collapsed) { console.log("toggle", this.collapsed)
this.collapsed = false this.collapsed = !this.collapsed
}
},
collapse: function() {
this.collapsed = true
}, },
article_link_click: function(item) { article_link_click: function(item) {
this.$emit('article-click', item) this.$emit('article-click', item)
}, },
......
...@@ -58,13 +58,13 @@ ...@@ -58,13 +58,13 @@
<v-btn class="expand_icon" v-if="$parent.collapsed" <v-btn class="expand_icon" v-if="$parent.collapsed"
text text
small small
@click="$parent.collapsed=false"> @click="$emit('toggle-collapse')">
Vis artikkel Vis artikkel
<v-icon small right>expand_more</v-icon></v-btn> <v-icon small right>expand_more</v-icon></v-btn>
<v-btn class="expand_icon" v-else <v-btn class="expand_icon" v-else
text text
small small
@click="$parent.collapsed=true"> @click="$emit('toggle-collapse')">
<v-icon small>expand_less</v-icon></v-btn> <v-icon small>expand_less</v-icon></v-btn>
</span> </span>
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
</v-list-item> </v-list-item>
<v-list-item> <v-list-item>
<v-radio-group mandatory two-line v-model="updateLocale" label="Velg når artiklene i søkeresultatene skal forkortes"> <v-radio-group mandatory two-line v-model="updateCollapse" label="Velg om søkeresultatene skal inneholde utdrag eller fullstendige artikler.">
<v-radio value="auto" label="Forkort i søk med to eller flere resultater"></v-radio> <v-radio value="auto" label="Automatisk (hvis mer enn 2 resultater)"></v-radio>
<v-radio value="always" label="Vis bare forkortede artikler"></v-radio> <v-radio value="always" label="Vis bare utdrag"></v-radio>
<v-radio value="never" label="Vis bare fullstendige artikler"></v-radio> <v-radio value="never" label="Vis bare fullstendige artikler"></v-radio>
</v-radio-group> </v-radio-group>
</v-list-item> </v-list-item>
...@@ -42,11 +42,12 @@ export default { ...@@ -42,11 +42,12 @@ export default {
set () { this.$store.commit("toggle", "showInflectionNo") set () { this.$store.commit("toggle", "showInflectionNo")
} }
}, },
toggleCollapse: { updateCollapse: {
get () { return this.$store.state.collapseArticles}, get () { return this.$store.state.collapseArticles},
set () { this.$store.commit("toggle", "collapseArticles") set(value) {
} this.$store.commit("setCollapse", value)
} }
},
}, },
} }
</script> </script>
...@@ -102,7 +102,7 @@ const store = new Vuex.Store({ ...@@ -102,7 +102,7 @@ const store = new Vuex.Store({
state.showInflectionNo = localStorage.getItem('showInflectionNo') || false state.showInflectionNo = localStorage.getItem('showInflectionNo') || false
state.currentLocale = localStorage.getItem('currentLocale') state.currentLocale = localStorage.getItem('currentLocale')
state.defaultDict = localStorage.getItem('defaultDict') || 'bm,nn' state.defaultDict = localStorage.getItem('defaultDict') || 'bm,nn'
state.collapseArticles = localStorage.getItem('collapseArticles') || window.innerWidth < 700 state.collapseArticles = localStorage.getItem('collapseArticles') || 'auto'
state.noMouse = window.matchMedia('(hover: none)').matches state.noMouse = window.matchMedia('(hover: none)').matches
...@@ -118,6 +118,10 @@ const store = new Vuex.Store({ ...@@ -118,6 +118,10 @@ const store = new Vuex.Store({
payload.i18n.locale = payload.value payload.i18n.locale = payload.value
localStorage.setItem("currentLocale", payload.value); localStorage.setItem("currentLocale", payload.value);
}, },
setCollapse(state, value) {
localStorage.setItem("collapseArticles", value)
state.collapseArticles = value
},
toggle(state, setting) { toggle(state, setting) {
let value = !state[setting] let value = !state[setting]
state[setting] = value state[setting] = value
......
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