Added confirmdialog when no roles are chosen
This commit is contained in:
@@ -91,12 +91,6 @@
|
||||
></digi-ng-form-checkbox>
|
||||
</li>
|
||||
</ul>
|
||||
<digi-form-validation-message
|
||||
*ngIf="rolesFormGroup.invalid && rolesFormGroup.errors.noRoleSelected && rolesFormGroup.touched"
|
||||
af-variation="error"
|
||||
>
|
||||
Du måste välja minst en behörighet
|
||||
</digi-form-validation-message>
|
||||
</fieldset>
|
||||
|
||||
<digi-notification-alert
|
||||
@@ -123,6 +117,22 @@
|
||||
</form>
|
||||
</digi-typography>
|
||||
|
||||
<digi-ng-dialog
|
||||
[afActive]="displayEditWithoutRolesDialog"
|
||||
(afOnPrimaryClick)="onFormSubmitted(true)"
|
||||
(afOnSecondaryClick)="abortFormSubmit()"
|
||||
(afOnInactive)="abortFormSubmit()"
|
||||
afHeading="Är du säker"
|
||||
afHeadingLevel="h2"
|
||||
afPrimaryButtonText="Ja, spara ändå"
|
||||
afSecondaryButtonText="Nej, gå tillbaka"
|
||||
>
|
||||
<p>
|
||||
Inga behörigheter har valts, det betyder att personalen inte kommer kunna utföra några arbetsuppgifter i systemet.
|
||||
Är du säker att du vill spara?
|
||||
</p>
|
||||
</digi-ng-dialog>
|
||||
|
||||
<digi-ng-dialog
|
||||
id="roles-dialog"
|
||||
[afActive]="displayRolesDialog"
|
||||
|
||||
@@ -64,6 +64,7 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
readonly toggleAllUtforandeVerksamhetFormControlName = 'allaUtforandeVerksamheter';
|
||||
|
||||
editEmployeeFormGroup: FormGroup | null = null;
|
||||
displayEditWithoutRolesDialog = false;
|
||||
|
||||
displayRolesDialog = false;
|
||||
|
||||
@@ -168,7 +169,11 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
return this.employeeFormService.getFormControlName(role);
|
||||
}
|
||||
|
||||
onFormSubmitted(): void {
|
||||
abortFormSubmit(): void {
|
||||
this.displayEditWithoutRolesDialog = false;
|
||||
}
|
||||
|
||||
onFormSubmitted(saveWithoutRoles = false): void {
|
||||
if (!this.editEmployeeFormGroup) {
|
||||
return;
|
||||
}
|
||||
@@ -179,6 +184,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
||||
return;
|
||||
}
|
||||
|
||||
const roles = this.employeeFormService.getRolesFromFormGroup(this.rolesFormGroup, this.availableRoles);
|
||||
if (!roles.length && !saveWithoutRoles) {
|
||||
this.displayEditWithoutRolesDialog = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.formSubmitted.emit({
|
||||
email: this.emailFormControl?.value as string,
|
||||
tjanstIds: this.employeeFormService
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
<dt>Förnamn</dt>
|
||||
<dd>{{employee.firstName}}</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Förnamn</dt>
|
||||
<dd>{{employee.firstName}}</dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>Efternamn</dt>
|
||||
<dd>{{employee.lastName}}</dd>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||
import { Role } from '@msfa-models/role.model';
|
||||
import { Tjanst } from '@msfa-models/tjanst.model';
|
||||
import { EmployeeValidator } from '@msfa-utils/validators/employee.validator';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -48,10 +47,7 @@ export class EmployeeFormService {
|
||||
this.getFormControlName(role),
|
||||
new FormControl(this.isSelectedRole(role, selectedRoles), []),
|
||||
])
|
||||
),
|
||||
{
|
||||
validators: [EmployeeValidator.HasSelectedAtLeastOneRole(roles.map(role => this.getFormControlName(role)))],
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user