-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/next'
# Conflicts: # src/InlineEdit/InlineEdit.php # src/templates/datagrid.latte
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,9 @@ class InlineEdit | |
*/ | ||
protected bool $showNonEditingColumns = true; | ||
|
||
/** @var array */ | ||
Check failure on line 61 in src/InlineEdit/InlineEdit.php GitHub Actions / Codesniffer / Codesniffer (8.3)
|
||
protected array $dataAttributes = []; | ||
|
||
public function __construct(protected Datagrid $grid, protected ?string $primaryWhereColumn = null) | ||
{ | ||
$this->title = 'contributte_datagrid.edit'; | ||
|
@@ -94,6 +97,12 @@ public function renderButton(Row $row): Html | |
|
||
$this->tryAddIcon($a, $this->getIcon(), $this->getText()); | ||
|
||
if ($this->dataAttributes !== []) { | ||
foreach ($this->dataAttributes as $key => $value) { | ||
$a->data((string) $key, $value); | ||
} | ||
} | ||
|
||
$a->addText($this->text); | ||
|
||
if ($this->title !== null) { | ||
|
@@ -122,6 +131,12 @@ public function renderButtonAdd(): Html | |
|
||
$this->tryAddIcon($a, $this->getIcon(), $this->getText()); | ||
|
||
if ($this->dataAttributes !== []) { | ||
foreach ($this->dataAttributes as $key => $value) { | ||
$a->data((string) $key, $value); | ||
} | ||
} | ||
|
||
$a->addText($this->text); | ||
|
||
if ($this->title !== null) { | ||
|
@@ -199,4 +214,14 @@ public function showNonEditingColumns(): bool | |
return $this->showNonEditingColumns; | ||
} | ||
|
||
/** | ||
* @return static | ||
*/ | ||
public function setDataAttribute(string $key, mixed $value): self | ||
{ | ||
$this->dataAttributes[$key] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
} |