From 839f9090bb8738de870ada0bce988e597643301c Mon Sep 17 00:00:00 2001 From: Matilde Park Date: Tue, 7 Apr 2020 17:35:02 -0400 Subject: [PATCH] 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. --- pkg/interface/chat/src/js/lib/util.js | 12 ++++++------ pkg/interface/link/src/js/lib/util.js | 12 ++++++------ pkg/interface/publish/src/js/lib/util.js | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/interface/chat/src/js/lib/util.js b/pkg/interface/chat/src/js/lib/util.js index 88bbda6fad..db5a4ce461 100644 --- a/pkg/interface/chat/src/js/lib/util.js +++ b/pkg/interface/chat/src/js/lib/util.js @@ -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()); diff --git a/pkg/interface/link/src/js/lib/util.js b/pkg/interface/link/src/js/lib/util.js index 5870dcac3a..8c83886b77 100644 --- a/pkg/interface/link/src/js/lib/util.js +++ b/pkg/interface/link/src/js/lib/util.js @@ -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()); diff --git a/pkg/interface/publish/src/js/lib/util.js b/pkg/interface/publish/src/js/lib/util.js index 7407d895f8..fe4b3ad61f 100644 --- a/pkg/interface/publish/src/js/lib/util.js +++ b/pkg/interface/publish/src/js/lib/util.js @@ -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());