hilla icon indicating copy to clipboard operation
hilla copied to clipboard

[autocrud] enable gridProps to accept service and model

Open taefi opened this issue 2 years ago • 3 comments

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

taefi avatar Nov 15 '23 07:11 taefi

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.

Legioth avatar Nov 20 '23 08:11 Legioth

The following issue is going to make the path clear for doing the fetch: https://github.com/vaadin/hilla/issues/1731

taefi avatar Nov 20 '23 11:11 taefi

Let's make a 1-day prototype of separate DTOs implemented manually.

platosha avatar Nov 21 '23 12:11 platosha