Skip to content

CardDeck/general addUserAction icon support #1849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mkrecek234 opened this issue Sep 1, 2022 · 3 comments
Open

CardDeck/general addUserAction icon support #1849

mkrecek234 opened this issue Sep 1, 2022 · 3 comments

Comments

@mkrecek234
Copy link
Contributor

mkrecek234 commented Sep 1, 2022

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';
            },
        ]);
@mvorisek mvorisek changed the title Feature Request: Support to configure icon in addUserAction Support to configure icon in addUserAction Sep 1, 2022
@mvorisek
Copy link
Member

mvorisek commented Sep 1, 2022

slightly related with #1848, I highly support unified look & feel (and impl.)

@mvorisek mvorisek changed the title Support to configure icon in addUserAction CardDeck/general addUserAction icon support Sep 1, 2022
@mvorisek
Copy link
Member

mvorisek commented Sep 1, 2022

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

@mkrecek234
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants