mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4274] - Fix users filtering on single selection mode (#4476)
* [ADF-4274] - fix users filtering on single selection mode * [ADF-4274] - add unit test
This commit is contained in:
committed by
Eugenio Romano
parent
f422fa30d2
commit
d8321b977a
@@ -398,4 +398,23 @@ describe('PeopleCloudComponent', () => {
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not filter the preselect user in single selection mode', async ((done) => {
|
||||
spyOn(identityService, 'findUserByUsername').and.returnValue(Promise.resolve(mockUsers));
|
||||
component.mode = 'single';
|
||||
component.validate = true;
|
||||
component.preSelectUsers = <any> [{ username: mockUsers[1].username }];
|
||||
fixture.detectChanges();
|
||||
let inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
inputHTMLElement.focus();
|
||||
inputHTMLElement.dispatchEvent(new Event('input'));
|
||||
inputHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
inputHTMLElement.dispatchEvent(new Event('keydown'));
|
||||
inputHTMLElement.value = mockUsers[1].username;
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
fixture.detectChanges();
|
||||
expect(fixture.debugElement.queryAll(By.css('mat-option')).length).toBe(3);
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@@ -278,7 +278,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges {
|
||||
}
|
||||
|
||||
private isUserAlreadySelected(user: IdentityUserModel): boolean {
|
||||
if (this.preSelectUsers && this.preSelectUsers.length > 0) {
|
||||
if (this.preSelectUsers && this.preSelectUsers.length > 0 && this.isMultipleMode()) {
|
||||
const result = this.preSelectUsers.find((selectedUser) => {
|
||||
return selectedUser.id === user.id || selectedUser.email === user.email || selectedUser.username === user.username;
|
||||
});
|
||||
|
Reference in New Issue
Block a user