Merge branch 'develop'
This commit is contained in:
commit
895de8a445
3 changed files with 28 additions and 1 deletions
|
|
@ -11,6 +11,7 @@
|
|||
* feat(builder): allow to add block between children
|
||||
* feat(builder): improve UI to add new block
|
||||
* feat(settings): allow to edit a setting in plain page
|
||||
* feat(crud/index): allow to define row attributes
|
||||
|
||||
## [v1.26.0] - 2025-03-17
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Core\Crud;
|
||||
|
||||
use App\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* class CrudConfiguration.
|
||||
*
|
||||
|
|
@ -28,6 +30,7 @@ class CrudConfiguration
|
|||
protected string $sortableCollectionProperty = 'sortOrder';
|
||||
protected ?string $defaultLocale = null;
|
||||
protected array $showActions = [];
|
||||
protected array $listRowAttributes = [];
|
||||
|
||||
protected static $self;
|
||||
|
||||
|
|
@ -247,6 +250,26 @@ class CrudConfiguration
|
|||
return $this->viewDatas[$context][$name] ?? $defaultValue;
|
||||
}
|
||||
|
||||
public function setListRowAttributes(string $context, array $attributes): self
|
||||
{
|
||||
$this->listRowAttributes[$context] = $attributes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getListRowAttributes(string $context, EntityInterface $entity): array
|
||||
{
|
||||
$attributes = $this->listRowAttributes[$context] ?? [];
|
||||
|
||||
foreach ($attributes as $key => $attribute) {
|
||||
if (is_callable($attribute)) {
|
||||
$attributes[$key] = $attribute($entity);
|
||||
}
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
// --
|
||||
|
||||
public function setField(string $context, string $label, string $field, array $options): self
|
||||
|
|
|
|||
|
|
@ -193,7 +193,10 @@
|
|||
{%- endif -%}
|
||||
{%- endset -%}
|
||||
|
||||
<tr {{ dataSortableItem|raw }} {% if configuration.doubleClick(context) %}data-dblclick="{{- dbClick -}}"{% endif %} class="{{ loop.index is odd ? 'is-odd' : 'is-even' }}">
|
||||
{% set rowAttributes = configuration.listRowAttributes(context, item) %}
|
||||
{% set rowClasses = rowAttributes['class']|default('') %}
|
||||
|
||||
<tr {{ dataSortableItem|raw }} {% if configuration.doubleClick(context) %}data-dblclick="{{- dbClick -}}"{% endif %} class="{{ loop.index is odd ? 'is-odd' : 'is-even' }} {{ rowClasses }}" {% for attr, attrValue in rowAttributes %}{% if attr != 'class' %}{{ attr }}={{ attrValue }} {% endif %}{% endfor %}>
|
||||
{% if configuration.hasBatchAction(context) %}
|
||||
<td class="crud-batch-column">
|
||||
<input type="checkbox" class="batch_form" name="batch[items][{{ loop.index }}]" form="form-batch" value="{{ loop.index }}">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue