Skip to content

Commit

Permalink
Refactor form columns configuration for Image and Title blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
marco76tv committed Feb 5, 2024
1 parent 95c0bac commit 7ef3ee3
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 48 deletions.
7 changes: 0 additions & 7 deletions Filament/Blocks/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,11 @@ public static function make(
TextInput::make('alt')
->columnSpanFull(),

<<<<<<< HEAD
TextInput::make('caption')
->columnSpanFull(),
]
)
->columns('form' === $context ? 2 : 1);
=======
TextInput::make('caption')
->columnSpanFull(),
])
->columns($context === 'form' ? 2 : 1);
>>>>>>> ef98e3f (rebase 4)
}

public static function getRatios(): array
Expand Down
12 changes: 0 additions & 12 deletions Filament/Blocks/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public static function make(
TextInput::make('text')
->required(),

<<<<<<< HEAD
Select::make('level')
->options(
[
Expand All @@ -33,16 +32,5 @@ public static function make(
]
)
->columns('form' === $context ? 2 : 1);
=======
Select::make('level')
->options([
'h2' => 'h2',
'h3' => 'h3',
'h4' => 'h4',
])
->afterStateHydrated(static fn ($state, $set) => $state || $set('level', 'h2')),
])
->columns($context === 'form' ? 2 : 1);
>>>>>>> ef98e3f (rebase 4)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public function storeChildItem(Model $record, array $data): void
{
$parent = data_get($this, $this->mountedChildTarget);
$data['parent_id'] = $parent['id'];
<<<<<<< HEAD
/*
dddx([
'data' => $data,
Expand All @@ -162,19 +161,6 @@ public function storeChildItem(Model $record, array $data): void

$new_id = app(GetNewInventoryNumberAction::class)->execute($record::class, $data['parent_id']);
$data['id'] = $new_id;
=======
if (Str::contains($data['parent_id'], '-')) {
$last_son = $record::class::where('parent_id', $data['parent_id'])
->orderByDesc('id')
->first();
if ($last_son == null) {
$data['id'] = $data['parent_id'].'-1';
} else {
$new_id = intval(Str::afterLast($last_son['id'], '-')) + 1;
$data['id'] = $data['parent_id'].'-'.$new_id;
}
}
>>>>>>> ef98e3f (rebase 4)
$row = $record::class::create($data);
$data = $row->toArray();
$data['id'] = $new_id;
Expand Down Expand Up @@ -238,7 +224,7 @@ function (array $data, $record): void {
}
)
->requiresConfirmation()
->visible($this->mountedItem != null),
->visible(null != $this->mountedItem),
Action::make('item')
->mountUsing(
function (ComponentContainer $form): void {
Expand Down
15 changes: 1 addition & 14 deletions View/Components/Render/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\Vi
$this->tpl = $this->block['type'];

$views = ['ui::components.blocks.'.$this->tpl];
if ($this->model !== null) {
if (null !== $this->model) {
$module = app(GetModuleNameFromModelAction::class)->execute($this->model);
$views[] = strtolower($module).'::components.blocks.'.$this->tpl;
}
Expand All @@ -37,21 +37,8 @@ public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\View\Vi
* @phpstan-var view-string|null
*/
$view = Arr::first($views, static fn (string $view) => view()->exists($view));
<<<<<<< HEAD
if (null === $view) {
<<<<<<< HEAD
throw new \Exception('none of these views exists ['.implode(', '.chr(13), $views).']');
=======
<<<<<<< HEAD
throw new Exception('none of these views exists ['.implode(', '.chr(13),$views).']');
//dddx([$views, $this->model]);
=======
=======
if ($view === null) {
>>>>>>> 1fc11df (Dusting)
dddx([$views, $this->model]);
>>>>>>> 760233f (Lint)
>>>>>>> ef98e3f (rebase 4)
}
$view_params = $this->block['data'] ?? [];

Expand Down

0 comments on commit 7ef3ee3

Please sign in to comment.