Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/event-modals
Browse files Browse the repository at this point in the history
  • Loading branch information
saade committed Jun 27, 2022
2 parents 2da36bf + 9b34d83 commit 11ab3b3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 2 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
];
}
Expand Down
11 changes: 10 additions & 1 deletion resources/views/fullcalendar.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@php($locale = strtolower(str_replace('_', '-', $this->getConfig()['locale'])))

<x-filament::widget>
<x-filament::card>
@if( $this::canCreate() )
Expand All @@ -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;
}
Expand All @@ -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));
});
})
'></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('filament-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 @@ -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;

Expand All @@ -16,6 +17,7 @@ class FullCalendarWidget extends Widget implements HasForms
CanManageEvents::getForms insteadof InteractsWithForms;
}

use CanRefreshEvents;
use FiresEvents;
use UsesConfig;

Expand Down

0 comments on commit 11ab3b3

Please sign in to comment.