renamed text_en_rebonds, text_de_depart et text_produits to siblings, parents and children
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
fragment TextTreeFields on TextInterface {
|
||||
id
|
||||
title
|
||||
familles {
|
||||
families: familles {
|
||||
id
|
||||
name
|
||||
}
|
||||
__typename
|
||||
type: __typename
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
fragment TextrefTreeFields on Textref {
|
||||
...TextTreeFields
|
||||
text_produits{
|
||||
children: text_produits {
|
||||
...TextTreeFields
|
||||
text_de_depart {
|
||||
parents: text_de_depart {
|
||||
...TextTreeFields
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ query TextRef ($id: Int!) {
|
||||
...TextCardFields
|
||||
|
||||
... on Textref {
|
||||
prods: text_produits {
|
||||
children: text_produits {
|
||||
id
|
||||
}
|
||||
bounces: text_en_rebond {
|
||||
siblings: text_en_rebond {
|
||||
id
|
||||
title
|
||||
authors: auteurs {
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
query TextdepartRecursive($id: Int!) {
|
||||
textref(id: $id) {
|
||||
...TextrefTreeFields
|
||||
text_en_rebond {
|
||||
siblings: text_en_rebond {
|
||||
...TextrefTreeFields
|
||||
text_en_rebond {
|
||||
siblings: text_en_rebond {
|
||||
...TextrefTreeFields
|
||||
text_en_rebond {
|
||||
siblings: text_en_rebond {
|
||||
...TextrefTreeFields
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
<b-nav class="ml-auto flex-nowrap">
|
||||
<b-nav-item
|
||||
v-for="prod in text.prods" :key="prod.id"
|
||||
@click="$emit('open', prod.id)"
|
||||
v-for="child in text.children" :key="child.id"
|
||||
@click="$emit('open', child.id)"
|
||||
>
|
||||
{{ prod.id }}
|
||||
{{ child.id }}
|
||||
</b-nav-item>
|
||||
|
||||
<b-nav-item @click="$emit('close')">
|
||||
@@ -39,20 +39,20 @@
|
||||
</b-badge>
|
||||
|
||||
<b-button
|
||||
v-if="text.bounces"
|
||||
:id="'bounces-' + text.id"
|
||||
v-if="text.siblings"
|
||||
:id="'siblings-' + text.id"
|
||||
>
|
||||
{{ $t('bounce_texts') }}
|
||||
{{ $t('siblings') }}
|
||||
</b-button>
|
||||
<b-popover
|
||||
v-if="text.bounces"
|
||||
:target="'bounces-' + text.id" triggers="click" placement="top"
|
||||
v-if="text.siblings"
|
||||
: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>
|
||||
<span>{{ bounce.authors | list }},</span>
|
||||
<span>{{ bounce.title }},</span>
|
||||
<span>{{ bounce.edition }}</span>
|
||||
<span>{{ sibling.authors | list }},</span>
|
||||
<span>{{ sibling.title }},</span>
|
||||
<span>{{ sibling.edition }}</span>
|
||||
</h6>
|
||||
</div>
|
||||
</b-popover>
|
||||
|
||||
Vendored
+5
-5
@@ -8,7 +8,7 @@ function flatten (arr, accumulator = []) {
|
||||
}
|
||||
|
||||
function getLinked (text) {
|
||||
const types = ['text_en_rebond', 'text_produits', 'text_de_depart']
|
||||
const types = ['siblings', 'children', 'parents']
|
||||
return types.reduce((acc, type) => {
|
||||
// Handle `null` and `undefined`
|
||||
return text[type] ? [...acc, ...text[type]] : acc
|
||||
@@ -29,8 +29,8 @@ export function toSingleManyData (rawData) {
|
||||
const links = h.links()
|
||||
nodes.forEach(node => {
|
||||
Object.assign(node.data, {
|
||||
type: node.data.__typename.toLowerCase(),
|
||||
class: 'family-' + node.data.familles[0].id
|
||||
type: node.data.type.toLowerCase(),
|
||||
class: 'family-' + node.data.families[0].id
|
||||
})
|
||||
})
|
||||
return { nodes, links }
|
||||
@@ -73,8 +73,8 @@ export function toManyManyData (rawData) {
|
||||
id: data.id,
|
||||
data: {
|
||||
...data,
|
||||
type: data.__typename.toLowerCase(),
|
||||
class: 'family-' + data.familles[0].id
|
||||
type: data.type.toLowerCase(),
|
||||
class: 'family-' + data.families[0].id
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
"gallery": "Créations numériques",
|
||||
"blog": "Blog"
|
||||
},
|
||||
"bounce_texts": "Textes rebonds"
|
||||
"siblings": "Textes rebonds"
|
||||
}
|
||||
|
||||
+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])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
function formatQuery (str, depth) {
|
||||
if (depth > 0) {
|
||||
return formatQuery(
|
||||
str.replace('INPUT', '...TextrefTreeFields\ntext_en_rebond {\nINPUT\n}'),
|
||||
str.replace('INPUT', '...TextrefTreeFields\nsiblings: text_en_rebond {\nINPUT\n}'),
|
||||
--depth
|
||||
)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user