Skip to content

Releases: Kreyu/data-table-bundle

v0.27.0

09 Feb 15:57
101fb07
Compare
Choose a tag to compare
v0.27.0 Pre-release
Pre-release

What's Changed

⚡ This release is all about icons and theming improvements.

image

  • Added IconColumnType that renders an icon
  • Added icon option to base ActionType to define an icon instead of icon_attr
  • Added icon themes that support Bootstrap and Tabler icons, both via webfont and Symfony UX Icons 🚀 (see docs)
  • Added attributes macro to the base.html.twig theme to render HTML attributes from an array (see docs)
  • Added data_table_theme_block Twig function to render a block through the theme hierarchy (see docs)
  • Changed the way themes are loaded - now each theme overrides the previous one, like in Symfony Form (see docs)
  • Added with_caret option to DropdownActionType to allow rendering the dropdown without a caret (see docs)
  • Improved built-in themes
    • In multiple blocks, the class attribute gets merged instead of being overridden completely
    • The Bootstrap 5 and Tabler themes are now more consistent with each other
    • Removed the action_control_icon block
  • Improved documentation about theming
  • Added missing Catalan & Spanish translations by @davidnectarestudio in #183

Full Changelog: v0.26.2...v0.27.0

Icon Themes

You should set an additional icon theme based on the icon set you're using in the application:

Icon themes are separate templates to allow using different icon sets.

Webfont icon themes render icons as <i> elements with CSS classes.
For example, Bootstrap's check icon will be rendered as <i class="bi bi-check"></i>

The UX icon themes refer to the Symfony UX Icons, which requires
the symfony/ux-icons package. Each icon has to be imported to the project separately, for example:

symfony console ux:icon:import bi:check

When using the generic icons_webfont.html.twig, you are expected to provide full icon class names manually,
for example bi bi-check instead of simple check.

Using the icons_ux.html.twig enables you to use the locally stored icons, for example:

  • user-profile will render icon from assets/icons/user-profile.svg
  • admin:user-profile will render icon from assets/icons/admin/user-profile.svg

For more details about how UX icons are loaded, see Symfony UX Icons documentation.

Setting Action Icon

In actions, you should define the icon using the icon option instead of icon_attr:

use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;

// Before 😒
// - unnecessary nesting
// - coupled to specific icon set
// - does not work with Symfony UX icons
$builder->addRowAction('status', ButtonActionType::class, [
    'icon_attr' => [
        'class' => 'ti ti-eye',
    ],
]);

// After 😎
// - simple option
// - icon set agnostic (kinda)
// - supports Symfony UX icons
$builder->addRowAction('status', ButtonActionType::class, [
    'icon' => 'eye',
]);

You can still use icon_attr to define additional attributes for the icon, like class:

use Kreyu\Bundle\DataTableBundle\Action\Type\ButtonActionType;

$builder->addRowAction('status', ButtonActionType::class, [
    'icon' => 'eye',
    'icon_attr' => [
        'class' => 'text-primary',
    ],
]);

New Contributors

Sponsoring

Do you like the bundle and find it useful? The "Sponsor" button is now available for the repository!

Thank you for all your support.

v0.26.2

22 Jan 17:16
Compare
Choose a tag to compare
v0.26.2 Pre-release
Pre-release

What's Changed

Fixed header_attr class attribute lost on sorted column (#177). Now the given classes are properly merged together with the theme ones.

Full Changelog: v0.26.1...v0.26.2

v0.26.1

21 Jan 18:28
Compare
Choose a tag to compare
v0.26.1 Pre-release
Pre-release

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

18 Jan 14:27
Compare
Choose a tag to compare
v0.26.0 Pre-release
Pre-release

What's Changed

Caution

This release contains breaking changes and deprecations.

Breaking Changes

{# 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

$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 as name
  • 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 a getter option, not formatted by the formatter 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 and value_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

14 Jan 12:01
Compare
Choose a tag to compare
v0.25.8 Pre-release
Pre-release

What's Changed

  • Fixed exception when rendering active filter with iterable value (partially fixes #151)
  • Added missing data-turbo-frame="_self" attribute to filter "clear" and "clear all" buttons

v0.25.7

29 Nov 20:16
7e78e53
Compare
Choose a tag to compare
v0.25.7 Pre-release
Pre-release

What's Changed

  • Fix missing theme variable in block 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

22 Nov 18:34
102a326
Compare
Choose a tag to compare
v0.25.6 Pre-release
Pre-release

What's Changed

  • [Docs] Fixed modal action docs by @easis in #146
  • [Bugfix] Browser back button not working properly with state Stimulus controller enabled #125

Full Changelog: v0.25.5...v0.25.6

v0.25.5

19 Nov 13:38
Compare
Choose a tag to compare
v0.25.5 Pre-release
Pre-release

What's Changed

Fixed incorrect behavior of date and date time related filters due to wrong url query parameters #145

Full Changelog: v0.25.4...v0.25.5

v0.25.4

19 Nov 12:58
a9e479c
Compare
Choose a tag to compare
v0.25.4 Pre-release
Pre-release

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

18 Nov 09:17
6801883
Compare
Choose a tag to compare
v0.25.3 Pre-release
Pre-release

What's Changed

Reverts 7c83d96 change that made initial data getters return null, which created unexpected issues with personalization.

Full Changelog: v0.25.2...v0.25.3