fix orderedTextDepart getter

This commit is contained in:
axolotle
2021-07-01 16:01:05 +02:00
parent 0d2d870381
commit ff85771c68
+8 -8
View File
@@ -15,7 +15,7 @@ export default {
state: { state: {
trees: {}, trees: {},
randomNodes: undefined, randomNodes: undefined,
nodebook: undefined, nodebook: [],
// LibraryOptions options // LibraryOptions options
tagsOptions: [], tagsOptions: [],
@@ -219,20 +219,20 @@ export default {
nodesDepartsOptions: (state, getters, rootState) => { nodesDepartsOptions: (state, getters, rootState) => {
const departIds = rootState.ids.depart const departIds = rootState.ids.depart
if (departIds === undefined || rootState.nodes[departIds[0]] === undefined) return if (departIds === undefined) return
return departIds.map(id => { const nodes = departIds.map(id => rootState.nodes[id])
const text = rootState.nodes[id] if (nodes.some(node => node === undefined)) return
const firstAuthor = text.authors !== null ? text.authors[0].name : 'Pad de noms' return nodes.map(node => {
const firstAuthor = node.authors !== null ? node.authors[0].name : 'Pad de noms'
return { return {
text: `${firstAuthor}, ${text.title} (${id})`, text: `${firstAuthor}, ${node.title} (${node.id})`,
value: id value: node.id
} }
}) })
}, },
// Library // Library
nodebook: (state, getters, rootState) => { nodebook: (state, getters, rootState) => {
if (!state.nodebook) return []
return state.nodebook.map(([parentId, ...childrenIds]) => { return state.nodebook.map(([parentId, ...childrenIds]) => {
return { return {
parent: rootState.nodes[parentId], parent: rootState.nodes[parentId],