Changes to some models and data coming from API

This commit is contained in:
Erik Tiekstra
2021-09-01 10:26:05 +02:00
parent 02cf0f6114
commit e4f5802f97
9 changed files with 55 additions and 62 deletions

View File

@@ -1,7 +1,6 @@
export enum RoleEnum {
OrganizationUser = 'OrganizationUser', // Default role
ReportAndPlanning = 'ReportAndPlanning',
ReceiveDeltagare = 'ReceiveDeltagare',
AuthAdmin = 'AuthAdmin',
ContactPerson = 'ContactPerson',
MSFA_AuthAdmin = 'MSFA_AuthAdmin',
MSFA_ReceiveDeltagare = 'MSFA_ReceiveDeltagare',
MSFA_ReportAndPlanning = 'MSFA_ReportAndPlanning',
MSFA_Standard = 'MSFA_Standard', // Default role
}

View File

@@ -6,33 +6,28 @@ export interface Role {
}
export function mapRoleResponseToRoleObject(type: string): Role {
switch(type) {
case 'OrganizationUser':
switch (type) {
case 'MSFA_Standard':
return {
name: 'Basanvändare',
type: RoleEnum[type]
name: 'Basanvändare',
type: RoleEnum[type],
};
case 'ReportAndPlanning':
case 'MSFA_ReportAndPlanning':
return {
name: 'Rapportering, planering och information om deltagare',
type: RoleEnum[type]
name: 'Rapportering, planering och information om deltagare',
type: RoleEnum[type],
};
case 'ReceiveDeltagare':
case 'MSFA_ReceiveDeltagare':
return {
name: 'Ta emot deltagare',
type: RoleEnum[RoleEnum[type]]
type: RoleEnum[RoleEnum[type]],
};
case 'AuthAdmin':
case 'MSFA_AuthAdmin':
return {
name: 'Administrera behörigheter',
type: RoleEnum[RoleEnum[type]]
};
case 'ContactPerson':
return {
name: 'Kontaktperson',
type: RoleEnum[type]
name: 'Administrera behörigheter',
type: RoleEnum[RoleEnum[type]],
};
default:
return;
}
}
}

View File

@@ -50,12 +50,16 @@ export class AvropApiService {
this._lockedAvropSnapshot$.next(avrop);
return this.httpClient.get<{ data: HandledareResponse[] }>(`${this._apiBaseUrl}/handledare`).pipe(
map(({ data }) => data.map(handledare => mapHandledareResponseToHandledare(handledare))),
tap(handledare => {
this._availableHandledareSnapshot$.next(handledare);
return this.httpClient
.get<{ data: HandledareResponse[] }>(`${this._apiBaseUrl}/handledare`, {
params: { avropIds: avrop.map(a => a.id) },
})
);
.pipe(
map(({ data }) => data.map(handledare => mapHandledareResponseToHandledare(handledare))),
tap(handledare => {
this._availableHandledareSnapshot$.next(handledare);
})
);
}
fetchAvailableTjanster$(params: Params): Observable<AvropTjanst[]> {

View File

@@ -190,15 +190,17 @@ export class EmployeeService extends UnsubscribeDirective {
}
public updateEmployeeData(employeeData: Employee): Observable<string> {
return /* this.httpClient.put<{ id: string }>(`${this._apiBaseUrl}/${employeeData.id}`,
return; /* this.httpClient.put<{ id: string }>(`${this._apiBaseUrl}/${employeeData.id}`,
mapEmployeeToRequestData(employeeData), API_HEADERS).pipe(
map(({ id }) => id),
catchError(error => throwError({ message: error as string, type: ErrorType.API }))
); */
}
public getAllRoles(): Role[] {
const allAuths: string[] = Object.keys(RoleEnum).filter((item) => {return isNaN(Number(item))});
return allAuths.map(key => mapRoleResponseToRoleObject(key));
public get allRoles(): Role[] {
const allAuths: string[] = Object.keys(RoleEnum).filter(item => {
return isNaN(Number(item));
});
return allAuths.map(key => mapRoleResponseToRoleObject(key));
}
}