add calendarview add frequency
This commit is contained in:
parent
a575200368
commit
bc5b73e080
@ -8,6 +8,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<rs-daisy-modal [isOpen]="isOpen()" (closeClick)="closeDialog()" >
|
<rs-daisy-modal [isOpen]="isOpen()" (closeClick)="closeDialog()" >
|
||||||
|
@if (isOpen()){
|
||||||
<app-create-event-form (ready)="closeDialog()" [date]="selectedDate()" [id]="selectedEventId()"></app-create-event-form>
|
<app-create-event-form (ready)="closeDialog()" [date]="selectedDate()" [id]="selectedEventId()"></app-create-event-form>
|
||||||
|
}
|
||||||
|
|
||||||
</rs-daisy-modal>
|
</rs-daisy-modal>
|
||||||
|
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export class CalendarView implements OnInit, AfterViewInit {
|
|||||||
this.workflow.set('day');
|
this.workflow.set('day');
|
||||||
this.selectedDate.set(info.date);
|
this.selectedDate.set(info.date);
|
||||||
this.selectedEventId.set(undefined);
|
this.selectedEventId.set(undefined);
|
||||||
|
console.info("date click with", this.selectedDate())
|
||||||
this.isOpen.set(true);
|
this.isOpen.set(true);
|
||||||
// console.info('Date click on: ' , info);
|
// console.info('Date click on: ' , info);
|
||||||
// const calendarApi = info.view.calendar;
|
// const calendarApi = info.view.calendar;
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
<div class="form-control"><label class="label"><span class="label-text">Megnevezés</span></label>
|
<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" />
|
<input [class.input-error]="title?.invalid && title?.touched" type="text" formControlName="title" class="input input-bordered w-full" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-control"><label class="label"><span class="label-text">Esemény típus</span></label>
|
<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" />
|
<input type="checkbox" formControlName="is_recurring" class="checkbox" />
|
||||||
</label></div>
|
</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">
|
<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">
|
<button type="submit" class="btn btn-primary" [disabled]="form.invalid">
|
||||||
{{ isEditMode ? 'Mentés' : 'Létrezhozás' }}
|
{{ isEditMode ? 'Mentés' : 'Létrezhozás' }}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -10,6 +10,12 @@ import { EventTypeService } from '../../../event-type/services/event-type.servic
|
|||||||
import { CalendarService } from '../../services/calendar.service';
|
import { CalendarService } from '../../services/calendar.service';
|
||||||
import { EventFormDTO } from '../../models/event-form-dto.model';
|
import { EventFormDTO } from '../../models/event-form-dto.model';
|
||||||
|
|
||||||
|
export type Frequency = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
||||||
|
export type FrequencyOption = {
|
||||||
|
frequency: Frequency,
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-create-event-form',
|
selector: 'app-create-event-form',
|
||||||
@ -30,6 +36,23 @@ export class CreateEventForm implements OnInit {
|
|||||||
|
|
||||||
private numericFields = ["event_type_id"];
|
private numericFields = ["event_type_id"];
|
||||||
|
|
||||||
|
frequencyOptions: FrequencyOption[] = [
|
||||||
|
{
|
||||||
|
frequency: 'DAILY',
|
||||||
|
label: 'Napi'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
frequency: 'WEEKLY',
|
||||||
|
label: 'Heti'
|
||||||
|
}, {
|
||||||
|
frequency: 'MONTHLY',
|
||||||
|
label: 'Havi'
|
||||||
|
},{
|
||||||
|
frequency: 'YEARLY',
|
||||||
|
label: 'Éves'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
@ -46,6 +69,16 @@ export class CreateEventForm implements OnInit {
|
|||||||
startTime: [null,Validators.required],
|
startTime: [null,Validators.required],
|
||||||
endTime: [null,Validators.required],
|
endTime: [null,Validators.required],
|
||||||
is_recurring: [null],
|
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(
|
of(this.id()).pipe(
|
||||||
tap(id => {
|
tap(id => {
|
||||||
if (id) {
|
if (id) {
|
||||||
|
console.info("edit mode", 'edit')
|
||||||
this.isEditMode = true;
|
this.isEditMode = true;
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
const start = new Date();
|
const start = this.date() || new Date();
|
||||||
const end = new Date();
|
const end = this.date() || new Date();
|
||||||
|
|
||||||
|
console.info("staring form with date", start,end);
|
||||||
start.setMinutes(0,0);
|
start.setMinutes(0,0);
|
||||||
end.setHours(start.getHours()+1,0,0);
|
end.setHours(start.getHours()+1,0,0);
|
||||||
start.setMinutes(start.getMinutes() - start.getTimezoneOffset());
|
start.setMinutes(start.getMinutes() - start.getTimezoneOffset());
|
||||||
@ -88,6 +124,7 @@ export class CreateEventForm implements OnInit {
|
|||||||
return of(null);
|
return of(null);
|
||||||
}),
|
}),
|
||||||
).subscribe(event => {
|
).subscribe(event => {
|
||||||
|
console.info("subscribe form done")
|
||||||
if (event) {
|
if (event) {
|
||||||
this.form.patchValue(event);
|
this.form.patchValue(event);
|
||||||
}
|
}
|
||||||
@ -141,6 +178,13 @@ export class CreateEventForm implements OnInit {
|
|||||||
return this.form.get('endTime');
|
return this.form.get('endTime');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isRecurring(){
|
||||||
|
return this.form.get('is_recurring');
|
||||||
|
}
|
||||||
|
|
||||||
|
get frequency(){
|
||||||
|
return this.form.get('recurringRule')?.get('frequency');
|
||||||
|
}
|
||||||
doReady(){
|
doReady(){
|
||||||
this.ready.emit();
|
this.ready.emit();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user