Skip to content

Commit

Permalink
4403 and 5509 issue are fixed (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithmuthukumar-bc authored May 3, 2023
1 parent e785f30 commit 6eead5e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ <h2 class="govuk-tabs__title">
</div>

<div class="govuk-button-group save-cancel-button-group">
<button type="submit" class="govuk-button" [disabled]="!formChanged" data-module="govuk-button">
<button type="submit" class="govuk-button" [disabled]="!isFormChanges" data-module="govuk-button">
{{ 'SAVE_BTN' | translate }}
</button>
<button type="button" (click)="onCancelClick()" class="govuk-button govuk-button--secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class ManageUserAddSingleUserDetailComponent
public isInvalidDomain: boolean = false
public subscription: Subscription = new Subscription;
public showRoleView: boolean = environment.appSetting.hideSimplifyRole
public isFormGroupChanges:boolean = false
@ViewChildren('input') inputs!: QueryList<ElementRef>;
constructor(
private organisationGroupService: WrapperOrganisationGroupService,
Expand Down Expand Up @@ -941,14 +942,22 @@ export class ManageUserAddSingleUserDetailComponent
}

public IsChangeInGroupSelection(responseGroups: any): void {
var isSelectedAndResponseGroupsSame = !this.selectedGroupCheckboxes.every((groupId: any) => responseGroups.includes(groupId));
var isResponseGroupsSame = !responseGroups.every((groupId: any) => this.selectedGroupCheckboxes.includes(groupId));
if (isSelectedAndResponseGroupsSame || isResponseGroupsSame) {
this.formChanged = true;
}
else {
this.formChanged = false;
if(this.isEdit){
var isSelectedAndResponseGroupsSame = !this.selectedGroupCheckboxes.every((groupId: any) => responseGroups.includes(groupId));
var isResponseGroupsSame = !responseGroups.every((groupId: any) => this.selectedGroupCheckboxes.includes(groupId));
if (isSelectedAndResponseGroupsSame || isResponseGroupsSame) {
this.isFormGroupChanges = true;
}
else {
this.isFormGroupChanges = false;
}
} else {
this.isFormGroupChanges = this.selectedGroupCheckboxes.length != 0;
}
}


public get isFormChanges(){
return this.formChanged || this.isFormGroupChanges;
}
}
4 changes: 2 additions & 2 deletions src/app/pages/user-profile/user-profile-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ <h2 class="govuk-tabs__title">
*ngFor="let orgRole of orgUserGroupRoles; let i=index">
<input class="govuk-checkboxes__input" id="{{'orgRoleControlGroup_' + orgRole.id}}"
[attr.disabled]="true" [attr.checked]="true"
[formControlName]="'orgRoleControlGroup_' + orgRole.id" type="checkbox"
type="checkbox"
value="hmrc">
<label class="govuk-label govuk-checkboxes__label role_lable"
[ngClass]="{'govuk-!-padding-top-0': orgRole.description != ''}"
Expand Down Expand Up @@ -411,7 +411,7 @@ <h2 class="govuk-heading-s contact-detail"> {{ 'CONTACT_DETAILS' | translate }}<
</div>

<div class="govuk-button-group save-cancel-button-group">
<button type="submit" class="govuk-button" [disabled]="!formChanged" data-module="govuk-button">
<button type="submit" class="govuk-button" [disabled]="!isFormChanges" data-module="govuk-button">
{{ 'SAVE_BTN' | translate }}
</button>
<button type="button" (click)="onCancelClick()" class="govuk-button govuk-button--secondary"
Expand Down
27 changes: 21 additions & 6 deletions src/app/pages/user-profile/user-profile-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { WrapperOrganisationService } from 'src/app/services/wrapper/wrapper-org
})
export class UserProfileComponent extends FormBaseComponent implements OnInit {
public showRoleView: boolean = environment.appSetting.hideSimplifyRole
public isFormGroupChanges:boolean = false
submitted!: boolean;
formGroup!: FormGroup;
userServiceTableHeaders = ['NAME'];
Expand Down Expand Up @@ -660,12 +661,10 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit {
for (const group of this.orgGroups) {
const isGroupOfUser: any = this.userGroups?.find((ug) => ug.groupId === group.groupId);
if (isGroupOfUser) {

group.serviceRoleGroups.map((fc: any) => {
var serviceGroupApprovalDetails: any = this.userGroups?.find((ug: any) => ug.groupId === group.groupId && ug.accessServiceRoleGroupId === fc.id);
fc.approvalStatus = serviceGroupApprovalDetails?.approvalStatus;
});

group.checked = true
group.serviceRoleGroups = group.serviceRoleGroups.filter((item: any) => item.approvalStatus === 0 || item.approvalStatus === 1);
this.groupsMember.data.push(group)
Expand All @@ -691,23 +690,23 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit {
}

public groupsMemberCheckBoxAddRoles(data: any) {
this.formChanged = true;
this.selectedGroupCheckboxes.push(data.groupId);
this.IsChangeInGroupSelection(this.userGroups?.map(x => x.groupId));
}

public groupsMemberCheckBoxRemoveRoles(data: any) {
this.formChanged = true;
this.selectedGroupCheckboxes = this.removeObjectById(this.selectedGroupCheckboxes, data.groupId)
this.IsChangeInGroupSelection(this.userGroups?.map(x => x.groupId));
}

public noneGroupsMemberCheckBoxAddRoles(data: any) {
this.formChanged = true;
this.selectedGroupCheckboxes.push(data.groupId);
this.IsChangeInGroupSelection(this.userGroups?.map(x => x.groupId));
}

public noneGroupsMemberCheckBoxRemoveRoles(data: any) {
this.formChanged = true;
this.selectedGroupCheckboxes = this.removeObjectById(this.selectedGroupCheckboxes, data.groupId)
this.IsChangeInGroupSelection(this.userGroups?.map(x => x.groupId));
}

private removeObjectById(arr: any, id: any) {
Expand All @@ -732,4 +731,20 @@ export class UserProfileComponent extends FormBaseComponent implements OnInit {
}
}

public IsChangeInGroupSelection(responseGroups: any): void {
var isSelectedAndResponseGroupsSame = !this.selectedGroupCheckboxes.every((groupId: any) => responseGroups.includes(groupId));
var isResponseGroupsSame = !responseGroups.every((groupId: any) => this.selectedGroupCheckboxes.includes(groupId));
if (isSelectedAndResponseGroupsSame || isResponseGroupsSame) {
this.isFormGroupChanges = true;
}
else {
this.isFormGroupChanges = false;
}
}


public get isFormChanges(){
return this.formChanged || this.isFormGroupChanges;
}

}

0 comments on commit 6eead5e

Please sign in to comment.