add calendarview add frequency

This commit is contained in:
Schneider Roland 2025-11-25 08:28:23 +01:00
parent a575200368
commit bc5b73e080
4 changed files with 69 additions and 4 deletions

View File

@ -8,6 +8,9 @@
</div>
<rs-daisy-modal [isOpen]="isOpen()" (closeClick)="closeDialog()" >
@if (isOpen()){
<app-create-event-form (ready)="closeDialog()" [date]="selectedDate()" [id]="selectedEventId()"></app-create-event-form>
}
</rs-daisy-modal>

View File

@ -67,6 +67,7 @@ export class CalendarView implements OnInit, AfterViewInit {
this.workflow.set('day');
this.selectedDate.set(info.date);
this.selectedEventId.set(undefined);
console.info("date click with", this.selectedDate())
this.isOpen.set(true);
// console.info('Date click on: ' , info);
// const calendarApi = info.view.calendar;

View File

@ -10,7 +10,6 @@
<div class="form-control"><label class="label"><span class="label-text">Megnevezés</span></label>
<input [class.input-error]="title?.invalid && title?.touched" type="text" formControlName="title" class="input input-bordered w-full" />
</div>
<div class="form-control"><label class="label"><span class="label-text">Esemény típus</span></label>
@ -39,8 +38,26 @@
<input type="checkbox" formControlName="is_recurring" class="checkbox" />
</label></div>
@if (isRecurring?.value) {
<h3>Ismétlődés</h3>
<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"
>
<option disabled selected>Válassz gyakoriságot</option>
@for (frequencyOption of frequencyOptions; track frequencyOption) {
<option [value]="frequencyOption.frequency">{{ frequencyOption.label }}</option>
}
</select>
</div>
}
<div class="card-actions justify-end mt-6">
<a routerLink="/events" class="btn btn-ghost">Mégse</a>
<a routerLink="/events" class="btn btn-ghost" (click)="doReady()">Mégse</a>
<button type="submit" class="btn btn-primary" [disabled]="form.invalid">
{{ isEditMode ? 'Mentés' : 'Létrezhozás' }}
</button>

View File

@ -10,6 +10,12 @@ import { EventTypeService } from '../../../event-type/services/event-type.servic
import { CalendarService } from '../../services/calendar.service';
import { EventFormDTO } from '../../models/event-form-dto.model';
export type Frequency = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
export type FrequencyOption = {
frequency: Frequency,
label: string;
}
@Component({
selector: 'app-create-event-form',
@ -30,6 +36,23 @@ export class CreateEventForm implements OnInit {
private numericFields = ["event_type_id"];
frequencyOptions: FrequencyOption[] = [
{
frequency: 'DAILY',
label: 'Napi'
},
{
frequency: 'WEEKLY',
label: 'Heti'
}, {
frequency: 'MONTHLY',
label: 'Havi'
},{
frequency: 'YEARLY',
label: 'Éves'
}
]
constructor(
private fb: FormBuilder,
@ -46,6 +69,16 @@ export class CreateEventForm implements OnInit {
startTime: [null,Validators.required],
endTime: [null,Validators.required],
is_recurring: [null],
recurringRule: this.fb.group({
frequency: [null] ,//'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
interval: [null] ,//number
endDate: [null], // Date
count: [null], // number
byDay: [null], // string
byMonthDay: [null], // number
byMonth: [null], // number
})
});
}
@ -53,11 +86,14 @@ export class CreateEventForm implements OnInit {
of(this.id()).pipe(
tap(id => {
if (id) {
console.info("edit mode", 'edit')
this.isEditMode = true;
}else{
const start = new Date();
const end = new Date();
const start = this.date() || new Date();
const end = this.date() || new Date();
console.info("staring form with date", start,end);
start.setMinutes(0,0);
end.setHours(start.getHours()+1,0,0);
start.setMinutes(start.getMinutes() - start.getTimezoneOffset());
@ -88,6 +124,7 @@ export class CreateEventForm implements OnInit {
return of(null);
}),
).subscribe(event => {
console.info("subscribe form done")
if (event) {
this.form.patchValue(event);
}
@ -141,6 +178,13 @@ export class CreateEventForm implements OnInit {
return this.form.get('endTime');
}
get isRecurring(){
return this.form.get('is_recurring');
}
get frequency(){
return this.form.get('recurringRule')?.get('frequency');
}
doReady(){
this.ready.emit();
}