Commit c9526d9c authored by mechtelm's avatar mechtelm
Browse files

Fix build error swagger/commonjs

NEVER extend dto classes in frontend!
NEVER use non-swagger classes/interfaces as data types in dto classes
parent 001f199b
import {Component, Inject} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import {MAT_DIALOG_DATA} from "@angular/material/dialog";
import {StaffMember} from "../staff-list.classes";
import {ContractTypeLabels, SexLabels} from "@lib/dto";
import {ContractTypeLabels, SexLabels, StaffMember} from "../staff-list.classes";
@Component({
template: `
......
import {ContractTypeLabels, StaffMemberInListDto, StaffMemberMainDto} from "../../../../../libs/dto/src";
import {StaffMemberInListDto, StaffMemberMainDto} from "@lib/dto";
import {formatDate} from "@angular/common";
export class StaffMemberView {
......@@ -16,18 +16,45 @@ export class StaffMemberView {
}
static idmStatusColor(staffMemberData: StaffMemberInListDto): string {
if (!staffMemberData.idmId) return 'yellow';
return ''
return staffMemberData.idmId ? '' : 'yellow';
}
}
export class StaffMember extends StaffMemberMainDto {
export const ContractTypeLabels = {
'hu': 'Humboldt-Universität',
'iqb': 'IQB regulär',
'stud': 'IQB Student:in',
'werk': 'IQB Werkstudent:in',
'school': 'abgeordnet'
}
export const SexLabels = {
'm': 'männlich',
'w': 'weiblich',
'd': 'divers',
'u': 'unbekannt'
}
export class StaffMember {
id!: number;
name!: string;
firstName?: string;
idmId?: string;
canonicalName?: string;
contractStart?: string;
contractEnd?: string;
contractType?: string;
payrollId?: string;
address?: string;
sex?: string;
salutation?: string;
get fullName(): string {
return `${this.name}${this.firstName ? ', ' + this.firstName : ''}`
}
get contractData(): string {
let returnText = `${this.contractType ? ContractTypeLabels[this.contractType] : '<kein Vertragstyp>'} `;
let returnText = `${this.contractType ? (ContractTypeLabels as {[key: string]: string})[this.contractType] : '<kein Vertragstyp>'} `;
if (this.contractStart) {
returnText += 'vom ' + formatDate(this.contractStart, 'dd.MM.yyyy', 'de') + ' ';
} else {
......@@ -42,7 +69,6 @@ export class StaffMember extends StaffMemberMainDto {
}
constructor (staffData: StaffMemberMainDto) {
super();
this.name = staffData.name;
this.firstName = staffData.firstName;
this.idmId = staffData.idmId;
......
export {UserInListDto} from './lib/user/user-in-list-dto';
export {UserFullDto} from './lib/user/user-full-dto';
export {StaffMemberMainDto, Sex, ContractType, SexLabels, ContractTypeLabels} from "./lib/staff/staff-member-main-dto";
export {StaffMemberMainDto} from "./lib/staff/staff-member-main-dto";
export {StaffMemberInListDto} from "./lib/staff/staff-member-in-list-dto";
export {StaffMemberMetadataDto} from "./lib/staff/staff-member-metadata-dto";
export {AuthDataDto} from "./lib/auth-data-dto";
......
......@@ -26,7 +26,7 @@ export class StaffMemberMainDto {
contractEnd?: string;
@ApiProperty({enum: ['hu', 'iqb', 'stud', 'werk', 'school']})
contractType?: ContractType | null;
contractType?: string;
@ApiProperty()
payrollId?: string;
......@@ -35,38 +35,8 @@ export class StaffMemberMainDto {
address?: string;
@ApiProperty({ enum: ['m', 'w', 'd', 'u']})
sex?: Sex | null;
sex?: string;
@ApiProperty()
salutation?: string;
}
export enum ContractType {
hu = 'hu',
iqb = 'iqb',
stud = 'stud',
werk = 'werk',
school = 'school'
}
export enum Sex {
m = 'm',
w = 'w',
d = 'd',
u = 'u'
}
export const ContractTypeLabels = {
'hu': 'Humboldt-Universität',
'iqb': 'IQB regulär',
'stud': 'IQB Student:in',
'werk': 'IQB Werkstudent:in',
'school': 'abgeordnet'
}
export const SexLabels = {
'm': 'männlich',
'w': 'weiblich',
'd': 'divers',
'u': 'unbekannt'
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment