encode open expanded section of /tickets view in url
This commit is contained in:
parent
79cfbdbe2f
commit
41d983ccbb
1 changed files with 31 additions and 14 deletions
|
@ -47,7 +47,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import router from '../router';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CollapsableCards',
|
name: 'CollapsableCards',
|
||||||
|
@ -76,7 +75,15 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.collapsed = this.sections.map(() => true);
|
const query = this.$router.currentRoute.query.collapsed;
|
||||||
|
if (query !== null && query !== undefined) {
|
||||||
|
this.collapsed = this.unpackInt(parseInt(query), this.sections.length);
|
||||||
|
} else {
|
||||||
|
this.collapsed = this.sections.map(() => true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.$router.push({...this.$router.currentRoute, query: {...this.$router.currentRoute.query, layout}});
|
||||||
|
//this.collapsed = this.sections.map(() => true);
|
||||||
/*this.columns.map(e => ({
|
/*this.columns.map(e => ({
|
||||||
k: e,
|
k: e,
|
||||||
v: this.$store.getters.getFilters[e]
|
v: this.$store.getters.getFilters[e]
|
||||||
|
@ -85,21 +92,31 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
grouped_items() {
|
grouped_items() {
|
||||||
return this.sections.map(section => this.items.filter(item => item[this.keyName] === section.slug));
|
return this.sections.map(section => this.items.filter(item => item[this.keyName] === section.slug));
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggle(index) {
|
packInt(arr) {
|
||||||
this.collapsed[index] = !this.collapsed[index];
|
return arr.reduce((a, e, i) => a + (e ? 0 : 2 ** i), 0);
|
||||||
this.$forceUpdate();
|
},
|
||||||
|
unpackInt(n, l) {
|
||||||
|
return [...Array(l)].map((e, i) => (n & 2 ** i) === 0);
|
||||||
|
},
|
||||||
|
toggle(index) {
|
||||||
|
const collapsed = [...this.collapsed]
|
||||||
|
collapsed[index] = !collapsed[index];
|
||||||
|
this.collapsed = collapsed;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
collapsed: {
|
||||||
|
handler() {
|
||||||
|
const encoded = this.packInt(this.collapsed).toString()
|
||||||
|
if (this.$router.currentRoute.query.collapsed !== encoded)
|
||||||
|
this.$router.push({...this.$router.currentRoute, query: {...this.$router.currentRoute.query, collapsed: encoded}});
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
},
|
},
|
||||||
/*changeFilter(col, val) {
|
|
||||||
this.setFilter(col, val);
|
|
||||||
let newquery = Object.entries({
|
|
||||||
...this.$store.getters.getFilters,
|
|
||||||
[col]: val
|
|
||||||
}).reduce((a, [k, v]) => (v ? {...a, [k]: v} : a), {});
|
|
||||||
router.push({query: newquery});
|
|
||||||
},*/
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue