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 class="msfa__small-text" *ngIf="errorWhileUpdating.message">{{errorWhileUpdating.message}}</p>
|
||||
</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>
|
||||
|
||||
<footer class="edit-employee-form__footer">
|
||||
|
||||
@@ -56,6 +56,7 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
|
||||
editEmployeeFormGroup: FormGroup | null = null;
|
||||
displayEditWithoutRolesDialog = false;
|
||||
displayPristineWarning = false;
|
||||
|
||||
displayRolesDialog = false;
|
||||
|
||||
@@ -151,7 +152,8 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
[
|
||||
TreeNodeValidator.IsValidTreeNode(
|
||||
this.utforandeVerksamheterService.hasSelectedUtforandeVerksamhet,
|
||||
'required'
|
||||
'required',
|
||||
this.toggleAllUtforandeVerksamhetFormControl
|
||||
),
|
||||
]
|
||||
),
|
||||
@@ -176,7 +178,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
|
||||
this.editEmployeeFormGroup.markAllAsTouched();
|
||||
|
||||
if (this.editEmployeeFormGroup.invalid || this.editEmployeeFormGroup.pristine) {
|
||||
if (this.editEmployeeFormGroup.invalid) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.editEmployeeFormGroup.pristine) {
|
||||
this.displayPristineWarning = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,7 +210,6 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
this.utforandeVerksamhetFormControl?.value
|
||||
),
|
||||
allaUtforandeVerksamheter: !!this.toggleAllUtforandeVerksamhetFormControl.value,
|
||||
utforandeVerksamhetIds: [],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,5 @@ export interface EmployeeEditRequest {
|
||||
roles: RoleEnum[];
|
||||
tjanstIds: number[];
|
||||
allaUtforandeVerksamheter: boolean;
|
||||
utforandeVerksamhetIds?: number[];
|
||||
adressIds: number[];
|
||||
}
|
||||
|
||||
@@ -4,14 +4,15 @@ import { TreeNode } from '@msfa-shared/components/tree-nodes-selector/services/t
|
||||
export class TreeNodeValidator {
|
||||
static IsValidTreeNode(
|
||||
validationFn: (treeNode: TreeNode | null | undefined) => boolean,
|
||||
nameOfError: string
|
||||
nameOfError: string,
|
||||
allUtforandeVerksamheterFormControl: AbstractControl
|
||||
): ValidatorFn {
|
||||
return (control: AbstractControl): { [key: string]: unknown } => {
|
||||
const isValid = validationFn(control.value);
|
||||
|
||||
const validationObj = {};
|
||||
|
||||
if (isValid) {
|
||||
if (isValid || allUtforandeVerksamheterFormControl?.value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user