diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a39910..c7232f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,21 @@ All notable changes to `filament-fullcalendar` will be documented in this file. +## v0.3.0 - 2022-06-27 + +### What's Changed + +- Update FiresEvents.php by @wychoong in https://github.com/saade/filament-fullcalendar/pull/8 +- feat: allow opening or not events in a new tab by @saade in https://github.com/saade/filament-fullcalendar/pull/12 +- feat: refresh calendar events by @saade in https://github.com/saade/filament-fullcalendar/pull/13 +- fix: convert laravel locale to fullcalendar compatible locale by @saade in https://github.com/saade/filament-fullcalendar/pull/14 + +### New Contributors + +- @wychoong made their first contribution in https://github.com/saade/filament-fullcalendar/pull/8 + +**Full Changelog**: https://github.com/saade/filament-fullcalendar/compare/v0.2.1...v0.3.0 + ## v0.2.1 - 2022-02-21 ## What's Changed diff --git a/README.md b/README.md index b4ba272..b7faf7a 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,8 @@ class CalendarWidget extends FullCalendarWidget 'id' => 2, 'title' => 'Meeting with Pamela', 'start' => now()->addDay(), - 'url' => MeetingResource::getUrl('view', ['record' => 2]) + 'url' => MeetingResource::getUrl('view', ['record' => 2]), + 'shouldOpenInNewTab' => true, ] ]; } diff --git a/resources/views/fullcalendar.blade.php b/resources/views/fullcalendar.blade.php index 4d25aaf..42ec4aa 100644 --- a/resources/views/fullcalendar.blade.php +++ b/resources/views/fullcalendar.blade.php @@ -1,3 +1,5 @@ +@php($locale = strtolower(str_replace('_', '-', $this->getConfig()['locale']))) + @if( $this::canCreate() ) @@ -17,11 +19,12 @@ document.addEventListener("DOMContentLoaded", function() { const config = @json($this->getConfig()); const events = @json($events); + const locale = "{{ $locale }}"; const eventClick = function ({ event, jsEvent }) { if( event.url ) { jsEvent.preventDefault(); - window.open(event.url, "_blank"); + window.open(event.url, event.extendedProps.shouldOpenInNewTab ? "_blank" : "_self"); return false; } @@ -38,12 +41,18 @@ const calendar = new FullCalendar.Calendar($el, { ...config, + locale, events, eventClick, eventDrop }); calendar.render(); + + window.addEventListener("filament-fullcalendar:refresh", (event) => { + calendar.removeAllEvents(); + event.detail.data.map(event => calendar.addEvent(event)); + }); }) '> diff --git a/src/Widgets/Concerns/CanRefreshEvents.php b/src/Widgets/Concerns/CanRefreshEvents.php new file mode 100644 index 0000000..f7a9dc7 --- /dev/null +++ b/src/Widgets/Concerns/CanRefreshEvents.php @@ -0,0 +1,11 @@ +dispatchBrowserEvent('filament-fullcalendar:refresh', ['data' => $this->getViewData()]); + } +} diff --git a/src/Widgets/FullCalendarWidget.php b/src/Widgets/FullCalendarWidget.php index bf5c70b..6c5a9ae 100644 --- a/src/Widgets/FullCalendarWidget.php +++ b/src/Widgets/FullCalendarWidget.php @@ -7,6 +7,7 @@ use Filament\Widgets\Widget; use Illuminate\View\View; use Saade\FilamentFullCalendar\Widgets\Concerns\CanManageEvents; +use Saade\FilamentFullCalendar\Widgets\Concerns\CanRefreshEvents; use Saade\FilamentFullCalendar\Widgets\Concerns\FiresEvents; use Saade\FilamentFullCalendar\Widgets\Concerns\UsesConfig; @@ -16,6 +17,7 @@ class FullCalendarWidget extends Widget implements HasForms CanManageEvents::getForms insteadof InteractsWithForms; } + use CanRefreshEvents; use FiresEvents; use UsesConfig;