diff --git a/database/migrations/create_sections_table.php.stub b/database/migrations/create_sections_table.php.stub index 0049127e..2e064bf7 100644 --- a/database/migrations/create_sections_table.php.stub +++ b/database/migrations/create_sections_table.php.stub @@ -22,6 +22,7 @@ return new class extends Migration $table->text('description')->nullable(); $table->string('icon')->nullable(); $table->boolean('aside')->default(0); + $table->boolean('grid')->default(0); $table->timestamps(); $table->softDeletes(); }); diff --git a/resources/lang/de.json b/resources/lang/de.json index a4e840de..acca373d 100644 --- a/resources/lang/de.json +++ b/resources/lang/de.json @@ -115,6 +115,8 @@ "From 1-12": "Von 1-12", "Section icon": "Abschnittssymbol", "show as aside": "Als Beilage anzeigen", + "Use Grid": "Raster verwenden", + "Use a Grid instead of a Section": "Ein Grid statt einem Abschnitt verwenden", "Show As Tabs": "Als Tabs anzeigen", "Show the Form as Tabs": "Das Formular als Tabs anzeigen", "Show the form as": "Formular anzeigen als", diff --git a/resources/lang/en.json b/resources/lang/en.json index 89637038..43c7b18a 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -114,7 +114,9 @@ "Section Details": "Section Details", "From 1-12": "From 1-12", "Section icon": "Section icon", - "show as aside": "show as aside", + "show as aside": "Show as aside", + "Use Grid": "Use Grid", + "Use a Grid instead of a Section": "Use a Grid instead of a Section", "Show As Tabs": "Show As Tabs", "Show the Form as Tabs": "Show the Form as Tabs", "Show the form as": "Show the form as", diff --git a/resources/lang/es.json b/resources/lang/es.json index 89ced7d4..0bc0a40e 100644 --- a/resources/lang/es.json +++ b/resources/lang/es.json @@ -115,6 +115,8 @@ "From 1-12": "De 1-12", "Section icon": "Ícono de la Sección", "show as aside": "mostrar al lado", + "Use Grid": "Usar Grilla", + "Use a Grid instead of a Section": "Utilice una cuadrícula en lugar de una sección", "Show As Tabs": "Mostrar como Pestañas", "Show the Form as Tabs": "Mostrar el Formulario como Pestañas", "Show the form as": "Mostrar el formulario como", diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 40afb82f..5bb31f75 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -115,6 +115,8 @@ "From 1-12": "De 1 à 12", "Section icon": "Icône de la section", "show as aside": "afficher comme une barre latérale", + "Use Grid": "Utiliser la grille", + "Use a Grid instead of a Section": "Utiliser une Grille au lieu d'une Section", "Show As Tabs": "Afficher comme des onglets", "Show the Form as Tabs": "Afficher le formulaire sous forme d'onglets", "Show the form as": "Afficher le formulaire comme", diff --git a/src/Concerns/Designer.php b/src/Concerns/Designer.php index 0d6a6d19..d9a035f4 100644 --- a/src/Concerns/Designer.php +++ b/src/Concerns/Designer.php @@ -2,15 +2,16 @@ namespace LaraZeus\Bolt\Concerns; -use Filament\Forms\Components\Section; -use Filament\Forms\Components\Tabs; -use Filament\Forms\Components\Tabs\Tab; -use Filament\Forms\Components\Wizard; -use Filament\Forms\Components\Wizard\Step; use Filament\Forms\Get; +use LaraZeus\Bolt\Models\Form; use LaraZeus\Bolt\Facades\Bolt; +use Filament\Forms\Components\Grid; +use Filament\Forms\Components\Tabs; +use Filament\Forms\Components\Wizard; use LaraZeus\Bolt\Facades\Extensions; -use LaraZeus\Bolt\Models\Form; +use Filament\Forms\Components\Section; +use Filament\Forms\Components\Tabs\Tab; +use Filament\Forms\Components\Wizard\Step; use LaraZeus\Bolt\Models\Section as ZeusSection; trait Designer @@ -97,7 +98,7 @@ private static function drawFields(ZeusSection $section, bool $inline, bool $has return $fields; } - private static function drawSections(Form $zeusForm, ZeusSection $section, array $fields): Tab | Step | Section + private static function drawSections(Form $zeusForm, ZeusSection $section, array $fields): Tab | Step | Section | Grid { if (optional($zeusForm->options)['show-as'] === 'tabs') { $component = Tab::make($section->name) @@ -108,6 +109,8 @@ private static function drawSections(Form $zeusForm, ZeusSection $section, array // ->live() ->description($section->description) ->icon($section->icon ?? null); + } elseif ($section->grid == true) { + $component = Grid::make($section->name); } else { $component = Section::make($section->name) // ->live() diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index e38a76f9..c1b5f2aa 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -79,15 +79,22 @@ protected static function sectionOptionsFormSchema(array $formOptions, array $al 'lg' => 3, '2xl' => 5, ]) + ->visible(fn (Get $get) => $formOptions['show-as'] === 'page' && $get('grid') === false) ->label(__('Section icon')), Toggle::make('aside') ->default(false) - ->visible($formOptions['show-as'] === 'page') + ->visible(fn (Get $get) => $formOptions['show-as'] === 'page' && $get('grid') === false) ->label(__('show as aside')), - Toggle::make('compact') + Toggle::make('grid') + ->live() ->default(false) ->visible($formOptions['show-as'] === 'page') - ->label(__('compact section')), + ->label(__('Use Grid')) + ->hint('Use a Grid instead of a Section'), + Toggle::make('compact') + ->default(false) + ->visible(fn (Get $get) => $formOptions['show-as'] === 'page' && $get('grid') === false) + ->label(__('Compact section')), ]), self::visibility($allSections), Bolt::getCustomSchema('section') ?? [], @@ -439,6 +446,7 @@ public static function getSectionsSchema(): array Hidden::make('compact')->default(0)->nullable(), Hidden::make('aside')->default(0)->nullable(), + Hidden::make('grid')->default(0)->nullable(), Hidden::make('icon')->nullable(), Hidden::make('columns')->default(1)->nullable(), Hidden::make('description')->nullable(), diff --git a/src/Models/Section.php b/src/Models/Section.php index f26423bc..7ba9071f 100644 --- a/src/Models/Section.php +++ b/src/Models/Section.php @@ -17,6 +17,7 @@ * @property string $columns * @property string $description * @property bool $aside + * @property bool $grid * @property bool $compact * @property mixed $fields */ diff --git a/tests/FormsTest.php b/tests/FormsTest.php index 61407703..8d8ab5f6 100644 --- a/tests/FormsTest.php +++ b/tests/FormsTest.php @@ -132,6 +132,7 @@ 'name' => 'sdf', 'columns' => 2, 'aside' => 0, + 'grid' => 0, 'fields' => [ [ 'name' => 'sdf', @@ -176,6 +177,7 @@ ]), 'columns' => 2, 'aside' => 0, + 'grid' => 0, ]); assertDatabaseHas(Field::class, [ @@ -244,6 +246,7 @@ 'name' => 'sdf', 'columns' => 2, 'aside' => 0, + 'grid' => 0, 'compact' => 0, 'fields' => [ [ diff --git a/tests/migrations/004_create_sections_table.php b/tests/migrations/004_create_sections_table.php index 29aafe39..e0911072 100644 --- a/tests/migrations/004_create_sections_table.php +++ b/tests/migrations/004_create_sections_table.php @@ -22,6 +22,7 @@ public function up() $table->text('description')->nullable(); $table->string('icon')->nullable(); $table->boolean('aside')->default(0); + $table->boolean('grid')->default(0); $table->boolean('compact')->default(0); $table->text('options')->nullable(); $table->timestamps();