Added pristineWarning if no changes has been made to edit employee form
This commit is contained in:
@@ -110,6 +110,17 @@
|
|||||||
<p>Personalkontot för {{employee.fullName}} kunde inte redigeras. Vänligen försök igen.</p>
|
<p>Personalkontot för {{employee.fullName}} kunde inte redigeras. Vänligen försök igen.</p>
|
||||||
<p class="msfa__small-text" *ngIf="errorWhileUpdating.message">{{errorWhileUpdating.message}}</p>
|
<p class="msfa__small-text" *ngIf="errorWhileUpdating.message">{{errorWhileUpdating.message}}</p>
|
||||||
</digi-notification-alert>
|
</digi-notification-alert>
|
||||||
|
|
||||||
|
<digi-notification-alert
|
||||||
|
*ngIf="displayPristineWarning"
|
||||||
|
af-variation="warning"
|
||||||
|
af-heading="Du har inte gjort några ändringar"
|
||||||
|
af-heading-level="h4"
|
||||||
|
[afCloseable]="true"
|
||||||
|
(afOnClose)="displayPristineWarning = false"
|
||||||
|
>
|
||||||
|
<p>Du har inte gjort några ändringar i formuläret. För att spara personalkontot behöver ändringar göras.</p>
|
||||||
|
</digi-notification-alert>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer class="edit-employee-form__footer">
|
<footer class="edit-employee-form__footer">
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
editEmployeeFormGroup: FormGroup | null = null;
|
editEmployeeFormGroup: FormGroup | null = null;
|
||||||
displayEditWithoutRolesDialog = false;
|
displayEditWithoutRolesDialog = false;
|
||||||
|
displayPristineWarning = false;
|
||||||
|
|
||||||
displayRolesDialog = false;
|
displayRolesDialog = false;
|
||||||
|
|
||||||
@@ -151,7 +152,8 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
[
|
[
|
||||||
TreeNodeValidator.IsValidTreeNode(
|
TreeNodeValidator.IsValidTreeNode(
|
||||||
this.utforandeVerksamheterService.hasSelectedUtforandeVerksamhet,
|
this.utforandeVerksamheterService.hasSelectedUtforandeVerksamhet,
|
||||||
'required'
|
'required',
|
||||||
|
this.toggleAllUtforandeVerksamhetFormControl
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
@@ -176,7 +178,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
this.editEmployeeFormGroup.markAllAsTouched();
|
this.editEmployeeFormGroup.markAllAsTouched();
|
||||||
|
|
||||||
if (this.editEmployeeFormGroup.invalid || this.editEmployeeFormGroup.pristine) {
|
if (this.editEmployeeFormGroup.invalid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.editEmployeeFormGroup.pristine) {
|
||||||
|
this.displayPristineWarning = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +210,6 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
this.utforandeVerksamhetFormControl?.value
|
this.utforandeVerksamhetFormControl?.value
|
||||||
),
|
),
|
||||||
allaUtforandeVerksamheter: !!this.toggleAllUtforandeVerksamhetFormControl.value,
|
allaUtforandeVerksamheter: !!this.toggleAllUtforandeVerksamhetFormControl.value,
|
||||||
utforandeVerksamhetIds: [],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,5 @@ export interface EmployeeEditRequest {
|
|||||||
roles: RoleEnum[];
|
roles: RoleEnum[];
|
||||||
tjanstIds: number[];
|
tjanstIds: number[];
|
||||||
allaUtforandeVerksamheter: boolean;
|
allaUtforandeVerksamheter: boolean;
|
||||||
utforandeVerksamhetIds?: number[];
|
|
||||||
adressIds: number[];
|
adressIds: number[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import { TreeNode } from '@msfa-shared/components/tree-nodes-selector/services/t
|
|||||||
export class TreeNodeValidator {
|
export class TreeNodeValidator {
|
||||||
static IsValidTreeNode(
|
static IsValidTreeNode(
|
||||||
validationFn: (treeNode: TreeNode | null | undefined) => boolean,
|
validationFn: (treeNode: TreeNode | null | undefined) => boolean,
|
||||||
nameOfError: string
|
nameOfError: string,
|
||||||
|
allUtforandeVerksamheterFormControl: AbstractControl
|
||||||
): ValidatorFn {
|
): ValidatorFn {
|
||||||
return (control: AbstractControl): { [key: string]: unknown } => {
|
return (control: AbstractControl): { [key: string]: unknown } => {
|
||||||
const isValid = validationFn(control.value);
|
const isValid = validationFn(control.value);
|
||||||
|
|
||||||
const validationObj = {};
|
const validationObj = {};
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid || allUtforandeVerksamheterFormControl?.value) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user