sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Html rendered by XmlHttpRequest has less flexibility in Sonata 4 than in Sonata 3 #7552

Closed VincentLanglet closed 2 years ago

VincentLanglet commented 2 years ago

Subject

The template of the list has the following checks: https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Resources/views/CRUD/base_list.html.twig#L57-L67 https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Resources/views/CRUD/base_list_flat_inner_row.html.twig#L12-L28 https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Resources/views/CRUD/base_list_inner_row.html.twig#L12-L20 https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Resources/views/CRUD/list_outer_rows_mosaic.html.twig#L20

https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Admin/AbstractAdmin.php#L2406-L2428

With the following logic:

This means by bumping from sonata 3 to sonata 4, since getDatagrid is now final, rendering some AJAX html without the select field is not possible.

Another issue we had in Sonata 3 and is till present is the fact we might want to render the list with the actions, even if it's an AJAX call.

VincentLanglet commented 2 years ago

@sonata-project/contributors Are you familiar with the ajax call made by sonata ?

We might need to define some query parameter to pass instead of just relying on the xmlHttpRequest https://github.com/sonata-project/SonataAdminBundle/search?q=_xml_http_request

This way

We could do it in a BC-way with the default to select = true. This can be change in next major.

Also, instead of having some logic about the actions buttons in the template, we should just remove the actions field directly in the admin when the select true option is passed.

Adding such an option is a new feature so should target the 4.x branch ; but it helps bumping from Sonata 3 to 4 so I wonder if such deprecation-fixer-helper feature shouldn't be allowed in the 3.x branch. WDYT ?