monthly meetups

This commit is contained in:
HolgerHatGarKeineNode
2023-03-06 14:05:31 +01:00
parent fcf73ad364
commit 9a00e6dc12
2 changed files with 14 additions and 12 deletions

View File

@@ -17,7 +17,7 @@ class MeetupEventForm extends Component
public bool $recurring = false; public bool $recurring = false;
public int $repetitions = 52; public int $repetitions = 12;
public array $series = []; public array $series = [];
@@ -34,6 +34,7 @@ class MeetupEventForm extends Component
'meetupEvent.description' => 'string|nullable', 'meetupEvent.description' => 'string|nullable',
'meetupEvent.link' => 'url|nullable', 'meetupEvent.link' => 'url|nullable',
'series' => 'array',
'series.*.start' => 'required', 'series.*.start' => 'required',
'recurring' => 'bool', 'recurring' => 'bool',
@@ -63,7 +64,7 @@ class MeetupEventForm extends Component
public function updatedMeetupEventStart($value) public function updatedMeetupEventStart($value)
{ {
$this->validate(); $this->validateOnly('meetupEvent.start');
if ($this->recurring) { if ($this->recurring) {
$this->updatedRecurring(true); $this->updatedRecurring(true);
} }
@@ -71,23 +72,24 @@ class MeetupEventForm extends Component
public function updatedRecurring($value) public function updatedRecurring($value)
{ {
$this->validate(); $this->validateOnly('recurring');
$series = [];
if ($value && $this->meetupEvent->start) { if ($value && $this->meetupEvent->start) {
$this->series = [];
for ($i = 0; $i < $this->repetitions; $i++) { for ($i = 0; $i < $this->repetitions; $i++) {
$this->series[] = [ $series[] = [
'start' => $this->meetupEvent->start->addWeeks($i + 1) 'start' => $this->meetupEvent->start->addMonths($i + 1)
->toDateTimeString(), ->toDateTimeString(),
]; ];
} }
} }
$this->series = $series;
} }
public function updatedRepetitions($value) public function updatedRepetitions($value)
{ {
$this->validate(); $this->validateOnly('repetitions');
if ($this->recurring) { if ($this->recurring) {
$this->updatedRecurring(true); $this->updatedRecurring(true, $value);
} }
} }

View File

@@ -60,9 +60,9 @@
:placeholder="__('Start')"/> :placeholder="__('Start')"/>
</x-input.group> </x-input.group>
@if(!$meetupEvent->id) @if(!$meetupEvent->id && $meetupEvent->start)
<x-input.group :for="md5('recurring')" :label="__('Recurring appointment')"> <x-input.group :for="md5('recurringid')" :label="__('Recurring appointment / monthly')">
<x-toggle :label="__('Recurring appointment')" wire:model="recurring"/> <x-toggle lg :label="__('Recurring appointment')" wire:model="recurring"/>
<p class="text-xs text-amber-400 py-2">{{ __('The recurring appointments are created in the database as new entries. Please be careful with this function, otherwise you will have to change or delete all the appointments you have created manually if you make an error.') }}</p> <p class="text-xs text-amber-400 py-2">{{ __('The recurring appointments are created in the database as new entries. Please be careful with this function, otherwise you will have to change or delete all the appointments you have created manually if you make an error.') }}</p>
</x-input.group> </x-input.group>
@endif @endif
@@ -91,7 +91,7 @@
</x-input.group> </x-input.group>
<x-input.group :for="md5('grid')" :label="__('Recurring appointments')"> <x-input.group :for="md5('grid')" :label="__('Recurring appointments')">
@if($meetupEvent->start && $recurring) @if($recurring && count($series) === $repetitions)
<div class="grid grid-cols-1 lg:grid-cols-3 gap-2"> <div class="grid grid-cols-1 lg:grid-cols-3 gap-2">
@for($i = 0; $i < $repetitions; $i++) @for($i = 0; $i < $repetitions; $i++)
<x-datetime-picker <x-datetime-picker