Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the previous and next buttons always work #9827

Conversation

bergice
Copy link
Contributor

@bergice bergice commented Jan 18, 2021

@bergice bergice changed the title Make the previous and next buttons always work WIP: Make the previous and next buttons always work Jan 18, 2021
@bergice bergice force-pushed the pulls/4.7/fix-better-button-pagination branch 2 times, most recently from 6efef0d to 1e8d7b7 Compare January 18, 2021 05:08
@bergice bergice force-pushed the pulls/4.7/fix-better-button-pagination branch from 1e8d7b7 to a66e441 Compare January 18, 2021 06:16
@bergice bergice changed the title WIP: Make the previous and next buttons always work Make the previous and next buttons always work Jan 18, 2021
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some unit tests please

@bergice
Copy link
Contributor Author

bergice commented Jul 7, 2021

Could you add some unit tests please

Spent some time trying to get a unit test done but it's quite tricky because of the convoluted state logic and pagination that's required.
Besides, adding the grid field state to the test and using that as a baseline for checking if the test is passing is sort of pointless with all the grid field state stuff taken out of the next/previous logic...

A behat test would be more ideal but we don't have anything suited in framework.

I'd prefer just getting this merged as we're a lot better off with it than without, unless someone else wants to give it a go first.

@emteknetnz
Copy link
Member

I don't feel confident merging this as is, or at least I don't feel confident that it won't break again sometime in the future.

We've assigned 3 story points on the parent issue so we've got some time to fix this.

Seems like we could add a corresponding behat test in admin to cover this functionality

->sort(['ID' => 'ASC']);
} else {
$list = $list->where(["\"$table\".\"ID\" <= ?" => $this->record->ID])
->sort(['ID' => 'DESC']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this change the sorting completely? Any sort order applied to the gridfield (or a default_sort) will be ignored, and the records will be sorted by ID. Is that intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t this change the sorting completely? Any sort order applied to the gridfield (or a default_sort) will be ignored, and the records will be sorted by ID. Is that intended?

Hmm, I'm pretty sure $list->getManipulatedList() already applies all the filters.

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach seems like it won't fix the root cause of the issue

I've done some investigation into part of the issue

This pull-request just filtering and sorting $list, however $list is fundamentally incomplete, which is why the next button can only be clicked a couple of times. I did not investigate the other issue identified of results being in the incorrect order. There I'd say it's likely the $list is simply incorrect

A proper solution would be to get a correct $list

If you're able to update the PR to get a correct $list that would still work in a 100K database records scenario, then great, otherwise recommend this one be closed

@bergice
Copy link
Contributor Author

bergice commented Jul 9, 2021

Closing, while the filtering is still working as expected, sorting is broken and will need to be fixed. Can reopen later if we want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants