feat: Add max slot count to event type entity, migration, and admin form.
This commit is contained in:
@@ -10,15 +10,22 @@
|
||||
|
||||
<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>
|
||||
<input type="text" formControlName="name" class="input input-bordered w-full" /></div>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
|
||||
<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"
|
||||
alpha /></div>
|
||||
<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"
|
||||
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">
|
||||
<a routerLink="/event-type" class="btn btn-ghost">Cancel</a>
|
||||
@@ -29,4 +36,4 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,7 +33,7 @@ export class EventTypeFormComponent implements OnInit {
|
||||
isEditMode = false;
|
||||
id: number | null = null;
|
||||
|
||||
private numericFields = [];
|
||||
private numericFields = ['max_slot_count'];
|
||||
|
||||
constructor(
|
||||
private fb: FormBuilder,
|
||||
@@ -43,9 +43,10 @@ export class EventTypeFormComponent implements OnInit {
|
||||
private cdr: ChangeDetectorRef
|
||||
) {
|
||||
this.form = this.fb.group({
|
||||
name: [null],
|
||||
description: [null],
|
||||
color: [null]
|
||||
name: [null],
|
||||
description: [null],
|
||||
color: [null],
|
||||
max_slot_count: [null]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,15 +90,15 @@ export class EventTypeFormComponent implements OnInit {
|
||||
|
||||
const payload = { ...this.form.value };
|
||||
|
||||
for (const field of this.numericFields) {
|
||||
if (payload[field] != null && payload[field] !== '') {
|
||||
payload[field] = parseFloat(payload[field]);
|
||||
}
|
||||
}
|
||||
for (const field of this.numericFields) {
|
||||
if (payload[field] != null && payload[field] !== '') {
|
||||
payload[field] = parseFloat(payload[field]);
|
||||
}
|
||||
}
|
||||
|
||||
let action$: Observable<EventType>;
|
||||
|
||||
if (this.isEditMode && this.id) {
|
||||
if (this.isEditMode && this.id) {
|
||||
action$ = this.eventTypeService.update(this.id, payload);
|
||||
} else {
|
||||
action$ = this.eventTypeService.create(payload);
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface EventType {
|
||||
name: string;
|
||||
description: string;
|
||||
color: string;
|
||||
max_slot_count?: number;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
import { Event } from './event.entity';
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
import { IsString, IsOptional, IsNumber } from 'class-validator';
|
||||
|
||||
@Entity({ name: 'event_type' })
|
||||
export class EventType {
|
||||
@@ -23,6 +23,11 @@ export class EventType {
|
||||
@IsString()
|
||||
color: string | null;
|
||||
|
||||
@Column({ type: 'integer', nullable: true })
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
max_slot_count: number | null;
|
||||
|
||||
@OneToMany(() => Event, (event) => event.eventType)
|
||||
events: Event[];
|
||||
}
|
||||
|
||||
@@ -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"`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user