refactor: reimplement course schedule edit and delete actions using Filament action objects directly in the view with enhanced UI.
This commit is contained in:
parent
bcdbbacf5c
commit
f6681cc5aa
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Filament\Actions\Cheerful\DeleteAction;
|
use App\Filament\Actions\Cheerful\DeleteAction;
|
||||||
use App\Models\CourseSchedule;
|
use App\Models\CourseSchedule;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
class DeleteScheduleAction extends DeleteAction
|
class DeleteScheduleAction extends DeleteAction
|
||||||
{
|
{
|
||||||
@ -19,6 +20,11 @@ protected function setUp(): void
|
|||||||
$this->record(function (array $arguments): CourseSchedule {
|
$this->record(function (array $arguments): CourseSchedule {
|
||||||
return CourseSchedule::findOrFail($arguments['schedule']);
|
return CourseSchedule::findOrFail($arguments['schedule']);
|
||||||
})
|
})
|
||||||
|
->label('Hapus')
|
||||||
|
->icon(Heroicon::OutlinedTrash)
|
||||||
|
->color('danger')
|
||||||
|
->iconButton()
|
||||||
|
->tooltip('Hapus')
|
||||||
->modalHeading('Hapus Jadwal Kuliah')
|
->modalHeading('Hapus Jadwal Kuliah')
|
||||||
->modalDescription('Apakah Anda yakin ingin menghapus jadwal ini? Tindakan ini tidak dapat dibatalkan.')
|
->modalDescription('Apakah Anda yakin ingin menghapus jadwal ini? Tindakan ini tidak dapat dibatalkan.')
|
||||||
->modalSubmitActionLabel('Hapus')
|
->modalSubmitActionLabel('Hapus')
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
use App\Filament\Actions\Cheerful\EditAction;
|
use App\Filament\Actions\Cheerful\EditAction;
|
||||||
use App\Models\CourseSchedule;
|
use App\Models\CourseSchedule;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
class EditScheduleAction extends EditAction
|
class EditScheduleAction extends EditAction
|
||||||
{
|
{
|
||||||
@ -17,9 +18,15 @@ protected function setUp(): void
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->record(function (array $arguments): CourseSchedule {
|
$this
|
||||||
return CourseSchedule::findOrFail($arguments['schedule']);
|
->label('Ubah')
|
||||||
})
|
->icon(Heroicon::OutlinedPencilSquare)
|
||||||
|
->color('warning')
|
||||||
|
->iconButton()
|
||||||
|
->tooltip('Ubah')
|
||||||
|
->record(function (array $arguments): CourseSchedule {
|
||||||
|
return CourseSchedule::findOrFail($arguments['schedule']);
|
||||||
|
})
|
||||||
->modalHeading('Ubah Jadwal Kuliah')
|
->modalHeading('Ubah Jadwal Kuliah')
|
||||||
->modalSubmitActionLabel('Simpan')
|
->modalSubmitActionLabel('Simpan')
|
||||||
->modalCancelActionLabel('Batal')
|
->modalCancelActionLabel('Batal')
|
||||||
|
|||||||
@ -81,13 +81,13 @@ protected function getHeaderActions(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function editScheduleAction(): Action
|
public function editScheduleAction(): Action
|
||||||
{
|
{
|
||||||
return EditScheduleAction::make()
|
return EditScheduleAction::make()
|
||||||
->visible(fn () => auth()->user()->can('Update:CourseSchedule'));
|
->visible(fn () => auth()->user()->can('Update:CourseSchedule'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function deleteScheduleAction(): Action
|
public function deleteScheduleAction(): Action
|
||||||
{
|
{
|
||||||
return DeleteScheduleAction::make()
|
return DeleteScheduleAction::make()
|
||||||
->visible(fn () => auth()->user()->can('Delete:CourseSchedule'));
|
->visible(fn () => auth()->user()->can('Delete:CourseSchedule'));
|
||||||
|
|||||||
@ -106,19 +106,14 @@ class="text-[11px] font-semibold tracking-wide text-gray-400 uppercase">
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
@canAny(['Update:CourseSchedule', 'Delete:CourseSchedule'])
|
||||||
class="flex items-center justify-end gap-1 pt-3 border-t border-gray-100 dark:border-gray-800">
|
<div
|
||||||
<x-filament::button size="xs" color="warning" tooltip="Ubah"
|
class="flex items-center justify-end gap-1 pt-3 border-t border-gray-100 dark:border-gray-800">
|
||||||
variant="primary"
|
{{ ($this->editScheduleAction)(['schedule' => $schedule->id]) }}
|
||||||
wire:click="mountAction('editSchedule', { schedule: {{ $schedule->id }} })">
|
|
||||||
<x-heroicon-m-pencil-square class="w-4 h-4" />
|
|
||||||
</x-filament::button>
|
|
||||||
|
|
||||||
<x-filament::button size="xs" color="danger" tooltip="Hapus"
|
{{ ($this->deleteScheduleAction)(['schedule' => $schedule->id]) }}
|
||||||
wire:click="mountAction('deleteSchedule', { schedule: {{ $schedule->id }} })">
|
</div>
|
||||||
<x-heroicon-m-trash class="w-4 h-4" />
|
@endcanAny
|
||||||
</x-filament::button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user