ui
ui copied to clipboard
CardDeck/general addUserAction icon support
Today, the UserActions are all automatically rendered based on the UserAction's name, so 'Edit', 'Delete' or the like. The 'name' by nature becomes then also the caption for all buttons. In Cruds, the 'Edit' UserActions are shown by an edit icon, in Cards not.
Generally, it would be helpful if there is an easy and direct way to also set the 'icon' for a UserAction that Ui is taking. Consider this as an alternative to describe the UserAction instead of the name. The name is as good or bad to describe it as caption or an icon would be. To my knowledge, this was easily possible in earlier versions of the UserActions, but was removed and transferred to ExecutionFactory - this makes it very time-consuming and complex, to add a simple UserAction like 'Archive entry' - it should be as easy as:
$this->addUserAction('Archive', [
'confirmation' => 'Are you sure you want to archive email?',
'icon' => 'mailbox',
'caption' => '', // Show only the icon, and not the "Archive" text
'callback' => function ($entity) {
$entity->save(['archived' => true]);
return 'Email successfully archived';
},
]);
slightly related with https://github.com/atk4/ui/issues/1848, I highly support unified look & feel (and impl.)
Initially, I thought this is supported, but not honored by CardDeck.
The UserAction is a class defined in atk4/data. This class cannot hold any UI specific information. icon is UI specific, as the possible values are defined by FUI.
this is correctly documented in https://github.com/atk4/data/blob/82fe55997a6c0cb73a982bfd86698d3a0ba9118d/src/Model/UserAction.php#L19
however, an ui property can be added like already present in data Field class
however, in atk4/data, we cannot still specify any UI specific default value, thus no default icon for the default UAs (add, ˙edit˙, ...)
so if these actions are desired to have an icon, it must be defined by some helper, but central/deduplicated method/registry in atk4/ui
Understood for the default actions and also understood that we have to change that on the Ui side. I would though ask for adding the ui property to UserAction as in Field, that at least custom defined UserActions can easily be setup and configured to show icon