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

Batch actions `all_elements` on `SimplePager` #8164

Open mvhirsch opened 8 months ago

mvhirsch commented 8 months ago

Environment

Sonata packages

show

``` $ composer show --latest 'sonata-project/*' sonata-project/admin-bundle 4.22.6 4.29.3 The missing Symfony Admin Generator sonata-project/block-bundle 4.21.0 5.1.0 Symfony SonataBlockBundle sonata-project/classification-bundle 4.4.1 4.8.0 Symfony SonataClassificationBundle sonata-project/doctrine-orm-admin-bundle 4.11.0 4.16.0 Integrate Doctrine ORM into the SonataAdminBundle sonata-project/form-extensions 1.20.0 2.3.0 Symfony form extensions sonata-project/media-bundle 4.11.1 4.11.1 Symfony SonataMediaBundle sonata-project/seo-bundle 3.5.0 3.8.0 Symfony SonataSeoBundle sonata-project/user-bundle 5.6.3 5.10.0 Symfony SonataUserBundle ```

Symfony packages

show

``` $ composer show --latest 'symfony/*' symfony/amqp-messenger v6.4.4 v6.4.4 Symfony AMQP extension Messenger Bridge symfony/asset v6.4.3 v6.4.3 Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files symfony/cache v6.4.4 v6.4.4 Provides extended PSR-6, PSR-16 (and tags) implementations symfony/cache-contracts v2.5.2 v3.4.0 Generic abstractions related to caching symfony/config v6.4.4 v6.4.4 Helps you find, load, combine, autofill and validate configuration values of any kind symfony/console v6.4.4 v6.4.4 Eases the creation of beautiful and testable command line interfaces symfony/debug-bundle v6.4.3 v6.4.3 Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework symfony/dependency-injection v6.4.4 v6.4.4 Allows you to standardize and centralize the way objects are constructed in your application symfony/doctrine-bridge v6.4.5 v6.4.5 Provides integration for Doctrine with various Symfony components symfony/doctrine-messenger v6.4.4 v6.4.4 Symfony Doctrine Messenger Bridge symfony/dom-crawler v6.4.4 v6.4.4 Eases DOM navigation for HTML and XML documents symfony/dotenv v6.4.4 v6.4.4 Registers environment variables from a .env file symfony/event-dispatcher v6.4.3 v6.4.3 Provides tools that allow your application components to communicate with each other by dispatching events and listening to them symfony/event-dispatcher-contracts v2.5.2 v3.4.0 Generic abstractions related to dispatching event symfony/expression-language v6.4.3 v6.4.3 Provides an engine that can compile and evaluate expressions symfony/filesystem v6.4.3 v6.4.3 Provides basic utilities for the filesystem symfony/finder v6.4.0 v6.4.0 Finds files and directories via an intuitive fluent interface symfony/flex v2.4.5 v2.4.5 Composer plugin for Symfony symfony/form v6.4.4 v6.4.4 Allows to easily create, process and reuse HTML forms symfony/framework-bundle v6.4.4 v6.4.4 Provides a tight integration between Symfony components and the Symfony full-stack framework symfony/http-client v6.4.5 v6.4.5 Provides powerful methods to fetch HTTP resources synchronously or asynchronously symfony/http-client-contracts v3.4.0 v3.4.0 Generic abstractions related to HTTP clients symfony/http-foundation v6.4.4 v6.4.4 Defines an object-oriented layer for the HTTP specification symfony/http-kernel v6.4.5 v6.4.5 Provides a structured process for converting a Request into a Response symfony/intl v6.4.3 v6.4.3 Provides access to the localization data of the ICU library symfony/lock v6.4.3 v6.4.3 Creates and manages locks, a mechanism to provide exclusive access to a shared resource symfony/mailer v6.4.4 v6.4.4 Helps sending emails symfony/maker-bundle v1.53.0 v1.56.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code. symfony/messenger v6.4.4 v6.4.4 Helps applications send and receive messages to/from other applications or via message queues symfony/mime v6.4.3 v6.4.3 Allows manipulating MIME messages symfony/monolog-bundle v3.10.0 v3.10.0 Symfony MonologBundle symfony/options-resolver v6.4.0 v6.4.0 Provides an improved replacement for the array_replace PHP function symfony/phpunit-bridge v6.4.4 v7.0.4 Provides utilities for PHPUnit, especially user deprecation notices management symfony/process v6.4.4 v6.4.4 Executes commands in sub-processes symfony/property-access v6.4.4 v6.4.4 Provides functions to read and write from/to an object or array using a simple string notation symfony/routing v6.4.5 v6.4.5 Maps an HTTP request to a set of configuration variables symfony/runtime v6.4.3 v6.4.3 Enables decoupling PHP applications from global state symfony/security-bundle v6.4.5 v6.4.5 Provides a tight integration of the Security component into the Symfony full-stack framework symfony/security-core v6.4.3 v6.4.3 Symfony Security Component - Core Library symfony/service-contracts v2.5.2 v3.4.1 Generic abstractions related to writing services symfony/stopwatch v6.4.3 v6.4.3 Provides a way to profile code symfony/string v6.4.4 v6.4.4 Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way symfony/translation v6.4.4 v6.4.4 Provides tools to internationalize your application symfony/twig-bundle v6.4.4 v6.4.4 Provides a tight integration of Twig into the Symfony full-stack framework symfony/validator v6.4.4 v6.4.4 Provides tools to validate values symfony/var-dumper v6.4.4 v6.4.4 Provides mechanisms for walking through any arbitrary PHP variable symfony/web-profiler-bundle v6.4.4 v6.4.4 Provides a development tool that gives detailed information about the execution of any request symfony/workflow v6.4.3 v6.4.3 Provides tools for managing a workflow or finite state machine ```

PHP version

$ php -v
PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.1.27, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.27, Copyright (c), by Zend Technologies
    with blackfire v1.92.6~linux-x64-non_zts81, https://blackfire.io, by Blackfire

Subject

Using SimplePager renders wrong statement on batch actions. For example: selecting 50 elements (on a table containing >1000 elements) the batch action checkbox "all_elements" would result in "all elements (51)".

image

Which looks weird.

Minimal repository with the bug

Steps to reproduce

Use an admin using SimplePager, a database table using more than 25 results and limit it to 25.

Expected results

I suggest printing something similar to pagination:

Alle Elemente (50+)

or

Alle Elemente (?)

Actual results

Alle Elemente (51)
VincentLanglet commented 7 months ago

In simple_pager_results we add {{ 'list_results_count_prefix'|trans({}, 'SonataAdminBundle') }}, we might use the same here, but I'm not sure how the override should be done in the base_list...

Feel free to provide a PR @mvhirsch

github-actions[bot] commented 1 month 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.

mvhirsch commented 1 month ago

I added a proposal in #8164.