feat: Add max slot count to event type entity, migration, and admin form.

This commit is contained in:
Schneider Roland
2026-01-02 13:11:26 +01:00
parent df35b8991d
commit be029ee054
5 changed files with 48 additions and 19 deletions

View File

@@ -11,14 +11,21 @@
<form [formGroup]="form" (ngSubmit)="onSubmit()" class="space-y-4 mt-4"> <form [formGroup]="form" (ngSubmit)="onSubmit()" class="space-y-4 mt-4">
<div class="form-control"><label class="label"><span class="label-text">Esemény típus neve</span></label> <div class="form-control"><label class="label"><span class="label-text">Esemény típus neve</span></label>
<input type="text" formControlName="name" class="input input-bordered w-full" /></div> <input type="text" formControlName="name" class="input input-bordered w-full" />
</div>
<div class="form-control"><label class="label"><span class="label-text">Leírás</span></label> <div class="form-control"><label class="label"><span class="label-text">Leírás</span></label>
<input type="text" formControlName="description" class="input input-bordered w-full" /></div> <input type="text" formControlName="description" class="input input-bordered w-full" />
</div>
<div class="form-control"><label class="label"><span class="label-text">Szín</span></label> <div class="form-control"><label class="label"><span class="label-text">Szín</span></label>
<input type="color" formControlName="color" class="input input-bordered w-full" colorspace="display-p3" <input type="color" formControlName="color" class="input input-bordered w-full" colorspace="display-p3"
alpha /></div> alpha />
</div>
<div class="form-control"><label class="label"><span class="label-text">Maximális slot szám</span></label>
<input type="number" formControlName="max_slot_count" class="input input-bordered w-full" />
</div>
<div class="card-actions justify-end mt-6"> <div class="card-actions justify-end mt-6">
<a routerLink="/event-type" class="btn btn-ghost">Cancel</a> <a routerLink="/event-type" class="btn btn-ghost">Cancel</a>

View File

@@ -33,7 +33,7 @@ export class EventTypeFormComponent implements OnInit {
isEditMode = false; isEditMode = false;
id: number | null = null; id: number | null = null;
private numericFields = []; private numericFields = ['max_slot_count'];
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
@@ -45,7 +45,8 @@ export class EventTypeFormComponent implements OnInit {
this.form = this.fb.group({ this.form = this.fb.group({
name: [null], name: [null],
description: [null], description: [null],
color: [null] color: [null],
max_slot_count: [null]
}); });
} }

View File

@@ -6,6 +6,7 @@ export interface EventType {
name: string; name: string;
description: string; description: string;
color: string; color: string;
max_slot_count?: number;
} }
export interface PaginatedResponse<T> { export interface PaginatedResponse<T> {

View File

@@ -2,7 +2,7 @@
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm'; import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { Event } from './event.entity'; import { Event } from './event.entity';
import { IsString, IsOptional } from 'class-validator'; import { IsString, IsOptional, IsNumber } from 'class-validator';
@Entity({ name: 'event_type' }) @Entity({ name: 'event_type' })
export class EventType { export class EventType {
@@ -23,6 +23,11 @@ export class EventType {
@IsString() @IsString()
color: string | null; color: string | null;
@Column({ type: 'integer', nullable: true })
@IsOptional()
@IsNumber()
max_slot_count: number | null;
@OneToMany(() => Event, (event) => event.eventType) @OneToMany(() => Event, (event) => event.eventType)
events: Event[]; events: Event[];
} }

View File

@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddMaxSlotCountToEventType1763106308125 implements MigrationInterface {
name = 'AddMaxSlotCountToEventType1763106308125';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "event_type" ADD COLUMN "max_slot_count" integer NULL`,
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "event_type" DROP COLUMN "max_slot_count"`);
}
}