Skip to content

Feature request - custom pagination #48

@theofidry

Description

@theofidry

As of now it is possible to customize the number of items per page at a global level on the API side with the option items_per_page.

But the number of items per page is a parameter you may wish to change for some entities on the API side and sometimes let the client adjust it to his need.

To cover most of the use case without having to override a DataProvider a defining a custom Paginator, tit should be possible to configure the following with some parameters in the config:

  1. Configure the items_per_page on a global basis on the API side (already possible)
  2. Configure the items_per_page on a resource basis on the API side
  3. Enable the possibility for the client to change the default page size for all resources
  4. Enable the possibility for the client to change the default page size on a resource basis

Suggestion of configuration

Feature 1

Keep it as it is.

Feature 2

services:
    resource.dummy:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Dummy" ]
        calls:
            -      method:    "setPagination"
                   arguments: 50

And in this case, regardless of the value of items_per_page in the config.yml, this pagination for Dummy will be at 50.

Feature 3

Since it's for all the resources it seem logical to define it in the config.yml:

dunglas_api:
    title:              "Your API name"
    description:        "The full description of your API"
    default:
        items_per_page:
            default_value:     30
            client_pagination: true # Default to false
        order:          ~

Maybe adding which values we allow for the pagination via a request would be nice too. If you deem it too specific then letting the user extending the paginator to achieve that is fine.

Feature 4

services:
    resource.dummy:
        parent:    "api.resource"
        arguments: [ "AppBundle\Entity\Dummy" ]
        calls:
            -      method:    "enableClientPagination"
                   arguments: [10, 50, 100, 200] # valid values, if no value provided all value is accepted.

Syntax

Syntax proposal for the custom pagination on the client side:

url?itemsPerPage=value

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions