renamed text_en_rebonds, text_de_depart et text_produits to siblings, parents and children

This commit is contained in:
axolotle
2021-03-10 17:32:48 +01:00
parent 9ffc2bf167
commit 19f37aa23b
9 changed files with 45 additions and 45 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
fragment TextTreeFields on TextInterface { fragment TextTreeFields on TextInterface {
id id
title title
familles { families: familles {
id id
name name
} }
__typename type: __typename
} }
+2 -2
View File
@@ -2,9 +2,9 @@
fragment TextrefTreeFields on Textref { fragment TextrefTreeFields on Textref {
...TextTreeFields ...TextTreeFields
text_produits{ children: text_produits {
...TextTreeFields ...TextTreeFields
text_de_depart { parents: text_de_depart {
...TextTreeFields ...TextTreeFields
} }
} }
+2 -2
View File
@@ -5,10 +5,10 @@ query TextRef ($id: Int!) {
...TextCardFields ...TextCardFields
... on Textref { ... on Textref {
prods: text_produits { children: text_produits {
id id
} }
bounces: text_en_rebond { siblings: text_en_rebond {
id id
title title
authors: auteurs { authors: auteurs {
+3 -3
View File
@@ -3,11 +3,11 @@
query TextdepartRecursive($id: Int!) { query TextdepartRecursive($id: Int!) {
textref(id: $id) { textref(id: $id) {
...TextrefTreeFields ...TextrefTreeFields
text_en_rebond { siblings: text_en_rebond {
...TextrefTreeFields ...TextrefTreeFields
text_en_rebond { siblings: text_en_rebond {
...TextrefTreeFields ...TextrefTreeFields
text_en_rebond { siblings: text_en_rebond {
...TextrefTreeFields ...TextrefTreeFields
} }
} }
+12 -12
View File
@@ -16,10 +16,10 @@
<b-nav class="ml-auto flex-nowrap"> <b-nav class="ml-auto flex-nowrap">
<b-nav-item <b-nav-item
v-for="prod in text.prods" :key="prod.id" v-for="child in text.children" :key="child.id"
@click="$emit('open', prod.id)" @click="$emit('open', child.id)"
> >
{{ prod.id }} {{ child.id }}
</b-nav-item> </b-nav-item>
<b-nav-item @click="$emit('close')"> <b-nav-item @click="$emit('close')">
@@ -39,20 +39,20 @@
</b-badge> </b-badge>
<b-button <b-button
v-if="text.bounces" v-if="text.siblings"
:id="'bounces-' + text.id" :id="'siblings-' + text.id"
> >
{{ $t('bounce_texts') }} {{ $t('siblings') }}
</b-button> </b-button>
<b-popover <b-popover
v-if="text.bounces" v-if="text.siblings"
:target="'bounces-' + text.id" triggers="click" placement="top" :target="'siblings-' + text.id" triggers="click" placement="top"
> >
<div v-for="bounce in text.bounces" :key="bounce.id"> <div v-for="sibling in text.siblings" :key="sibling.id">
<h6> <h6>
<span>{{ bounce.authors | list }},</span> <span>{{ sibling.authors | list }},</span>
<span>{{ bounce.title }},</span> <span>{{ sibling.title }},</span>
<span>{{ bounce.edition }}</span> <span>{{ sibling.edition }}</span>
</h6> </h6>
</div> </div>
</b-popover> </b-popover>
+5 -5
View File
@@ -8,7 +8,7 @@ function flatten (arr, accumulator = []) {
} }
function getLinked (text) { function getLinked (text) {
const types = ['text_en_rebond', 'text_produits', 'text_de_depart'] const types = ['siblings', 'children', 'parents']
return types.reduce((acc, type) => { return types.reduce((acc, type) => {
// Handle `null` and `undefined` // Handle `null` and `undefined`
return text[type] ? [...acc, ...text[type]] : acc return text[type] ? [...acc, ...text[type]] : acc
@@ -29,8 +29,8 @@ export function toSingleManyData (rawData) {
const links = h.links() const links = h.links()
nodes.forEach(node => { nodes.forEach(node => {
Object.assign(node.data, { Object.assign(node.data, {
type: node.data.__typename.toLowerCase(), type: node.data.type.toLowerCase(),
class: 'family-' + node.data.familles[0].id class: 'family-' + node.data.families[0].id
}) })
}) })
return { nodes, links } return { nodes, links }
@@ -73,8 +73,8 @@ export function toManyManyData (rawData) {
id: data.id, id: data.id,
data: { data: {
...data, ...data,
type: data.__typename.toLowerCase(), type: data.type.toLowerCase(),
class: 'family-' + data.familles[0].id class: 'family-' + data.families[0].id
} }
} }
}) })
+1 -1
View File
@@ -9,5 +9,5 @@
"gallery": "Créations numériques", "gallery": "Créations numériques",
"blog": "Blog" "blog": "Blog"
}, },
"bounce_texts": "Textes rebonds" "siblings": "Textes rebonds"
} }
+17 -17
View File
@@ -4,13 +4,13 @@
<component :is="mode" /> <component :is="mode" />
<!-- FOREGROUND (texts) --> <!-- FOREGROUND (texts) -->
<section v-for="group in groups" :key="group.id" class="split-screen"> <section v-for="parent in parents" :key="parent.id" class="split-screen">
<text-card :id="group.id" @open="openText(group, $event)" @close="closeText(group)" /> <text-card :id="parent.id" @open="openText(parent, $event)" @close="closeText(parent)" />
<div> <div>
<text-card <text-card
v-for="id in group.prod" :key="id" v-for="id in parent.children" :key="id"
:id="id" :id="id"
@close="closeText(group, id)" @close="closeText(parent, id)"
/> />
</div> </div>
</section> </section>
@@ -38,36 +38,36 @@ export default {
}, },
computed: { computed: {
groups () { parents () {
return this.texts.map(text => { return this.texts.map(text => {
const [id, ...prod] = text const [id, ...children] = text
return { id, prod } return { id, children }
}) })
} }
}, },
methods: { methods: {
openText (group, id) { openText (parent, id) {
if (group.prod.includes(id)) return if (parent.children.includes(id)) return
group.prod.push(id) parent.children.push(id)
this.updateQuery(this.groups) this.updateQuery(this.parents)
}, },
closeText (group, id) { closeText (parent, id) {
if (!id) { if (!id) {
this.updateQuery(this.groups.filter(grp => grp !== group)) this.updateQuery(this.parents.filter(p => p !== parent))
} else { } else {
group.prod = group.prod.filter(id_ => id_ !== id) parent.children = parent.children.filter(id_ => id_ !== id)
this.updateQuery(this.groups) this.updateQuery(this.parents)
} }
}, },
updateQuery (groups) { updateQuery (parents) {
// Update the route's query (will not reload the page) and let vue determine what changed. // Update the route's query (will not reload the page) and let vue determine what changed.
this.$router.push({ this.$router.push({
query: { query: {
mode: this.mode, mode: this.mode,
texts: groups.map(grp => [grp.id, ...grp.prod]) texts: parents.map(parent => [parent.id, ...parent.children])
} }
}) })
} }
+1 -1
View File
@@ -39,7 +39,7 @@ export default {
function formatQuery (str, depth) { function formatQuery (str, depth) {
if (depth > 0) { if (depth > 0) {
return formatQuery( return formatQuery(
str.replace('INPUT', '...TextrefTreeFields\ntext_en_rebond {\nINPUT\n}'), str.replace('INPUT', '...TextrefTreeFields\nsiblings: text_en_rebond {\nINPUT\n}'),
--depth --depth
) )
} else { } else {