[AAE-1594] Fix partial group name of a valid group should not be valid, fix form-cloud able to search when people/group widget is readonly (#5417)

This commit is contained in:
arditdomi
2020-01-29 09:23:03 +00:00
committed by GitHub
parent 2e71bc6e27
commit 95c7074d65
4 changed files with 11 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
<form> <form>
<mat-form-field class="adf-cloud-group"> <mat-form-field class="adf-cloud-group">
<mat-label <mat-label *ngIf="!isReadonly()"
id="adf-group-cloud-title-id">{{ (title || 'ADF_CLOUD_GROUPS.SEARCH-GROUP') | translate }}</mat-label> id="adf-group-cloud-title-id">{{ (title || 'ADF_CLOUD_GROUPS.SEARCH-GROUP') | translate }}</mat-label>
<mat-chip-list #groupChipList [disabled]="isReadonly() || isValidationLoading()" data-automation-id="adf-cloud-group-chip-list" class="apa-group-chip-list"> <mat-chip-list #groupChipList [disabled]="isReadonly() || isValidationLoading()" data-automation-id="adf-cloud-group-chip-list" class="apa-group-chip-list">
<mat-chip <mat-chip
@@ -16,7 +16,7 @@
cancel cancel
</mat-icon> </mat-icon>
</mat-chip> </mat-chip>
<input matInput <input *ngIf="!isReadonly()" matInput
[formControl]="searchGroupsControl" [formControl]="searchGroupsControl"
[matAutocomplete]="auto" [matAutocomplete]="auto"
[matChipInputFor]="groupChipList" [matChipInputFor]="groupChipList"

View File

@@ -119,7 +119,6 @@ describe('GroupCloudComponent', () => {
it('should selectedGroup and groupsChanged emit, update selected groups when a group is selected', (done) => { it('should selectedGroup and groupsChanged emit, update selected groups when a group is selected', (done) => {
const group = { name: 'groupname' }; const group = { name: 'groupname' };
fixture.detectChanges(); fixture.detectChanges();
spyOn(component, 'hasGroupIdOrName').and.returnValue(true);
const selectEmitSpy = spyOn(component.selectGroup, 'emit'); const selectEmitSpy = spyOn(component.selectGroup, 'emit');
const changedGroupsSpy = spyOn(component.changedGroups, 'emit'); const changedGroupsSpy = spyOn(component.changedGroups, 'emit');
component.onSelect(group); component.onSelect(group);
@@ -540,7 +539,6 @@ describe('GroupCloudComponent', () => {
it('should check validation only for the first group and emit warning when group is invalid - single mode', (done) => { it('should check validation only for the first group and emit warning when group is invalid - single mode', (done) => {
spyOn(identityGroupService, 'findGroupsByName').and.returnValue(Promise.resolve([])); spyOn(identityGroupService, 'findGroupsByName').and.returnValue(Promise.resolve([]));
spyOn(component, 'hasGroupIdOrName').and.returnValue(false);
const expectedWarning = { const expectedWarning = {
message: 'INVALID_PRESELECTED_GROUPS', message: 'INVALID_PRESELECTED_GROUPS',

View File

@@ -266,7 +266,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
await Promise.all(preselectedGroupsToValidate.map(async (group: IdentityGroupModel) => { await Promise.all(preselectedGroupsToValidate.map(async (group: IdentityGroupModel) => {
try { try {
const validationResult = await this.searchGroup(group.name); const validationResult = await this.searchGroup(group.name);
if (!this.hasGroupIdOrName(validationResult)) { if (this.isPreselectedGroupInvalid(group, validationResult)) {
this.invalidGroups.push(group); this.invalidGroups.push(group);
} }
} catch (error) { } catch (error) {
@@ -380,8 +380,12 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
this.searchGroupsSubject.next(this.searchGroups); this.searchGroupsSubject.next(this.searchGroups);
} }
hasGroupIdOrName(group: IdentityGroupModel): boolean { isPreselectedGroupInvalid(preselectedGroup: IdentityGroupModel, validatedGroup: IdentityGroupModel): boolean {
return group && (group.id !== undefined || group.name !== undefined); if (validatedGroup && validatedGroup.name !== undefined) {
return preselectedGroup.name !== validatedGroup.name;
} else {
return true;
}
} }
isSingleMode(): boolean { isSingleMode(): boolean {

View File

@@ -1,6 +1,6 @@
<form> <form>
<mat-form-field class="adf-people-cloud"> <mat-form-field class="adf-people-cloud">
<mat-label id="adf-people-cloud-title-id">{{ title | translate }}</mat-label> <mat-label *ngIf="!isReadonly()" id="adf-people-cloud-title-id">{{ title | translate }}</mat-label>
<mat-chip-list #userMultipleChipList [disabled]="isReadonly() || isValidationLoading()" data-automation-id="adf-cloud-people-chip-list"> <mat-chip-list #userMultipleChipList [disabled]="isReadonly() || isValidationLoading()" data-automation-id="adf-cloud-people-chip-list">
<mat-chip <mat-chip
*ngFor="let user of selectedUsers" *ngFor="let user of selectedUsers"
@@ -16,7 +16,7 @@
cancel cancel
</mat-icon> </mat-icon>
</mat-chip> </mat-chip>
<input matInput <input *ngIf="!isReadonly()" matInput
[formControl]="searchUserCtrl" [formControl]="searchUserCtrl"
[matAutocomplete]="auto" [matAutocomplete]="auto"
[matChipInputFor]="userMultipleChipList" [matChipInputFor]="userMultipleChipList"