Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh calendar events #13

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions resources/views/fullcalendar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
));

calendar.render();

window.addEventListener("fullcalendar::refresh", event => {
calendar.removeAllEvents();
event.detail.data.map(event => calendar.addEvent(event));
});
})'>
</div>
</x-filament::card>
Expand Down
11 changes: 11 additions & 0 deletions src/Widgets/Concerns/CanRefreshEvents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Saade\FilamentFullCalendar\Widgets\Concerns;

trait CanRefreshEvents
{
protected function refreshEvents(): void
{
$this->dispatchBrowserEvent('fullcalendar::refresh', ['data' => $this->getViewData()]);
}
}
2 changes: 2 additions & 0 deletions src/Widgets/FullCalendarWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

use Filament\Widgets\Widget;
use Illuminate\View\View;
use Saade\FilamentFullCalendar\Widgets\Concerns\CanRefreshEvents;
use Saade\FilamentFullCalendar\Widgets\Concerns\FiresEvents;
use Saade\FilamentFullCalendar\Widgets\Concerns\UsesConfig;

class FullCalendarWidget extends Widget
{
use CanRefreshEvents;
use FiresEvents;
use UsesConfig;

Expand Down