Added confirmdialog when no roles are chosen
This commit is contained in:
@@ -91,12 +91,6 @@
|
|||||||
></digi-ng-form-checkbox>
|
></digi-ng-form-checkbox>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</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>
|
</fieldset>
|
||||||
|
|
||||||
<digi-notification-alert
|
<digi-notification-alert
|
||||||
@@ -123,6 +117,22 @@
|
|||||||
</form>
|
</form>
|
||||||
</digi-typography>
|
</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
|
<digi-ng-dialog
|
||||||
id="roles-dialog"
|
id="roles-dialog"
|
||||||
[afActive]="displayRolesDialog"
|
[afActive]="displayRolesDialog"
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
readonly toggleAllUtforandeVerksamhetFormControlName = 'allaUtforandeVerksamheter';
|
readonly toggleAllUtforandeVerksamhetFormControlName = 'allaUtforandeVerksamheter';
|
||||||
|
|
||||||
editEmployeeFormGroup: FormGroup | null = null;
|
editEmployeeFormGroup: FormGroup | null = null;
|
||||||
|
displayEditWithoutRolesDialog = false;
|
||||||
|
|
||||||
displayRolesDialog = false;
|
displayRolesDialog = false;
|
||||||
|
|
||||||
@@ -168,7 +169,11 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
return this.employeeFormService.getFormControlName(role);
|
return this.employeeFormService.getFormControlName(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
onFormSubmitted(): void {
|
abortFormSubmit(): void {
|
||||||
|
this.displayEditWithoutRolesDialog = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onFormSubmitted(saveWithoutRoles = false): void {
|
||||||
if (!this.editEmployeeFormGroup) {
|
if (!this.editEmployeeFormGroup) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,6 +184,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const roles = this.employeeFormService.getRolesFromFormGroup(this.rolesFormGroup, this.availableRoles);
|
||||||
|
if (!roles.length && !saveWithoutRoles) {
|
||||||
|
this.displayEditWithoutRolesDialog = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.formSubmitted.emit({
|
this.formSubmitted.emit({
|
||||||
email: this.emailFormControl?.value as string,
|
email: this.emailFormControl?.value as string,
|
||||||
tjanstIds: this.employeeFormService
|
tjanstIds: this.employeeFormService
|
||||||
|
|||||||
@@ -20,10 +20,6 @@
|
|||||||
<dt>Förnamn</dt>
|
<dt>Förnamn</dt>
|
||||||
<dd>{{employee.firstName}}</dd>
|
<dd>{{employee.firstName}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
|
||||||
<dt>Förnamn</dt>
|
|
||||||
<dd>{{employee.firstName}}</dd>
|
|
||||||
</dl>
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Efternamn</dt>
|
<dt>Efternamn</dt>
|
||||||
<dd>{{employee.lastName}}</dd>
|
<dd>{{employee.lastName}}</dd>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
|||||||
import { RoleEnum } from '@msfa-enums/role.enum';
|
import { RoleEnum } from '@msfa-enums/role.enum';
|
||||||
import { Role } from '@msfa-models/role.model';
|
import { Role } from '@msfa-models/role.model';
|
||||||
import { Tjanst } from '@msfa-models/tjanst.model';
|
import { Tjanst } from '@msfa-models/tjanst.model';
|
||||||
import { EmployeeValidator } from '@msfa-utils/validators/employee.validator';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
@@ -48,10 +47,7 @@ export class EmployeeFormService {
|
|||||||
this.getFormControlName(role),
|
this.getFormControlName(role),
|
||||||
new FormControl(this.isSelectedRole(role, selectedRoles), []),
|
new FormControl(this.isSelectedRole(role, selectedRoles), []),
|
||||||
])
|
])
|
||||||
),
|
)
|
||||||
{
|
|
||||||
validators: [EmployeeValidator.HasSelectedAtLeastOneRole(roles.map(role => this.getFormControlName(role)))],
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user