admin icon indicating copy to clipboard operation
admin copied to clipboard

ListGuesser keeping unusable defaults for sort and pagination regardless of support in API

Open Antarian opened this issue 4 years ago • 3 comments

API Platform version(s) affected: 2.6.2

Description
I am using useEmbedded true. Because of that I was required to setup ListGuesser for resource manually, like in docs for admin. My API is not supporting any king of filtering, sorting or searching for now. Pagination is on default 30 items not changeable. Kind of default CRUD "entity/api resource" with nothing extended so far. I would expect not to have offered sorting on columns and pagination under grid defaulting for 30 items, not 10 and displaying 30 recieved ones. Which results in last pages of pagination resetting to first page as they do not exist. I have 110 items and 4 pages and admin show 110 items on 11 pages available as pagination.

Possible Solution
I tried to pass perPage={30} property to ListGuesser. It is kind of working, but pagination is now only 2 arrows, forward and backward, without showing any pages number links at all. Unusable sorting is still present.

Additional Context
const FoodList = (props) => ( <ListGuesser {...props}> <FieldGuesser source="title" /> </ListGuesser> );

Antarian avatar Feb 26 '21 10:02 Antarian

Arrows were issue only with window size and perPage settings is working. Unfortunatelly pagination per page dropdown is not possible to change to display only one option 30, as this https://marmelab.com/react-admin/List.html#pagination-pagination-component is not working for ListGuesser and only results in some strange info text ra.navigation.page_range_info

Edit: Dropdown is working, but it will dissappear if only one option is available. But labels are broken. al of them are now starting ra.navigation.

Edit 2: Sorting solved with sortable={false} used on fields, but wtill wondering why this is not automaticly set. OpenApi/Swagger UI is able to see if there is pagination enabled or sorting on field. What is a difference here?

Antarian avatar Feb 26 '21 11:02 Antarian

This is handled though: https://github.com/api-platform/admin/blob/5badc1f19024c1800a60431e575219039b86d0b6/src/FieldGuesser.js#L108

alanpoulain avatar Feb 26 '21 13:02 alanpoulain

Probably yes, but for some reason it is not working for me. I can paste here whole jsonld doc if you are able to check what is going on. I am not skilled in React in this level.

Antarian avatar Feb 26 '21 19:02 Antarian