Skip to content

Commit

Permalink
Merge pull request #13 from saade/feature/refresh-calendar
Browse files Browse the repository at this point in the history
feat: refresh calendar events
  • Loading branch information
saade authored Jun 27, 2022
2 parents 3389b6c + fad6468 commit 1951f90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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

0 comments on commit 1951f90

Please sign in to comment.