Skip to content

[Bug]: #147

@underdpt

Description

@underdpt

What happened?

Hello,

I found some issues when trying to drag & drop events on a dayGridWeek view, and traced the issues to enum CalendarViewType missing this view type. I'm not sure if this impacts anywhere else, otherwise I can make a PR.

Error was:

Cannot assign null to property Guava\Calendar\ValueObjects\CalendarView::$type of type Guava\Calendar\Enums\CalendarViewType
 #file: "vendor\guava\calendar\src\ValueObjects\CalendarView.php"
 #line: 33

How to reproduce the bug

use Filament\Notifications\Notification;
use Filament\Widgets\Concerns\InteractsWithPageFilters;
use Guava\Calendar\Enums\CalendarViewType;
use Guava\Calendar\Filament\Actions\DeleteAction;
use Guava\Calendar\Filament\Actions\EditAction;
use Guava\Calendar\Filament\CalendarWidget;
use Guava\Calendar\ValueObjects\EventDropInfo;
use Guava\Calendar\ValueObjects\FetchInfo;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString;

class CalendarioWidget extends CalendarWidget
{
    use InteractsWithPageFilters;

    protected bool $useFilamentTimezone = false;

    protected bool $eventClickEnabled = true;

    protected CalendarViewType $calendarView = CalendarViewType::DayGridMonth;

    protected ?string $defaultEventClickAction = 'edit';

    protected bool $eventDragEnabled = true;

    protected string | HtmlString | null | bool $heading = null;

    protected function getEvents(FetchInfo $info): Collection | array | Builder
    {
...
    }

    protected function onEventDrop(EventDropInfo $info, Model | Evento $event): bool
    {
        try {
            $event->update([
                'start' => $info->event->getStart(),
                'end'   => $info->event->getEnd(),
            ]);
        } catch (\Throwable $th) {
            Notification::make()
                ->danger()
                ->title('Error al modificar el evento')
                ->body($th->getMessage())
                ->send();

            return false;
        }

        return true;
    }

    public function getOptions(): array
    {
        return [
            'headerToolbar' => [
                'start'  => 'title',
                'center' => 'dayGridMonth,dayGridWeek,listDay',
                'end'    => 'today prev,next',
            ],
        ];
    }
}

Change calendar view to dayGridWeek and move any event around.

Package Version

3.1.0

PHP Version

8.4.19

Laravel Version

12.56.0

Which operating systems does with happen with?

No response

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions