diff --git a/art/fullcalendar-widget.png:Zone.Identifier b/art/fullcalendar-widget.png:Zone.Identifier deleted file mode 100644 index a831910..0000000 --- a/art/fullcalendar-widget.png:Zone.Identifier +++ /dev/null @@ -1,3 +0,0 @@ -[ZoneTransfer] -LastWriterPackageFamilyName=Microsoft.ScreenSketch_8wekyb3d8bbwe -ZoneId=3 diff --git a/resources/views/fullcalendar.blade.php b/resources/views/fullcalendar.blade.php index 688c6c7..81553a8 100644 --- a/resources/views/fullcalendar.blade.php +++ b/resources/views/fullcalendar.blade.php @@ -68,6 +68,16 @@ @endif } + @if($this->config('saveState', false)) + const key = "{{ $this->getKey() }}"; + const initialView = + localStorage.getItem("fullcalendar.view." + key) ?? + @json($this->config('initialView')); + const initialDate = + localStorage.getItem("fullcalendar.date." + key) ?? + @json($this->config('initialDate')); + @endif + const calendar = new FullCalendar.Calendar($el, { ...config, locale, @@ -79,7 +89,15 @@ eventSources:[ { events }, fetchEvents - ] + ], + @if($this->config('saveState', false)) + initialView: initialView ?? undefined, + initialDate: initialDate ?? undefined, + datesSet: function ({start, view}) { + localStorage.setItem("fullcalendar.view." + key, view.type); + localStorage.setItem("fullcalendar.date." + key, start.toISOString()); + }, + @endif }); calendar.render(); diff --git a/src/Widgets/FullCalendarWidget.php b/src/Widgets/FullCalendarWidget.php index c563801..a8a5d0e 100644 --- a/src/Widgets/FullCalendarWidget.php +++ b/src/Widgets/FullCalendarWidget.php @@ -17,7 +17,6 @@ class FullCalendarWidget extends Widget implements HasForms use InteractsWithForms, CanManageEvents { CanManageEvents::getForms insteadof InteractsWithForms; } - use CanRefreshEvents; use CanFetchEvents; use FiresEvents; @@ -39,4 +38,9 @@ public function render(): View 'events' => $this->getViewData(), ]); } + + public function getKey(): string + { + return $this->key ?? 'default'; + } }