feat: add SelectAllCoursesAction to course selection field in study group page
This commit is contained in:
parent
758df75156
commit
6277d50cc0
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages\Learning\StudyGroup\Actions;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
|
||||
class SelectAllCoursesAction extends Action
|
||||
{
|
||||
public static function getDefaultName(): ?string
|
||||
{
|
||||
return 'selectAllCourse';
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this
|
||||
->icon('heroicon-m-check-circle')
|
||||
->tooltip('Pilih/Hapus Semua Mata Kuliah')
|
||||
->action(function (Select $component) {
|
||||
$options = array_keys($component->getOptions());
|
||||
$state = $component->getState() ?? [];
|
||||
|
||||
if (count($state) === count($options)) {
|
||||
$component->state([]);
|
||||
} else {
|
||||
$component->state($options);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
use App\Filament\Pages\Learning\StudyGroup\Actions\CreateStudyGroupAction;
|
||||
use App\Filament\Pages\Learning\StudyGroup\Actions\DeleteStudyGroupAction;
|
||||
use App\Filament\Pages\Learning\StudyGroup\Actions\EditStudyGroupAction;
|
||||
use App\Filament\Pages\Learning\StudyGroup\Actions\SelectAllCoursesAction;
|
||||
use App\Models\Course;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudyGroup;
|
||||
@ -171,7 +172,8 @@ public function studyGroupFormSchema(): array
|
||||
->searchable()
|
||||
->required()
|
||||
->live()
|
||||
->columnSpanFull(),
|
||||
->columnSpanFull()
|
||||
->suffixAction(SelectAllCoursesAction::make()),
|
||||
|
||||
TextInput::make('name')
|
||||
->label('Nama Kelompok')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user