Skip to content

Commit

Permalink
[ENH] add header_attr for header attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
n3o77 committed Jul 17, 2024
1 parent 0bb7fd1 commit 2b5b8d8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/ColumnType/AbstractColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function configureOptions(OptionsResolver $resolver): void
'isSortable' => true,
'isMapped' => true,
'attr' => [],
'header_attr' => [],
'template' => $this->template,
'meta' => [],
'permissions' => [],
Expand Down Expand Up @@ -70,6 +71,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setAllowedTypes('label', ['null', 'string']);
$resolver->setAllowedTypes('isSortable', 'bool');
$resolver->setAllowedTypes('attr', 'array');
$resolver->setAllowedTypes('header_attr', 'array');
$resolver->setAllowedTypes('template', ['null', 'string']);
$resolver->setAllowedTypes('meta', 'array');
$resolver->setAllowedTypes('permissions', 'array');
Expand Down
1 change: 1 addition & 0 deletions src/ColumnType/BadgeColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults([
'classPrefix' => null,
'attr' => ['class' => 'text-center'],
'header_attr' => ['class' => 'text-center'],
]);
$resolver->setAllowedTypes('classPrefix', ['null', 'string']);
}
Expand Down
1 change: 1 addition & 0 deletions src/ColumnType/LocalizedDateColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function configureOptions(OptionsResolver $resolver): void

$resolver->setDefaults([
'attr' => ['class' => 'text-right'],
'header_attr' => ['class' => 'text-right'],
'date_format' => 'medium',
'time_format' => 'medium',
'locale' => null,
Expand Down
1 change: 1 addition & 0 deletions src/ColumnType/NumberColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults([
'nullAsZero' => false,
'attr' => ['class' => 'text-right'],
'header_attr' => ['class' => 'text-right'],
'formatOptions' => [],
'style' => 'decimal',
'aggregates' => [],
Expand Down
7 changes: 4 additions & 3 deletions src/Resources/views/column_header.html.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{# @var column \Unlooped\GridBundle\ColumnType\AbstractColumnType #}
{# @var column \Unlooped\GridBundle\Column\Column #}

{% if column.isSortable and pagination.isSorted(column.field) %}
{% set attr = column.attr|merge({class: (column.attr.class|default('') ~ ' sorted sorted-' ~ pagination.direction)|trim}) %}
{% set attr = column.header_attr|merge({class: (column.header_attr.class|default('') ~ ' sorted sorted-' ~ pagination.direction)|trim}) %}
{% else %}
{% set attr = column.attr %}
{% set attr = column.header_attr %}
{% endif %}

{% block grid_column %}
Expand Down

0 comments on commit 2b5b8d8

Please sign in to comment.