various: alphabetise associations accesses obj

Previously we were checking for a title for the association by accessing
a non-existent property of the key we were using to iterate through
the object. What we want to do is access the iterated object to find
that title, and so this commit does that.
This commit is contained in:
Matilde Park 2020-04-07 17:35:02 -04:00
parent 2bfcf20bf7
commit 839f9090bb
3 changed files with 18 additions and 18 deletions

View File

@ -138,14 +138,14 @@ export function alphabetiseAssociations(associations) {
Object.keys(associations).sort((a, b) => {
let aName = a.substr(1);
let bName = b.substr(1);
if (a.metadata && a.metadata.title) {
aName = a.metadata.title !== ""
? a.metadata.title
if (associations[a].metadata && associations[a].metadata.title) {
aName = associations[a].metadata.title !== ""
? associations[a].metadata.title
: a.substr(1);
}
if (b.metadata && b.metadata.title) {
bName = b.metadata.title !== ""
? b.metadata.title
if (associations[b].metadata && associations[b].metadata.title) {
bName = associations[b].metadata.title !== ""
? associations[b].metadata.title
: b.substr(1);
}
return aName.toLowerCase().localeCompare(bName.toLowerCase());

View File

@ -171,14 +171,14 @@ export function alphabetiseAssociations(associations) {
Object.keys(associations).sort((a, b) => {
let aName = a.substr(1);
let bName = b.substr(1);
if (a.metadata && a.metadata.title) {
aName = a.metadata.title !== ""
? a.metadata.title
if (associations[a].metadata && associations[a].metadata.title) {
aName = associations[a].metadata.title !== ""
? associations[a].metadata.title
: a.substr(1);
}
if (b.metadata && b.metadata.title) {
bName = b.metadata.title !== ""
? b.metadata.title
if (associations[b].metadata && associations[b].metadata.title) {
bName = associations[b].metadata.title !== ""
? associations[b].metadata.title
: b.substr(1);
}
return aName.toLowerCase().localeCompare(bName.toLowerCase());

View File

@ -97,14 +97,14 @@ export function alphabetiseAssociations(associations) {
Object.keys(associations).sort((a, b) => {
let aName = a.substr(1);
let bName = b.substr(1);
if (a.metadata && a.metadata.title) {
aName = a.metadata.title !== ""
? a.metadata.title
if (associations[a].metadata && associations[a].metadata.title) {
aName = associations[a].metadata.title !== ""
? associations[a].metadata.title
: a.substr(1);
}
if (b.metadata && b.metadata.title) {
bName = b.metadata.title !== ""
? b.metadata.title
if (associations[b].metadata && associations[b].metadata.title) {
bName = associations[b].metadata.title !== ""
? associations[b].metadata.title
: b.substr(1);
}
return aName.toLowerCase().localeCompare(bName.toLowerCase());