From 9c1c2f6356faa07dd47efe0a0dd7dbec28c21fd4 Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Tue, 25 Nov 2025 20:00:48 +0100 Subject: [PATCH] add calendarview add frequency --- .../create-event-form/create-event-form.html | 42 +++++++++++++------ .../create-event-form/create-event-form.ts | 37 +++++++++++++++- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/admin/src/app/features/calendar/components/create-event-form/create-event-form.html b/admin/src/app/features/calendar/components/create-event-form/create-event-form.html index 2ccfa10..9e02f83 100644 --- a/admin/src/app/features/calendar/components/create-event-form/create-event-form.html +++ b/admin/src/app/features/calendar/components/create-event-form/create-event-form.html @@ -39,21 +39,37 @@ @if (isRecurring?.value) { -

Ismétlődés

+
+

Ismétlődés

-
- +
+ + +
+ +
+ + +
+ +
+ + +
- }
diff --git a/admin/src/app/features/calendar/components/create-event-form/create-event-form.ts b/admin/src/app/features/calendar/components/create-event-form/create-event-form.ts index 3930206..8390e6c 100644 --- a/admin/src/app/features/calendar/components/create-event-form/create-event-form.ts +++ b/admin/src/app/features/calendar/components/create-event-form/create-event-form.ts @@ -68,13 +68,13 @@ export class CreateEventForm implements OnInit { description: [null], startTime: [null,Validators.required], endTime: [null,Validators.required], - is_recurring: [null], + is_recurring: [false], recurringRule: this.fb.group({ frequency: [null] ,//'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY'; interval: [null] ,//number endDate: [null], // Date count: [null], // number - byDay: [null], // string + byDay: [null], // string. e.g.: "MO,TU,WE,TH,FR" byMonthDay: [null], // number byMonth: [null], // number @@ -83,6 +83,22 @@ export class CreateEventForm implements OnInit { } ngOnInit(): void { + this.isRecurring?.valueChanges.subscribe(isRecurring => { + const recurringRule = this.form.get('recurringRule'); + if (isRecurring) { + recurringRule?.get('frequency')?.setValidators([Validators.required]); + recurringRule?.get('interval')?.setValidators([Validators.required, Validators.min(1)]); + recurringRule?.get('endDate')?.setValidators([Validators.required]); + } else { + recurringRule?.get('frequency')?.clearValidators(); + recurringRule?.get('interval')?.clearValidators(); + recurringRule?.get('endDate')?.clearValidators(); + } + recurringRule?.get('frequency')?.updateValueAndValidity(); + recurringRule?.get('interval')?.updateValueAndValidity(); + recurringRule?.get('endDate')?.updateValueAndValidity(); + }); + of(this.id()).pipe( tap(id => { if (id) { @@ -139,6 +155,10 @@ export class CreateEventForm implements OnInit { const payload: EventFormDTO|any = { ...this.form.value }; + if (!payload.is_recurring) { + delete payload.recurringRule; + } + for (const field of this.numericFields) { if (payload[field] != null && payload[field] !== '') { payload[field] = parseFloat(payload[field]); @@ -182,9 +202,22 @@ export class CreateEventForm implements OnInit { return this.form.get('is_recurring'); } + get recurringRule(){ + return this.form.get('recurringRule'); + } + get frequency(){ return this.form.get('recurringRule')?.get('frequency'); } + + get interval(){ + return this.form.get('recurringRule')?.get('interval'); + } + + get endDate(){ + return this.form.get('recurringRule')?.get('endDate'); + } + doReady(){ this.ready.emit(); }