vaadin / hilla

Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
https://hilla.dev
Apache License 2.0
909 stars 57 forks source link

Provide an API for custom action buttons for AutoGrid/AutoCrud/AutoForm #2255

Open alxflam opened 6 months ago

alxflam commented 6 months ago

Describe your motivation

When using AutoGrid/AutoCrud/AutoForm, there are already some action buttons provided below the component (e.g. "+ NEW", "Delete", "Submit"). But it is common to have more such actions for table/form elements (e.g. "Activate", "Deactivate", "Share", "Move", "Assign", ...), which currently cannot be added to the same div like the standard action buttons.

Describe the solution you'd like

AutoCrudGridProps / AutoCrudFormProps should allow to specify custom action buttons (e.g. label, callback, enabled-condition, visible-condition). The enabled-condition should allow to ensure the button is only active when there is a single selection or a multi-selection (depends on the use-case) or a selection which passes some arbitrary predicate. Similarly, the visible-condition could be used to completely hide a button if there is no selection for which the action is applicable.

Describe alternatives you've considered

Alternatively, custom action buttons need to be added manually to a UI component which is not part of the AutoForm / AutoCRUD, e.g. a row of buttons above the actual table/form.

Additional context

This feature request originates from the following discussion: https://vaadin.com/forum/t/autocrud-grid-custom-actions/165681/3

platosha commented 6 months ago

Thanks for the request.

It would be helpful for the design to have few specific action use cases to consider. Usage code examples are welcome also.

alxflam commented 6 months ago

@platosha this is my concrete use case:

Im writing a little personal finance app which can query financial institutions for the customers accounts and transactions. Now i have a JPA entity BankAccount which describes an account, so the columns include IBAN, AccountNumber, AccountOwner etc. Now i have an action Fetch Transactions for these BankAccount entities: The action communicates with the corresponding banking backend and fetches the latest transactions, processes them using Spring Batch and stores them finally in another JPA table. So as per my understanding, such custom action buttons are helpful in cases when: