From f038d662c52c2d98f2e7d623270357597fa1b6d0 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Fri, 29 Oct 2021 14:52:19 +0300 Subject: [PATCH] Homepage - sort stakeholders public first, restricted after and then alphabetically --- src/app/home/home.component.ts | 25 ++++++++++++++++++++++++- src/app/openaireLibrary | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 25807d3..312d561 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -247,7 +247,30 @@ export class HomeComponent { if (!stakeholders || stakeholders.length == 0) { this.status = this.errorCodes.NONE; } else { - this.stakeholders = stakeholders; + // compare function for alphabetical order based on the 'name' property + function compare (a, b) { + if(a.name < b.name) { + return -1; + } + if(a.name > b.name) { + return 1; + } + return 0; + } + let publicStakeholders = []; + let restrictedStakeholders = []; + stakeholders.forEach(stakeholder => { + if(stakeholder.visibility == "PUBLIC") { + publicStakeholders.push(stakeholder); + } else { + restrictedStakeholders.push(stakeholder); + } + }); + // actual sorting of the arrays + publicStakeholders.sort(compare); + restrictedStakeholders.sort(compare); + // joining the two arrays again + this.stakeholders = publicStakeholders.concat(restrictedStakeholders); } this.loading = false; }, diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 389cd74..b2ad62b 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 389cd74ba564e77f6ac85fa890259ba1c880c372 +Subproject commit b2ad62b6ad0e7c36e6be4b7a3de39631a81fd9bc