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

Support display/hidden fields in `configureListFields` #7968

Closed onEXHovia closed 1 year ago

onEXHovia commented 1 year ago

At the moment in configureListFields method you can specify only the fields that will be displayed in the list, but often there are a lot of them and the table is heavily overloaded. But removing unnecessary fields from the list is also not a solution, since they are sometimes needed when filtering or sorting.

Suggestion to add the ability to hide fields that are not needed. The list of fields is customizable for each user. An example of what I mean can be seen here https://demo.laravel-admin.org/

VincentLanglet commented 1 year ago

The example you gave is reloading the whole page when we're trying to hide/show a list column.

We have a similar feature for filters, and they are displayed/hidden dynamically thanks to javascript. This might be better to use javascript for this feature request rather than reloading the page everytime.

Do you want to give a try ?

onEXHovia commented 1 year ago

We have a similar feature for filters, and they are displayed/hidden dynamically thanks to javascript. This might be better to use javascript for this feature request rather than reloading the page everytime.

The filter after reloading the page loses the selected fields.

The very purpose of display/hidden fields in configureListFields is to be able to have different settings for different user roles.

We, as developers, set up all possible fields in configureListFields by default. Further, the content manager can set up a list for himself that he needs, since sometimes there are a lot of service fields.

Therefore, we need some service that stores the configuration data(FilesystemStore, CookierStore etc).

VincentLanglet commented 1 year ago

The very purpose of display/hidden fields in configureListFields is to be able to have different settings for different user roles.

You can already do this

if ($this->isGranted('CUSTOM_ROLE')) {
    $listMapper->add('field');
}
onEXHovia commented 1 year ago

Let's consider example, there is a service field views we not show content to managers

if (!$this->isGranted('CONTENT_MANAGER')) {
    $listMapper->add('view');
}

Next, they write to us how we can see the most viewed posts in the admin panel, hardcoded conditions are useless. This feature is just a convenience of content administration, where each user can customize the fields.

Many fields are not needed in content administration, mainly for some kind of export or check. I hope I explained the idea 😊

onEXHovia commented 1 year ago

Updated the first post, added more examples from others cms/cmf(wordpress, magento, 1c-bitrix), this is a fairly common setting.

VincentLanglet commented 1 year ago

Do you want to start the PR ?

haivala commented 1 year ago

I would argue that hardcoded conditions are better than giving the control to the user. Of course it is bit more work so that you can understand what the user needs but with combination of https://docs.sonata-project.org/projects/SonataAdminBundle/en/4.x/cookbook/recipe_row_templates/ you can get the data in really small display size and show exactly what they need.

VincentLanglet commented 1 year ago

I would argue that hardcoded conditions are better than giving the control to the user.

Both are valid.

Sure it can be done with a custom template. But if @onEXHovia get something which works and look nice, it can be a nice feature to add to this project.

haivala commented 1 year ago

Sure it can be done with a custom template. But if @onEXHovia get something which works and look nice, it can be a nice feature to add to this project.

I agree!

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.