Can set the father and the mother of a member
This commit is contained in:
@ -31,6 +31,12 @@ export interface MemberDataApi {
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface DateValue {
|
||||
year?: number;
|
||||
month?: number;
|
||||
day?: number;
|
||||
}
|
||||
|
||||
export class Member implements MemberDataApi {
|
||||
id: number;
|
||||
family_id: number;
|
||||
@ -111,13 +117,43 @@ export class Member implements MemberDataApi {
|
||||
return this.photo_id !== null;
|
||||
}
|
||||
|
||||
get photoURL(): string {
|
||||
get photoURL(): string | null {
|
||||
if (!this.signed_photo_id) return null;
|
||||
return `${APIClient.backendURL()}/photo/${this.signed_photo_id}`;
|
||||
}
|
||||
|
||||
get thumbnailURL(): string {
|
||||
get thumbnailURL(): string | null {
|
||||
if (!this.signed_photo_id) return null;
|
||||
return `${APIClient.backendURL()}/photo/${this.signed_photo_id}/thumbnail`;
|
||||
}
|
||||
|
||||
get dateOfBirth(): DateValue | undefined {
|
||||
if (!this.birth_day && !this.birth_month && !this.birth_year)
|
||||
return undefined;
|
||||
|
||||
return {
|
||||
year: this.birth_year,
|
||||
month: this.birth_month,
|
||||
day: this.birth_day,
|
||||
};
|
||||
}
|
||||
|
||||
get dateOfDeath(): DateValue | undefined {
|
||||
if (!this.death_day && !this.death_month && !this.death_year)
|
||||
return undefined;
|
||||
|
||||
return {
|
||||
year: this.death_year,
|
||||
month: this.death_month,
|
||||
day: this.death_day,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function fmtDate(d?: DateValue): string {
|
||||
return `${d?.day?.toString().padStart(2, "0") ?? "__"}/${
|
||||
d?.month?.toString().padStart(2, "0") ?? "__"
|
||||
}/${d?.year?.toString().padStart(4, "0") ?? "__"}`;
|
||||
}
|
||||
|
||||
export class MembersList {
|
||||
@ -132,6 +168,14 @@ export class MembersList {
|
||||
this.map.set(m.id, m);
|
||||
}
|
||||
}
|
||||
|
||||
filter(predicate: (m: Member) => boolean): Member[] {
|
||||
return this.list.filter(predicate);
|
||||
}
|
||||
|
||||
get(id: number): Member | undefined {
|
||||
return this.map.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
export class MemberApi {
|
||||
|
Reference in New Issue
Block a user