[AAE-1372] Refactor People/Group cloud component (#5355)

* [AAE-1372] Fix read-only preselected users can be deleted

* [AAE-1372] Fix people/group cloud component readonly mode

* [AAE-1372] Refactor People/Group Cloud components

* [AAE-1372] Refactor People/Group Cloud components

* [AAE-1372] Clear invalid user in single mode after replacing with a valid user

* [AAE-1372] Add progress bar while validation loading. When user gets removed remove from validation

* [AAE-1372] Fix lint errors

* [AAE-1372] Fix single selection e2e

* [AAE-1372] Fix unit tests - people/group cloud components

* [AAE-1372] Fix e2e, set People/Group formControls invalid when has preselect errors

* [AAE-1372] Fix invalid form control bug
This commit is contained in:
arditdomi
2020-01-21 13:37:57 +00:00
committed by Maurizio Vitale
parent 91abe87ccc
commit 3c3aa7599a
17 changed files with 1005 additions and 987 deletions

View File

@@ -32,21 +32,23 @@
</mat-form-field>
<mat-checkbox class="app-preselect-value" (change)="onChangePeopleValidation($event)">{{
'PEOPLE_GROUPS_CLOUD.PRESELECT_VALIDATION' | translate }}</mat-checkbox>
<mat-checkbox data-automation-id="app-people-readonly" value="{{ peopleReadonly }}" (change)="onChangePeopleReadonly($event)">{{
'PEOPLE_GROUPS_CLOUD.READONLY_MODE' | translate }}</mat-checkbox>
</div>
<div>
<adf-cloud-people
[preSelectUsers]="preSelectUsers"
[readOnly]="peopleReadonly"
[validate]="peoplePreselectValidation"
[appName]="peopleAppName"
[roles]="peopleRoles"
[title]="'ADF_TASK_LIST.START_TASK.FORM.LABEL.ASSIGNEE'"
[mode]="peopleMode"
(selectUser)="onSelectUser($event)"
(warning)="onUsersWarning($event)"></adf-cloud-people>
</div>
<div class="app-people-list" *ngIf="canShowPeopleList()">
<h4>{{ 'PEOPLE_GROUPS_CLOUD.ALL_SELECTED_USERS' | translate }}</h4>
<h4>{{ 'PEOPLE_GROUPS_CLOUD.ALL_PRESELECTED_USERS' | translate }}</h4>
<mat-list role="list">
<mat-list-item *ngFor="let item of preSelectUsers" role="listitem">
<mat-icon mat-list-icon>person</mat-icon>
@@ -99,23 +101,24 @@
<mat-label>Preselect: {{ DEFAULT_GROUP_PLACEHOLDER }}</mat-label>
<input matInput (input)="setGroupsPreselectValue($event)" data-automation-id="app-group-preselect-input" />
</mat-form-field>
<mat-checkbox class="app-group-preselect-validation" (change)="onChangeGroupValidation($event)">{{
<mat-checkbox class="app-preselect-value" (change)="onChangeGroupValidation($event)">{{
'PEOPLE_GROUPS_CLOUD.PRESELECT_VALIDATION' | translate }}</mat-checkbox>
<mat-checkbox data-automation-id="app-group-readonly" value="{{ groupReadonly }}" (change)="onChangeGroupReadonly($event)">{{
'PEOPLE_GROUPS_CLOUD.READONLY_MODE' | translate }}</mat-checkbox>
</div>
<div>
<adf-cloud-group
[mode]="groupMode"
[readOnly]="groupReadonly"
[validate]="groupPreselectValidation"
[roles]="groupRoles"
[appName]="groupAppName"
[preSelectGroups]="preSelectGroup"
(selectGroup)="onSelectGroup($event)"
(removeGroup)="onRemoveGroup($event)"
(warning)="onGroupsWarning($event)"></adf-cloud-group>
</div>
<div class="app-group-list" *ngIf="canShowGroupList()">
<h4>{{ 'PEOPLE_GROUPS_CLOUD.ALL_SELECTED_GROUPS' | translate }}</h4>
<h4>{{ 'PEOPLE_GROUPS_CLOUD.ALL_PRESELECTED_GROUPS' | translate }}</h4>
<mat-list role="list">
<mat-list-item *ngFor="let item of preSelectGroup" role="listitem">
<mat-icon mat-list-icon>group</mat-icon>

View File

@@ -34,17 +34,18 @@ export class PeopleGroupCloudDemoComponent {
peopleMode: string = PeopleCloudComponent.MODE_SINGLE;
preSelectUsers: IdentityUserModel[] = [];
invalidUsers: IdentityGroupModel[] = [];
invalidUsers: IdentityUserModel[] = [];
peopleRoles: string[] = [];
peopleAppName: string;
peopleFilterMode: string = this.DEFAULT_FILTER_MODE;
peoplePreselectValidation: Boolean = false;
groupPreselectValidation = false;
peopleReadonly = false;
groupReadonly = false;
groupMode: string = GroupCloudComponent.MODE_SINGLE;
preSelectGroup: IdentityGroupModel[] = [];
invalidGroups: IdentityGroupModel[] = [];
selectedGroupList: IdentityGroupModel[] = [];
groupRoles: string[];
groupAppName: string;
groupFilterMode: string = this.DEFAULT_FILTER_MODE;
@@ -75,12 +76,18 @@ export class PeopleGroupCloudDemoComponent {
onChangePeopleMode(event: MatRadioChange) {
this.peopleMode = event.value;
this.preSelectUsers = [...this.preSelectUsers];
}
onChangePeopleReadonly(event: MatCheckboxChange) {
this.peopleReadonly = event.checked;
}
onChangeGroupReadonly(event: MatCheckboxChange) {
this.groupReadonly = event.checked;
}
onChangeGroupsMode(event: MatRadioChange) {
this.groupMode = event.value;
this.preSelectGroup = [...this.preSelectGroup];
}
onChangePeopleFilterMode(event: MatRadioChange) {
@@ -119,18 +126,10 @@ export class PeopleGroupCloudDemoComponent {
onChangePeopleValidation(event: MatCheckboxChange) {
this.peoplePreselectValidation = event.checked;
this.preSelectUsers = [...this.preSelectUsers];
if (!this.peoplePreselectValidation) {
this.invalidUsers = [];
}
}
onChangeGroupValidation(event: MatCheckboxChange) {
this.groupPreselectValidation = event.checked;
this.preSelectGroup = [...this.preSelectGroup];
if (!this.groupPreselectValidation) {
this.invalidGroups = [];
}
}
onGroupsWarning(warning: any) {
@@ -167,22 +166,6 @@ export class PeopleGroupCloudDemoComponent {
return this.groupMode === GroupCloudComponent.MODE_MULTIPLE;
}
onRemoveGroup(group: IdentityGroupModel) {
this.preSelectGroup = this.preSelectGroup.filter((value: any) => value.id !== group.id);
}
onSelectUser(user: IdentityUserModel) {
if (this.peopleMode === PeopleCloudComponent.MODE_MULTIPLE) {
this.preSelectUsers.push(user);
}
}
onSelectGroup(group: IdentityGroupModel) {
if (this.groupMode === GroupCloudComponent.MODE_MULTIPLE) {
this.preSelectGroup.push(group);
}
}
get peopleSingleMode() {
return PeopleCloudComponent.MODE_SINGLE;
}