renamed text_en_rebonds, text_de_depart et text_produits to siblings, parents and children
This commit is contained in:
+17
-17
@@ -4,13 +4,13 @@
|
||||
<component :is="mode" />
|
||||
|
||||
<!-- FOREGROUND (texts) -->
|
||||
<section v-for="group in groups" :key="group.id" class="split-screen">
|
||||
<text-card :id="group.id" @open="openText(group, $event)" @close="closeText(group)" />
|
||||
<section v-for="parent in parents" :key="parent.id" class="split-screen">
|
||||
<text-card :id="parent.id" @open="openText(parent, $event)" @close="closeText(parent)" />
|
||||
<div>
|
||||
<text-card
|
||||
v-for="id in group.prod" :key="id"
|
||||
v-for="id in parent.children" :key="id"
|
||||
:id="id"
|
||||
@close="closeText(group, id)"
|
||||
@close="closeText(parent, id)"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
@@ -38,36 +38,36 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
groups () {
|
||||
parents () {
|
||||
return this.texts.map(text => {
|
||||
const [id, ...prod] = text
|
||||
return { id, prod }
|
||||
const [id, ...children] = text
|
||||
return { id, children }
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
openText (group, id) {
|
||||
if (group.prod.includes(id)) return
|
||||
group.prod.push(id)
|
||||
this.updateQuery(this.groups)
|
||||
openText (parent, id) {
|
||||
if (parent.children.includes(id)) return
|
||||
parent.children.push(id)
|
||||
this.updateQuery(this.parents)
|
||||
},
|
||||
|
||||
closeText (group, id) {
|
||||
closeText (parent, id) {
|
||||
if (!id) {
|
||||
this.updateQuery(this.groups.filter(grp => grp !== group))
|
||||
this.updateQuery(this.parents.filter(p => p !== parent))
|
||||
} else {
|
||||
group.prod = group.prod.filter(id_ => id_ !== id)
|
||||
this.updateQuery(this.groups)
|
||||
parent.children = parent.children.filter(id_ => id_ !== id)
|
||||
this.updateQuery(this.parents)
|
||||
}
|
||||
},
|
||||
|
||||
updateQuery (groups) {
|
||||
updateQuery (parents) {
|
||||
// Update the route's query (will not reload the page) and let vue determine what changed.
|
||||
this.$router.push({
|
||||
query: {
|
||||
mode: this.mode,
|
||||
texts: groups.map(grp => [grp.id, ...grp.prod])
|
||||
texts: parents.map(parent => [parent.id, ...parent.children])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user