hilla
hilla copied to clipboard
[autocrud] enable gridProps to accept service and model
Describe your motivation
When dealing with DTOs instead of entities, it is easier to project data with a DTO class different that the one used for Update and Save operations. As the services for the underlying AutoGrid and AutoForm accepting the generic type for the transfer type, this enables to have a ListService<DTO1> for the grid and CrudService<DTO2> for the form.
Describe the solution you'd like
Assuming that the Project is a DTO used for SAVE and UPDATE operations, and ProjectView is used for data READ operation, It would be nice to have the following possible:
<AutoCrud service={ProjectService} model={ProjectModel}
gridProps={{
service: ProjectViewService,
model: ProjectViewModel
}}
/>
Describe alternatives you've considered
No response
Additional context
No response
Note that it's not enough to give a different configuration for the grid since <AutoCrud> expects the grid and the form to have data in the same format so that the currently selected grid row can be used to populate the form. To use different DTOs, it's also necessary to have a way for the form to fetch a form DTO based on the id of the grid DTO that was selected.
The following issue is going to make the path clear for doing the fetch: https://github.com/vaadin/hilla/issues/1731
Let's make a 1-day prototype of separate DTOs implemented manually.