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, SimpleChanges,
} from '@angular/core'; } from '@angular/core';
import { AbstractControl, FormControl, FormGroup } from '@angular/forms'; 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 { EmployeeEditRequest } from '@msfa-models/api/employee-edit.request.model';
import { Employee } from '@msfa-models/employee.model'; import { Employee } from '@msfa-models/employee.model';
import { CustomError } from '@msfa-models/error/custom-error'; import { CustomError } from '@msfa-models/error/custom-error';
@@ -183,7 +184,12 @@ export class EditEmployeeFormComponent implements OnInit, OnChanges {
tjanstIds: this.employeeFormService tjanstIds: this.employeeFormService
.getSelectedTjanster(this.availableTjanster, +this.tjansterFormControl?.value) .getSelectedTjanster(this.availableTjanster, +this.tjansterFormControl?.value)
.map(tjanst => tjanst.tjanstId), .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 adressIds: this.toggleAllUtforandeVerksamhetFormControl.value
? [] ? []
: this.utforandeVerksamheterService.getSelectedAdressIdsFromTreeNode( : this.utforandeVerksamheterService.getSelectedAdressIdsFromTreeNode(

View File

@@ -27,7 +27,7 @@
></digi-form-input-search> --> ></digi-form-input-search> -->
<digi-form-checkbox <digi-form-checkbox
class="employees__only-employees-without-authorization" 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" [afChecked]="onlyEmployeesWithoutAuthorization$ | async"
(afOnChange)="setOnlyEmployeesWithoutAuthorization($event.detail.target.checked)" (afOnChange)="setOnlyEmployeesWithoutAuthorization($event.detail.target.checked)"
></digi-form-checkbox> ></digi-form-checkbox>

View File

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