[AAE-1602][AAE-1594] Fix duplicated users issue when validation enabl… (#5413)

* [AAE-1602][AAE-1594] Fix duplicated users issue when validation enabled, fix partial username should not return a valid user

* [AAE-1602][AAE-1594] Fix removing incorrect invalid user/group when name or id matches
This commit is contained in:
arditdomi
2020-01-28 15:05:26 +00:00
committed by Maurizio Vitale
parent d09373501f
commit 0ae55ba590
3 changed files with 40 additions and 35 deletions

View File

@@ -345,22 +345,28 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
onRemove(groupToRemove: IdentityGroupModel) {
this.removeGroup.emit(groupToRemove);
const indexToRemove = this.selectedGroups.findIndex((group: IdentityGroupModel) => {
return group.id === groupToRemove.id;
});
this.selectedGroups.splice(indexToRemove, 1);
this.removeGroupFromSelected(groupToRemove);
this.changedGroups.emit(this.selectedGroups);
this.searchGroupsControl.markAsDirty();
if (this.isValidationEnabled()) {
this.removeGroupFromValidation(groupToRemove.name);
this.removeGroupFromValidation(groupToRemove);
this.checkPreselectValidationErrors();
}
}
private removeGroupFromValidation(groupName: string) {
private removeGroupFromSelected(groupToRemove: IdentityGroupModel) {
const indexToRemove = this.selectedGroups.findIndex((selectedGroup: IdentityGroupModel) => {
return selectedGroup.id === groupToRemove.id && selectedGroup.name === groupToRemove.name;
});
if (indexToRemove !== -1) {
this.selectedGroups.splice(indexToRemove, 1);
}
}
private removeGroupFromValidation(groupToRemove: IdentityGroupModel) {
const indexToRemove = this.invalidGroups.findIndex((invalidGroup) => {
return invalidGroup.name === groupName;
return invalidGroup.name === groupToRemove.name && invalidGroup.id === groupToRemove.id;
});
if (indexToRemove !== -1) {