Removed default role from view

This commit is contained in:
Erik Tiekstra
2021-09-07 16:15:46 +02:00
parent 89c8a38faa
commit 36035e07be
3 changed files with 36 additions and 28 deletions

View File

@@ -11,6 +11,7 @@ import {
SimpleChanges,
} from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
import { RoleEnum } from '@msfa-enums/role.enum';
import { EmployeeEditRequest } from '@msfa-models/api/employee-edit.request.model';
import { Employee } from '@msfa-models/employee.model';
import { CustomError } from '@msfa-models/error/custom-error';
@@ -183,7 +184,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
tjanstIds: this.employeeFormService
.getSelectedTjanster(this.availableTjanster, +this.tjansterFormControl?.value)
.map(tjanst => tjanst.tjanstId),
roles: this.employeeFormService.getRolesFromFormGroup(this.rolesFormGroup, this.availableRoles),
roles: [
...new Set([
...this.employeeFormService.getRolesFromFormGroup(this.rolesFormGroup, this.availableRoles),
RoleEnum.MSFA_Standard,
]),
],
adressIds: this.toggleAllUtforandeVerksamhetFormControl.value
? []
: this.utforandeVerksamheterService.getSelectedAdressIdsFromTreeNode(

View File

@@ -27,7 +27,7 @@
></digi-form-input-search> -->
<digi-form-checkbox
class="employees__only-employees-without-authorization"
af-label="Visa endast personer utan behörigheter"
af-label="Visa endast personal utan behörigheter"
[afChecked]="onlyEmployeesWithoutAuthorization$ | async"
(afOnChange)="setOnlyEmployeesWithoutAuthorization($event.detail.target.checked)"
></digi-form-checkbox>

View File

@@ -6,30 +6,32 @@ export interface Role {
}
export function mapResponseToRoles(types: RoleEnum[] = []): Role[] {
return types.map(type => {
switch (type) {
case 'MSFA_Standard':
return {
name: 'Basanvändare',
type: RoleEnum[type],
};
case 'MSFA_ReportAndPlanning':
return {
name: 'Rapportering, planering och information om deltagare',
type: RoleEnum[type],
};
case 'MSFA_ReceiveDeltagare':
return {
name: 'Ta emot deltagare',
type: RoleEnum[RoleEnum[type]],
};
case 'MSFA_AuthAdmin':
return {
name: 'Administrera behörigheter',
type: RoleEnum[RoleEnum[type]],
};
default:
return;
}
});
return types
.filter(type => type !== RoleEnum.MSFA_Standard)
.map(type => {
switch (type) {
case 'MSFA_Standard':
return {
name: 'Basanvändare',
type: RoleEnum[type],
};
case 'MSFA_ReportAndPlanning':
return {
name: 'Rapportering, planering och information om deltagare',
type: RoleEnum[type],
};
case 'MSFA_ReceiveDeltagare':
return {
name: 'Ta emot deltagare',
type: RoleEnum[RoleEnum[type]],
};
case 'MSFA_AuthAdmin':
return {
name: 'Administrera behörigheter',
type: RoleEnum[RoleEnum[type]],
};
default:
return;
}
});
}