diff --git a/README.md b/README.md index 6e4edfb..7e3f280 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,10 @@ public function onEventDrop($newEvent, $oldEvent, $relatedEvents): void Since [v1.0.0](https://github.com/saade/filament-fullcalendar/releases/tag/v1.0.0) you can create and edit events using a modal. -To change the modal size, override the `protected string $modalWidth` property in your widget. +To customise the modal, override the following properties in your widget: + +- `protected string $modalWidth` +- `protected string $modalLabel` The process of saving and editing the event is up to you, since this plugin does not rely on a Model to save the calendar events. @@ -240,11 +243,11 @@ public function editEvent(array $data): void * 1. $this->record_id * 2. $this->record */ - + # $this->record_id // the value is retrieved from event's id key // eg: Appointment::find($this->record); - + # $this->record // model instance is resolved by user defined resolveEventRecord() funtion. See example below // eg: $this->record->update($data); diff --git a/resources/views/components/create-event-modal.blade.php b/resources/views/components/create-event-modal.blade.php index dabd728..9350b0c 100644 --- a/resources/views/components/create-event-modal.blade.php +++ b/resources/views/components/create-event-modal.blade.php @@ -1,17 +1,21 @@ - - - {{ __('filament::resources/pages/create-record.title', ['label' => 'Event']) }} - + + + + + {{ __('filament::resources/pages/create-record.title', ['label' => $this->getModalLabel()]) }} + + - {{ $this->createEventForm }} - - {{ __('filament::resources/pages/create-record.form.actions.create.label') }} - + + + {{ __('filament::resources/pages/create-record.form.actions.create.label') }} + - - {{ __('filament::resources/pages/create-record.form.actions.cancel.label') }} - - - + + {{ __('filament::resources/pages/create-record.form.actions.cancel.label') }} + + + + diff --git a/resources/views/components/edit-event-modal.blade.php b/resources/views/components/edit-event-modal.blade.php index b802099..2b69708 100644 --- a/resources/views/components/edit-event-modal.blade.php +++ b/resources/views/components/edit-event-modal.blade.php @@ -1,17 +1,21 @@ - - - {{ __('filament::resources/pages/edit-record.title', ['label' => 'Event']) }} - + + + + + {{ __('filament::resources/pages/edit-record.title', ['label' => $this->getModalLabel()]) }} + + - {{ $this->editEventForm }} - - {{ __('filament::resources/pages/edit-record.form.actions.save.label') }} - + + + {{ __('filament::resources/pages/edit-record.form.actions.save.label') }} + - - {{ __('filament::resources/pages/edit-record.form.actions.cancel.label') }} - - - + + {{ __('filament::resources/pages/edit-record.form.actions.cancel.label') }} + + + + diff --git a/src/Widgets/Concerns/CanManageEvents.php b/src/Widgets/Concerns/CanManageEvents.php index ce1307c..7f8a035 100644 --- a/src/Widgets/Concerns/CanManageEvents.php +++ b/src/Widgets/Concerns/CanManageEvents.php @@ -12,12 +12,11 @@ trait CanManageEvents { use AuthorizesActions; + use CanManageModals; use CreateEventForm; use EditEventForm; use EvaluateClosures; - protected string $modalWidth = 'sm'; - public ?int $record_id = null; public ?Model $record = null; @@ -41,11 +40,6 @@ protected function getForms(): array ]; } - protected function getModalWidth(): string - { - return $this->modalWidth; - } - public function onEventClick($event): void { if (! static::canEdit($event)) { diff --git a/src/Widgets/Concerns/CanManageModals.php b/src/Widgets/Concerns/CanManageModals.php new file mode 100644 index 0000000..4f1834a --- /dev/null +++ b/src/Widgets/Concerns/CanManageModals.php @@ -0,0 +1,20 @@ +modalLabel; + } + + protected function getModalWidth(): string + { + return $this->modalWidth; + } +}