Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4403 and 5509 issue are fixed #1307

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}