Skip to content

Commit

Permalink
Introduce the methods to fetch resources from the livewire component …
Browse files Browse the repository at this point in the history
…in a dynamic way.
  • Loading branch information
felahdab committed Aug 27, 2024
1 parent 34f6cc5 commit cd6345d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/filament-fullcalendar.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion resources/js/filament-fullcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function fullcalendar({
'center': 'title',
'right': 'dayGridMonth,dayGridWeek,dayGridDay',
},
refetchResourcesOnNavigate: true,
plugins: plugins.map(plugin => availablePlugins[plugin]),
locale,
schedulerLicenseKey,
Expand Down Expand Up @@ -87,11 +88,16 @@ export default function fullcalendar({
if (!selectable) return;
this.$wire.onDateSelect(startStr, endStr, allDay, view, resource)
},
resources: (fetchInfo, successCallback, failureCallback) => {
this.$wire.fetchResources(fetchInfo)
.then(successCallback)
.catch(failureCallback);
},
})

calendar.render()

window.addEventListener('filament-fullcalendar--refresh', () => calendar.refetchEvents())
window.addEventListener('filament-fullcalendar--refresh', () => { calendar.refetchEvents(); calendar.refetchResources() } )
window.addEventListener('filament-fullcalendar--prev', () => calendar.prev())
window.addEventListener('filament-fullcalendar--next', () => calendar.next())
window.addEventListener('filament-fullcalendar--today', () => calendar.today())
Expand Down
5 changes: 5 additions & 0 deletions src/Widgets/FullCalendarWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function fetchEvents(array $info): array
return [];
}

public function fetchResources(array $info): array
{
return [];
}

public function getFormSchema(): array
{
return [];
Expand Down

0 comments on commit cd6345d

Please sign in to comment.