From 4dd6fa6d8a73eb4d660416fba7a46358590c3ca2 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Sun, 19 Jan 2025 13:14:12 +0100 Subject: [PATCH] add excused state to protocol presence --- src/data-source.ts | 2 ++ src/entity/club/protocol/protocolPresence.ts | 3 +++ .../admin/club/protocol/protocolPresence.ts | 1 + .../1737287798828-protocolPresenceExcuse.ts | 21 +++++++++++++++++++ .../club/protocol/protocolPresence.models.ts | 1 + 5 files changed, 28 insertions(+) create mode 100644 src/migrations/1737287798828-protocolPresenceExcuse.ts diff --git a/src/data-source.ts b/src/data-source.ts index 4c4a424..c7ba457 100644 --- a/src/data-source.ts +++ b/src/data-source.ts @@ -67,6 +67,7 @@ import { ProtocolAbsent1736072179716 } from "./migrations/1736072179716-protocol import { Memberlist1736079005086 } from "./migrations/1736079005086-memberlist"; import { ExtendViewValues1736084198860 } from "./migrations/1736084198860-extendViewValues"; import { FinishInternalIdTransfer1736505324488 } from "./migrations/1736505324488-finishInternalIdTransfer"; +import { ProtocolPresenceExcuse1737287798828 } from "./migrations/1737287798828-protocolPresenceExcuse"; const dataSource = new DataSource({ type: DB_TYPE as any, @@ -144,6 +145,7 @@ const dataSource = new DataSource({ Memberlist1736079005086, ExtendViewValues1736084198860, FinishInternalIdTransfer1736505324488, + ProtocolPresenceExcuse1737287798828, ], migrationsRun: true, migrationsTransactionMode: "each", diff --git a/src/entity/club/protocol/protocolPresence.ts b/src/entity/club/protocol/protocolPresence.ts index ef7f0cb..15fe061 100644 --- a/src/entity/club/protocol/protocolPresence.ts +++ b/src/entity/club/protocol/protocolPresence.ts @@ -13,6 +13,9 @@ export class protocolPresence { @Column({ type: "boolean", default: false }) absent: boolean; + @Column({ type: "boolean", default: true }) + excused: boolean; + @ManyToOne(() => member, { nullable: false, onDelete: "CASCADE", diff --git a/src/factory/admin/club/protocol/protocolPresence.ts b/src/factory/admin/club/protocol/protocolPresence.ts index 37ca37a..5cfbeb4 100644 --- a/src/factory/admin/club/protocol/protocolPresence.ts +++ b/src/factory/admin/club/protocol/protocolPresence.ts @@ -12,6 +12,7 @@ export default abstract class ProtocolPresenceFactory { return { memberId: record.member.id, absent: record.absent, + excused: record.excused, protocolId: record.protocolId, }; } diff --git a/src/migrations/1737287798828-protocolPresenceExcuse.ts b/src/migrations/1737287798828-protocolPresenceExcuse.ts new file mode 100644 index 0000000..c3954e1 --- /dev/null +++ b/src/migrations/1737287798828-protocolPresenceExcuse.ts @@ -0,0 +1,21 @@ +import { MigrationInterface, QueryRunner, TableColumn } from "typeorm"; + +export class ProtocolPresenceExcuse1737287798828 implements MigrationInterface { + name = "ProtocolPresenceExcuse1737287798828"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.addColumn( + "protocol_presence", + new TableColumn({ + name: "excused", + type: "tinyint", + default: "1", + isNullable: false, + }) + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.dropColumn("protocol_presence", "excused"); + } +} diff --git a/src/viewmodel/admin/club/protocol/protocolPresence.models.ts b/src/viewmodel/admin/club/protocol/protocolPresence.models.ts index 476dc99..9bc363c 100644 --- a/src/viewmodel/admin/club/protocol/protocolPresence.models.ts +++ b/src/viewmodel/admin/club/protocol/protocolPresence.models.ts @@ -3,5 +3,6 @@ import { MemberViewModel } from "../member/member.models"; export interface ProtocolPresenceViewModel { memberId: number; absent: boolean; + excused: boolean; protocolId: number; }