[AAE-3750] - add possibility to exclude user from selection on people… (#6277)

* [AAE-3750] - add possibility to exclude user from selection on people cloud component

* update docs

* PR changes
This commit is contained in:
Silviu Popa
2020-10-26 19:43:22 +02:00
committed by GitHub
parent faacac6c5f
commit 1f68bfebb2
3 changed files with 85 additions and 16 deletions

View File

@@ -92,6 +92,12 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
@Input()
preSelectUsers: IdentityUserModel[] = [];
/** Array of users to be excluded.
* Mandatory properties are: id, email, username
*/
@Input()
excludedUsers: IdentityUserModel[] = [];
/** FormControl to list of users */
@Input()
userChipsCtrl: FormControl = new FormControl({ value: '', disabled: false });
@@ -211,7 +217,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
this.searchLoading = false;
return users;
}),
filter(user => !this.isUserAlreadySelected(user)),
filter(user => !this.isUserAlreadySelected(user) && !this.isExcludedUser(user)),
mergeMap(user => {
if (this.appName) {
return this.checkUserHasAccess(user.id).pipe(
@@ -275,6 +281,13 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
return false;
}
private isExcludedUser(searchUser: IdentityUserModel): boolean {
if (this.excludedUsers?.length > 0) {
return !!this.excludedUsers.find(excludedUser => this.compare(excludedUser, searchUser));
}
return false;
}
private async loadPreSelectUsers(): Promise<void> {
this.selectedUsers = [];