add calendarview add frequency
This commit is contained in:
parent
bc5b73e080
commit
9c1c2f6356
@ -39,14 +39,14 @@
|
|||||||
</label></div>
|
</label></div>
|
||||||
|
|
||||||
@if (isRecurring?.value) {
|
@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"
|
<select class="select w-full"
|
||||||
formGroupName="recurringRule"
|
|
||||||
formControlName="frequency"
|
formControlName="frequency"
|
||||||
[class.input-error]="frequency?.invalid && eventType?.touched"
|
[class.select-error]="frequency?.invalid && frequency?.touched">
|
||||||
>
|
|
||||||
<option disabled selected>Válassz gyakoriságot</option>
|
<option disabled selected>Válassz gyakoriságot</option>
|
||||||
@for (frequencyOption of frequencyOptions; track frequencyOption) {
|
@for (frequencyOption of frequencyOptions; track frequencyOption) {
|
||||||
<option [value]="frequencyOption.frequency">{{ frequencyOption.label }}</option>
|
<option [value]="frequencyOption.frequency">{{ frequencyOption.label }}</option>
|
||||||
@ -54,6 +54,22 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</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">
|
<div class="card-actions justify-end mt-6">
|
||||||
|
|||||||
@ -68,13 +68,13 @@ export class CreateEventForm implements OnInit {
|
|||||||
description: [null],
|
description: [null],
|
||||||
startTime: [null,Validators.required],
|
startTime: [null,Validators.required],
|
||||||
endTime: [null,Validators.required],
|
endTime: [null,Validators.required],
|
||||||
is_recurring: [null],
|
is_recurring: [false],
|
||||||
recurringRule: this.fb.group({
|
recurringRule: this.fb.group({
|
||||||
frequency: [null] ,//'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
frequency: [null] ,//'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY';
|
||||||
interval: [null] ,//number
|
interval: [null] ,//number
|
||||||
endDate: [null], // Date
|
endDate: [null], // Date
|
||||||
count: [null], // number
|
count: [null], // number
|
||||||
byDay: [null], // string
|
byDay: [null], // string. e.g.: "MO,TU,WE,TH,FR"
|
||||||
byMonthDay: [null], // number
|
byMonthDay: [null], // number
|
||||||
byMonth: [null], // number
|
byMonth: [null], // number
|
||||||
|
|
||||||
@ -83,6 +83,22 @@ export class CreateEventForm implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
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(
|
of(this.id()).pipe(
|
||||||
tap(id => {
|
tap(id => {
|
||||||
if (id) {
|
if (id) {
|
||||||
@ -139,6 +155,10 @@ export class CreateEventForm implements OnInit {
|
|||||||
|
|
||||||
const payload: EventFormDTO|any = { ...this.form.value };
|
const payload: EventFormDTO|any = { ...this.form.value };
|
||||||
|
|
||||||
|
if (!payload.is_recurring) {
|
||||||
|
delete payload.recurringRule;
|
||||||
|
}
|
||||||
|
|
||||||
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]);
|
||||||
@ -182,9 +202,22 @@ export class CreateEventForm implements OnInit {
|
|||||||
return this.form.get('is_recurring');
|
return this.form.get('is_recurring');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get recurringRule(){
|
||||||
|
return this.form.get('recurringRule');
|
||||||
|
}
|
||||||
|
|
||||||
get frequency(){
|
get frequency(){
|
||||||
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(){
|
doReady(){
|
||||||
this.ready.emit();
|
this.ready.emit();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user