add calendarview add frequency

This commit is contained in:
Schneider Roland 2025-11-25 20:00:48 +01:00
parent bc5b73e080
commit 9c1c2f6356
2 changed files with 64 additions and 15 deletions

View File

@ -39,14 +39,14 @@
</label></div>
@if (isRecurring?.value) {
<h3>Ismétlődés</h3>
<div formGroupName="recurringRule" class="space-y-4 p-4 border border-base-300 rounded-lg">
<h3 class="text-lg font-semibold">Ismétlődés</h3>
<div class="form-control"><label class="label"><span class="label-text">Gyakoriság</span></label>
<div class="form-control">
<label class="label"><span class="label-text">Gyakoriság</span></label>
<select class="select w-full"
formGroupName="recurringRule"
formControlName="frequency"
[class.input-error]="frequency?.invalid && eventType?.touched"
>
[class.select-error]="frequency?.invalid && frequency?.touched">
<option disabled selected>Válassz gyakoriságot</option>
@for (frequencyOption of frequencyOptions; track frequencyOption) {
<option [value]="frequencyOption.frequency">{{ frequencyOption.label }}</option>
@ -54,6 +54,22 @@
</select>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Intervallum</span></label>
<input type="number"
formControlName="interval"
class="input input-bordered w-full"
[class.input-error]="interval?.invalid && interval?.touched" />
</div>
<div class="form-control">
<label class="label"><span class="label-text">Ismétlődés vége</span></label>
<input type="date"
formControlName="endDate"
class="input input-bordered w-full"
[class.input-error]="endDate?.invalid && endDate?.touched" />
</div>
</div>
}
<div class="card-actions justify-end mt-6">

View File

@ -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();
}