Skip to content

Commit

Permalink
add disableActions option to repeater
Browse files Browse the repository at this point in the history
  • Loading branch information
13twelve committed Jan 14, 2025
1 parent 44e993e commit 23a2fe2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/js/components/Repeater.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:block="block"
:index="index"
:withHandle="allowSortable && draggable"
:withActions="allowActions"
:size="blockSize"
:opened="opened"
>
Expand Down Expand Up @@ -114,6 +115,10 @@
type: Boolean,
default: true
},
allowActions: {
type: Boolean,
default: true
},
max: {
type: [Number, null],
required: false,
Expand Down
8 changes: 8 additions & 0 deletions src/Services/Forms/Fields/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Repeater extends BaseFormField
protected bool $buttonAsLink = false;
protected bool $allowCreate = true;
protected bool $allowSortable = true;
protected bool $allowActions = true;
protected ?string $relation = null;
protected ?array $browserModule = null;

Expand Down Expand Up @@ -71,6 +72,13 @@ public function allowSortable(bool $allowSortable = true): static
return $this;
}

public function allowActions(bool $allowActions = true): static
{
$this->allowActions = $allowActions;

return $this;
}

public function browserModule(?array $browserModule = null): static
{
$this->browserModule = $browserModule;
Expand Down
9 changes: 9 additions & 0 deletions src/Services/Forms/InlineRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function __construct(
private ?string $label = null,
private bool $allowCreate = true,
private bool $allowSortable = true,
private bool $allowActions = true,
private ?string $relation = null,
private ?bool $allowBrowse = false,
private ?array $browser = null,
Expand Down Expand Up @@ -103,6 +104,13 @@ public function disableSortable(bool $disableSortable = true): static
return $this;
}

public function disableActions(bool $disableActions = true): static
{
$this->allowActions = ! $disableActions;

return $this;
}

/**
* The name of the module to use for selecting existing records. Not for json repeaters.
*/
Expand Down Expand Up @@ -216,6 +224,7 @@ public function render(): View
->type($this->getRenderName())
->allowCreate($this->allowCreate)
->allowSortable($this->allowSortable)
->allowActions($this->allowActions)
->relation($this->relation ?? null)
->browserModule($this->allowBrowse ? $this->browser : null);

Expand Down
1 change: 1 addition & 0 deletions src/View/Components/Fields/Repeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct(
public ?int $max = null,
public bool $allowCreate = true,
public bool $allowSortable = true,
public bool $allowActions = true,
public ?string $relation = null,
public ?array $browserModule = null,
// Generic
Expand Down
1 change: 1 addition & 0 deletions views/partials/form/_repeater.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@if ($relation) relation="{{$relation}}" @endif
:allow-create="{{$allowCreate ? 'true' : 'false'}}"
:allow-sortable="{{$allowSortable ? 'true' : 'false'}}"
:allow-actions="{{$allowActions ? 'true' : 'false' }}"
></a17-repeater>

@unless($renderForBlocks)
Expand Down

0 comments on commit 23a2fe2

Please sign in to comment.