1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-23 11:43:48 +00:00

sort results

This commit is contained in:
Kyle Spearrin
2018-05-02 17:00:31 -04:00
parent c80fa93515
commit 3981cb95fc
3 changed files with 19 additions and 1 deletions

2
jslib

Submodule jslib updated: c29b53cdd6...b5db9edc3f

View File

@@ -7,6 +7,7 @@ import { GSuiteDirectoryService } from '../../services/gsuite-directory.service'
import { LdapDirectoryService } from '../../services/ldap-directory.service'; import { LdapDirectoryService } from '../../services/ldap-directory.service';
import { SyncService } from '../../services/sync.service'; import { SyncService } from '../../services/sync.service';
import { Entry } from '../../models/entry';
import { GroupEntry } from '../../models/groupEntry'; import { GroupEntry } from '../../models/groupEntry';
import { UserEntry } from '../../models/userEntry'; import { UserEntry } from '../../models/userEntry';
@@ -49,6 +50,7 @@ export class DashboardComponent {
const userMap = new Map<string, UserEntry>(); const userMap = new Map<string, UserEntry>();
if (this.simUsers != null) { if (this.simUsers != null) {
this.sort(this.simUsers);
this.simUsers.forEach((u) => { this.simUsers.forEach((u) => {
userMap.set(u.externalId, u); userMap.set(u.externalId, u);
if (u.deleted) { if (u.deleted) {
@@ -62,6 +64,7 @@ export class DashboardComponent {
} }
if (userMap.size > 0 && this.simGroups != null) { if (userMap.size > 0 && this.simGroups != null) {
this.sort(this.simGroups);
this.simGroups.forEach((g) => { this.simGroups.forEach((g) => {
if (g.userMemberExternalIds == null) { if (g.userMemberExternalIds == null) {
return; return;
@@ -75,9 +78,20 @@ export class DashboardComponent {
(g as any).users.push(userMap.get(uid)); (g as any).users.push(userMap.get(uid));
} }
}); });
if ((g as any).users != null) {
this.sort((g as any).users);
}
}); });
} }
resolve(); resolve();
}); });
} }
private sort(arr: Entry[]) {
arr.sort((a, b) => {
return this.i18nService.collator ? this.i18nService.collator.compare(a.displayName, b.displayName) :
a.displayName.localeCompare(b.displayName);
});
}
} }

View File

@@ -1,4 +1,8 @@
export abstract class Entry { export abstract class Entry {
referenceId: string; referenceId: string;
externalId: string; externalId: string;
get displayName(): string {
return this.referenceId;
}
} }