Skip to content

Commit

Permalink
feat: Grid gap/vertical mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Dec 18, 2024
1 parent 30583a3 commit f7466aa
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/Fields/Relationships/RelationRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use MoonShine\UI\Contracts\HasDefaultValueContract;
use MoonShine\UI\Contracts\RemovableContract;
use MoonShine\UI\Fields\Field;
use MoonShine\UI\Traits\Fields\HasVerticalMode;
use MoonShine\UI\Traits\Fields\WithDefaultValue;
use MoonShine\UI\Traits\Removable;
use MoonShine\UI\Traits\WithFields;
Expand All @@ -42,6 +43,7 @@ class RelationRepeater extends ModelRelationField implements
use WithFields;
use Removable;
use WithDefaultValue;
use HasVerticalMode;

protected string $view = 'moonshine::fields.json';

Expand All @@ -51,8 +53,6 @@ class RelationRepeater extends ModelRelationField implements

protected bool $resolveValueOnce = true;

protected bool $isVertical = false;

protected bool $isCreatable = true;

protected ?int $creatableLimit = null;
Expand Down Expand Up @@ -80,18 +80,6 @@ public function __construct(
);
}

public function vertical(Closure|bool|null $condition = null): static
{
$this->isVertical = value($condition, $this) ?? true;

return $this;
}

public function isVertical(): bool
{
return $this->isVertical;
}

public function creatable(
Closure|bool|null $condition = null,
?int $limit = null,
Expand Down Expand Up @@ -257,7 +245,7 @@ protected function getComponent(): TableBuilder
->cast($this->getResource()?->getCaster())
->when(
$this->isVertical(),
static fn (TableBuilderContract $table): TableBuilderContract => $table->vertical()
fn (TableBuilderContract $table): TableBuilderContract => $table->vertical($this->verticalTitleSpan, $this->verticalValueSpan)
)
->when(
! \is_null($this->modifyTable),
Expand Down

0 comments on commit f7466aa

Please sign in to comment.