Compare commits
2 Commits
df35b8991d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6ecefb8d9 | ||
|
|
be029ee054 |
@@ -1,6 +1,7 @@
|
|||||||
<form [formGroup]="filterForm" class="p-4 bg-base-200 rounded-lg shadow">
|
<form [formGroup]="filterForm" class="p-4 bg-base-200 rounded-lg shadow">
|
||||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-end">
|
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 items-end">
|
||||||
<div class="form-control"><label class="label"><span class="label-text">SearchTerm</span></label>
|
<div class="form-control"><label class="label"><span class="label-text">Keresés</span></label>
|
||||||
<input type="text" formControlName="term" class="input input-bordered w-full" placeholder="Search term" /></div>
|
<input type="text" formControlName="term" class="input input-bordered w-full" placeholder="Keresés" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -5,28 +5,35 @@
|
|||||||
<div class="card bg-base-100 shadow-xl max-w-2xl mx-auto">
|
<div class="card bg-base-100 shadow-xl max-w-2xl mx-auto">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h2 class="card-title text-3xl">
|
<h2 class="card-title text-3xl">
|
||||||
{{ isEditMode ? 'Edit' : 'Create' }} EventType
|
{{ isEditMode ? 'Frissítés' : 'Létrehozás' }} Esemény típus
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<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">Vissza</a>
|
||||||
<button type="submit" class="btn btn-primary" [disabled]="form.invalid">
|
<button type="submit" class="btn btn-primary" [disabled]="form.invalid">
|
||||||
{{ isEditMode ? 'Update' : 'Create' }}
|
{{ isEditMode ? 'Frissítés' : 'Létrehozás' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -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,
|
||||||
@@ -43,9 +43,10 @@ export class EventTypeFormComponent implements OnInit {
|
|||||||
private cdr: ChangeDetectorRef
|
private cdr: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
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]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,22 +90,22 @@ export class EventTypeFormComponent implements OnInit {
|
|||||||
|
|
||||||
const payload = { ...this.form.value };
|
const payload = { ...this.form.value };
|
||||||
|
|
||||||
for (const field of this.numericFields) {
|
for (const field of this.numericFields) {
|
||||||
if (payload[field] != null && payload[field] !== '') {
|
if (payload[field] != null && payload[field] !== '') {
|
||||||
payload[field] = parseFloat(payload[field]);
|
payload[field] = parseFloat(payload[field]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let action$: Observable<EventType>;
|
let action$: Observable<EventType>;
|
||||||
|
|
||||||
if (this.isEditMode && this.id) {
|
if (this.isEditMode && this.id) {
|
||||||
action$ = this.eventTypeService.update(this.id, payload);
|
action$ = this.eventTypeService.update(this.id, payload);
|
||||||
} else {
|
} else {
|
||||||
action$ = this.eventTypeService.create(payload);
|
action$ = this.eventTypeService.create(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
action$.subscribe({
|
action$.subscribe({
|
||||||
next: () => this.router.navigate(['/event-type']),
|
next: () => this.router.navigate(['/event-type/table']),
|
||||||
error: (err) => console.error('Failed to save event-type', err)
|
error: (err) => console.error('Failed to save event-type', err)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,19 +13,21 @@
|
|||||||
<table class="table w-full">
|
<table class="table w-full">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>id</th>
|
<th>Azonosító</th>
|
||||||
<th>name</th>
|
<th>Név</th>
|
||||||
<th>description</th>
|
<th>Leírás</th>
|
||||||
<th>color</th>
|
<th>Szín</th>
|
||||||
<th class="text-right">Actions</th>
|
<th>Férőhelyek</th>
|
||||||
|
<th class="text-right">Műveletek</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let item of response.data" class="hover">
|
<tr *ngFor="let item of response.data" class="hover">
|
||||||
<td>{{ item.id }}</td>
|
<td>{{ item.id }}</td>
|
||||||
<td>{{ item.name }}</td>
|
<td>{{ item.name }}</td>
|
||||||
<td>{{ item.description }}</td>
|
<td>{{ item.description }}</td>
|
||||||
<td>{{ item.color }}</td>
|
<td>{{ item.color }}</td>
|
||||||
|
<td>{{ item.max_slot_count }}</td>
|
||||||
<td class="text-right space-x-2">
|
<td class="text-right space-x-2">
|
||||||
<a [routerLink]="['/event-type', item.id]" class="btn btn-sm btn-ghost">Részletek</a>
|
<a [routerLink]="['/event-type', item.id]" class="btn btn-sm btn-ghost">Részletek</a>
|
||||||
<a [routerLink]="['/event-type', item.id, 'edit']" class="btn btn-sm btn-ghost">Módosítás</a>
|
<a [routerLink]="['/event-type', item.id, 'edit']" class="btn btn-sm btn-ghost">Módosítás</a>
|
||||||
@@ -33,7 +35,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr *ngIf="response.data.length === 0">
|
<tr *ngIf="response.data.length === 0">
|
||||||
<td colspan="5" class="text-center">No event-type found.</td>
|
<td colspan="6" class="text-center">Nem található eseménytípusok.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -42,14 +44,10 @@
|
|||||||
<!-- Pagination Controls -->
|
<!-- Pagination Controls -->
|
||||||
<div *ngIf="response.meta.totalPages > 1" class="flex justify-center mt-4">
|
<div *ngIf="response.meta.totalPages > 1" class="flex justify-center mt-4">
|
||||||
<div class="join">
|
<div class="join">
|
||||||
<button
|
<button class="join-item btn" (click)="changePage(response.meta.currentPage - 1)"
|
||||||
class="join-item btn"
|
|
||||||
(click)="changePage(response.meta.currentPage - 1)"
|
|
||||||
[disabled]="response.meta.currentPage === 1">«</button>
|
[disabled]="response.meta.currentPage === 1">«</button>
|
||||||
<button class="join-item btn">Page {{ response.meta.currentPage }} of {{ response.meta.totalPages }}</button>
|
<button class="join-item btn">Oldal {{ response.meta.currentPage }} of {{ response.meta.totalPages }}</button>
|
||||||
<button
|
<button class="join-item btn" (click)="changePage(response.meta.currentPage + 1)"
|
||||||
class="join-item btn"
|
|
||||||
(click)="changePage(response.meta.currentPage + 1)"
|
|
||||||
[disabled]="response.meta.currentPage === response.meta.totalPages">»</button>
|
[disabled]="response.meta.currentPage === response.meta.totalPages">»</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,4 +58,4 @@
|
|||||||
<span class="loading loading-spinner loading-lg"></span>
|
<span class="loading loading-spinner loading-lg"></span>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,7 +60,7 @@ export class EventTypeTableComponent implements OnInit {
|
|||||||
columns: [
|
columns: [
|
||||||
{
|
{
|
||||||
attribute: 'name',
|
attribute: 'name',
|
||||||
headerCell: true,
|
headerCell: { value: 'Név' },
|
||||||
valueCell: {
|
valueCell: {
|
||||||
styleClass: ctx => 'w-[1%]',
|
styleClass: ctx => 'w-[1%]',
|
||||||
value: item => item?.name,
|
value: item => item?.name,
|
||||||
@@ -68,14 +68,14 @@ export class EventTypeTableComponent implements OnInit {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
attribute: 'description',
|
attribute: 'description',
|
||||||
headerCell: true,
|
headerCell: { value: 'Leírás' },
|
||||||
valueCell: {
|
valueCell: {
|
||||||
value: item => item?.description,
|
value: item => item?.description,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
attribute: 'color',
|
attribute: 'color',
|
||||||
headerCell: true,
|
headerCell: { value: 'Szín' },
|
||||||
valueCell: {
|
valueCell: {
|
||||||
styleClass: ctx => 'w-[1%]',
|
styleClass: ctx => 'w-[1%]',
|
||||||
value: item => item?.color,
|
value: item => item?.color,
|
||||||
@@ -85,9 +85,16 @@ export class EventTypeTableComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
attribute: 'max_slot_count',
|
||||||
|
headerCell: { value: 'Férőhelyek' },
|
||||||
|
valueCell: {
|
||||||
|
value: item => item?.max_slot_count,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
attribute: 'actions',
|
attribute: 'actions',
|
||||||
headerCell: { value: 'Actions' },
|
headerCell: { value: 'Műveletek' },
|
||||||
valueCell: {
|
valueCell: {
|
||||||
styleClass: ctx => 'w-[1%]',
|
styleClass: ctx => 'w-[1%]',
|
||||||
component: GenericActionColumn,
|
component: GenericActionColumn,
|
||||||
|
|||||||
@@ -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> {
|
||||||
|
|||||||
@@ -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[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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