Homepage - sort stakeholders public first, restricted after and then alphabetically
This commit is contained in:
parent
feea166388
commit
f038d662c5
|
@ -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;
|
||||
},
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 389cd74ba564e77f6ac85fa890259ba1c880c372
|
||||
Subproject commit b2ad62b6ad0e7c36e6be4b7a3de39631a81fd9bc
|
Loading…
Reference in New Issue