Changes to some models and data coming from API
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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[]> {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user