add CardList cards & add temp ordered text by authors getter

This commit is contained in:
axolotle
2021-03-15 10:05:27 +01:00
parent 9473e94b16
commit 5735b330be
2 changed files with 61 additions and 2 deletions
+17
View File
@@ -58,6 +58,23 @@ export default {
value: id,
text: `(${id}) ${title}`
}))
},
orderedParents: state => {
// FIXME duplicates references if multiple authors ?
if (!state.textsDepart) return undefined
return state.textsDepart.sort((a, b) => {
if (!b.authors) return -1
if (!a.authors) return +1
if (a.authors[0].name < b.authors[0].name) return -1
if (a.authors[0].name > b.authors[0].name) return 1
return 0
}).reduce((dict, text) => {
const firstChar = text.authors ? text.authors[0].name[0] : '&'
if (!(firstChar in dict)) dict[firstChar] = []
dict[firstChar].push(text)
return dict
}, {})
}
}
}