Skip to content

Commit

Permalink
add compact section view
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Oct 8, 2023
1 parent ce8c011 commit fed1997
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
32 changes: 32 additions & 0 deletions database/migrations/add_compact_to_section.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('sections', function (Blueprint $table) {
$table->boolean('compact')->default(0);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('sections', function (Blueprint $table) {
$table->dropColumn('compact');
});
}
};
1 change: 1 addition & 0 deletions src/BoltServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ protected function getMigrations(): array
'add_extensions_to_forms',
'add_extension_item_responses',
'alter_tables_constraints',
'add_compact_to_section',
];
}
}
5 changes: 5 additions & 0 deletions src/Concerns/Schemata.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ public static function getSectionsSchema(): array
->inline(false)
->visible(fn (Get $get) => $get('../../options.show-as') === 'page')
->label(__('show as aside')),

Toggle::make('compact')
->inline(false)
->visible(fn (Get $get) => $get('../../options.show-as') === 'page')
->label(__('compact section')),
]),
]),
]),
Expand Down
10 changes: 9 additions & 1 deletion src/Facades/Bolt.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LaraZeus\Bolt\Facades;

use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Section;
Expand Down Expand Up @@ -131,14 +132,21 @@ public static function prepareFieldsAndSectionToRender(Form $zeusForm, bool $inl
Grid::make()->columns($section->columns)->schema($fields),
]);
} else {
$sections[] = Section::make($section->name)
if($section->compact){
$sections[] = Fieldset::make($section->name)
->id($sectionId)
->schema($fields)
->columns($section->columns);
} else {
$sections[] = Section::make($section->name)
->id($sectionId)
->icon($section->icon ?? null)
->schema($fields)
->collapsible()
->aside(fn () => $section->aside)
->description($section->description)
->columns($section->columns);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Models/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* @property string $name
* @property string $columns
* @property string $description
* @property string $aside
* @property boolean $aside
* @property boolean $compact
*/
class Section extends Model
{
Expand Down

0 comments on commit fed1997

Please sign in to comment.