Releases: Kreyu/data-table-bundle
v0.26.1
What's Changed
This small release fixes the batch actions not working properly since 0.26.0 (#178). The URLs of the actions were not properly updated with the selected identifiers. The batch Stimulus controller was updated, therefore, remember to rebuild the assets if you're using build system.
Full Changelog: v0.26.0...v0.26.1
v0.26.0
What's Changed
Caution
This release contains breaking changes and deprecations.
Breaking Changes
- Renamed action types Twig block suffix from
value
tocontrol
by @alexandre-castelain (#163):
{# Before #}
{% block action_value %}{% endblock %}
{% block action_link_value %}{% endblock %}
{% block action_button_value %}{% endblock %}
{% block action_form_value %}{% endblock %}
{# After #}
{% block action_control %}{% endblock %}
{% block action_link_control %}{% endblock %}
{% block action_button_control %}{% endblock %}
{% block action_form_control %}{% endblock %}
This also includes custom action types with their own Twig blocks.
Deprecations
FormColumnType
is now deprecated. No replacement available.
Features
- Added dropdown action type - by @alexandre-castelain - see docs
- Added modal action type - by @alexandre-castelain (#110, #170) - see docs
- Added German translations - by @creiner (#156)
- Added HTML column type - see docs
- The column
value_translation_parameters
option now acceptscallable
value:
$builder->addColumn('firstName', options: [
'value_translation_parameters' => function (string $firstName, User $user) {
return [...];
},
]);
- The column value view now contains two additional variables - itself as
column
and its name asname
- Columns having
TranslatableInterface
as value is now automatically translated in export:
// Assume this data tables displays User entities
use Symfony\Contracts\Translation\TranslatableInterface;
use Symfony\Component\Translation\TranslatableMessage;
class User
{
public function __construct(
public TranslatableInterface $firstName,
) {
}
}
// This column displays User's first name and is exportable
$builder->addColumn('firstName', options: ['export' => true]);
// The row displays a User of name "John"
$rowView = new ValueRowView(data: new User(firstName: new TranslatableMessage('John'));
// Then export's ColumnValueView will be like so:
$view = $column->createExportValueView($rowView);
$view->vars['data']; // object(TranslatableMessage)
$view->vars['value']; // string(4) "John"
- The export value view now contains
data
variable, similar to regular value view, that represents value returned by property path or agetter
option, not formatted by theformatter
option:
// Assume this data tables displays User entities
use Kreyu\Bundle\DataTableBundle\ValueRowView;
use Kreyu\Bundle\DataTableBundle\Column\ColumnValueView;
class User
{
public function __construct(
public string $firstName,
) {
}
}
// This column displays User's first name and is exportable
$builder->addColumn('firstName', options: ['export' => true]);
// The row displays a User of name "John"
$rowView = new ValueRowView(data: new User(firstName: 'John'));
// Then export's ColumnValueView will be like so:
$view = $column->createExportValueView($rowView);
$view->vars['data']; // object(User)
$view->vars['value'] // string(4) "John"
Bug Fixes
- The Doctrine ORM filter types now properly allows overwriting the supported operators via option - by @alexandre-castelain (#168):
$builder->addFilter('id', NumericFilterType::class, [
'supported_operators' => [Operator::Equals, Operator::Contains],
'operator_selectable' => true,
]);
- The default property path inherited from column name is now properly set in column config (#148):
$builder->addColumn('firstName');
// Before:
$builder->getColumn('firstName')->getPropertyPath(); // null
$builder->getColumn('firstName')->getColumnConfig()->getPropertyPath(); // null
// After:
(string) $builder->getColumn('firstName')->getPropertyPath(); // string(9) "firstName"
(string) $dataTable->getColumn('firstName')->getConfig()->getPropertyPath(); // string(9) "firstName"
- The default sort property path inherited from column name is now properly set in column config (#149):
$builder->addColumn('firstName', options: ['sort' => true]);
// Before:
$builder->getColumn('firstName')->getSortPropertyPath(); // null
$builder->getColumn('firstName')->getColumnConfig()->getSortPropertyPath(); // null
// After:
(string) $builder->getColumn('firstName')->getSortPropertyPath(); // string(9) "firstName"
(string) $dataTable->getColumn('firstName')->getConfig()->getSortPropertyPath(); // string(9) "firstName"
- Setting the different column label for export is now properly respected (#147):
$builder->addColumn('name', TextColumnType::class, [
'export' => [
'label' => 'Full name',
],
]);
- Columns now inherit the
header_translation_domain
andvalue_translation_domain
options in export properly:
// Export will use column value translation domain and parameters:
$builder->addColumn('firstName', options: [
'value_translation_domain' => 'user',
'value_translation_parameters' => ['%first_name%' => 'John'];
]);
// This however, can be overwritten for export:
$builder->addColumn('firstName', options: [
'value_translation_domain' => 'user',
'value_translation_parameters' => ['%first_name%' => 'John'];
'export' => [
'value_translation_domain' => 'export_user',
'value_translation_parameters' => ['%first_name%' => 'Jane'];
]
]);
- Actions of the same name, but different context (global, row, batch) now use different ID of the confirmation modal:
// Assuming that the data table name is "user"
$builder
->addAction('foo', options: ['confirmation' => true])
->addRowAction('foo', options: ['confirmation' => true])
->addBatchAction('foo', options: ['confirmation' => true]);
Before, global and batch action confirmation modal would have the same ID: user-action-confirmation-foo
, which will result in invalid HTML. Now, the IDs will be different, using the new patterns:
- for global and batch action:
[data table name]--[context]-action--[action name]--confirmation
- for row action:
[data table name]--[context]-action--[action name]--confirmation--[row index]
Therefore:
- for global action, it will be
user--global-action--foo--confirmation
- for row action, it will be
user--row-action--foo--confirmation-0
,user--row-action--foo--confirmation-1
... (depends on row index) - for batch action, it will be
user--batch-action--foo--confirmation
New Contributors
Full Changelog: v0.25.7...v0.26.0
v0.25.8
v0.25.7
What's Changed
- Fix missing
theme
variable inblock
calls for proper theme inheritance by @Kreyu in #154 - Fix pagination per-page form not working properly with Turbo by @Kreyu in #155
- Remove default
ActionsColumnType
priority option value for better flexibility
Full Changelog: v0.25.6...v0.25.7
v0.25.6
v0.25.5
v0.25.4
What's changed
Fixed DateTimeColumnType
and DateColumnType
throwing exceptions during export due to incorrect formatter
option arguments
Full Changelog: v0.25.3...v0.25.4
v0.25.3
v0.25.2
What's Changed
Fixes missing initial pagination data, displaying all records at once when page parameter is not given
Full Changelog: v0.25.1...v0.25.2
v0.25.1
What's Changed
- Fixed request handler to manually submit forms regardless of request method
- Fixed "include all" export strategy not working
- Fixed sort direction visible on non-sortable column in profiler tab
- Fixed missing "total_count" array key in profiler tab
- Changed data table url query parameters getter logic to accept nullable sorting data and use DataTableInterface getters instead of views
- Changed initial pagination/sorting/filtration/personalization data getters to return null if initial nor persistence data is set
Full Changelog: v0.25.0...v0.25.1