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

Add possibility to set pagination options on grids #68

Merged
merged 8 commits into from
Aug 18, 2021

Conversation

vvasiloi
Copy link
Contributor

@vvasiloi vvasiloi commented Oct 18, 2020

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes Sylius/Sylius#10343
License MIT

A similar solution can be applied to the Resource Bundle Sylius/SyliusResourceBundle#148.

The solution is based on this experiment: https://github.com/vvasiloi/doctrine-pagination

TODO:

  • test setting default values by parameters
  • add parameters for setting default values
  • test setting the values per grid
  • allow setting the values per grid
  • test with fetch join enabled/disabled per grid
  • test with fetch join enabled/disabled by default
  • test with order by to-many association field and allow output walkers enabled/disabled per grid
  • test with order by to-many association field and allow output walkers enabled/disabled by default
  • update documentation

Additional:

  • apply a similar solution to Sylius Resource Bundle
  • enable fetch join and output walkers in Sylius Standard
  • use configuration instead of parameters?

@vvasiloi
Copy link
Contributor Author

@lchrusciel can I have a review, please? I need to know if and how I should move forward with this.

@lchrusciel lchrusciel requested review from pamil, GSadee and lchrusciel and removed request for GSadee October 25, 2020 12:53
Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

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

Hey Victor,

this issue is with us for way too long. Your proposal seems to be in a good direction. However generic setting could be done with configuration component indeed. I would like to see it merged in SyliusGridBundle.

/cc @pamil, what is your opinion?

src/Bundle/Doctrine/ORM/DataSource.php Outdated Show resolved Hide resolved
@pamil pamil force-pushed the pagination branch 4 times, most recently from 05ab13d to cf7f221 Compare December 2, 2020 18:37
Copy link
Contributor

@pamil pamil left a comment

Choose a reason for hiding this comment

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

Thanks a lot and sorry for the delay! I've just rebased the PR to the newest master so that CI does not fail anymore. Also resolved @lchrusciel comment and added a comment not to rely on these parameters for defining global behaviour for now.

@pamil
Copy link
Contributor

pamil commented Dec 2, 2020

I think in the current form it's pretty good to go. I'd say the next steps, for now, would be "test with order by to-many association field and allow output walkers enabled/disabled per grid" and "update documentation".

Then it should be good to merge, we can skip configurable default settings for all grids for now and address that later. If so, I think the best place to set it would be sylius_grid.drivers.orm configuration.

Also, really cool work on https://github.com/vvasiloi/doctrine-pagination! I wonder if there's some solution that is both performant and accurate? Can it be solved somehow with a custom query (for cases like Sylius/Sylius#3775, when using output walkers takes too much time)?

@vvasiloi
Copy link
Contributor Author

vvasiloi commented Aug 9, 2021

@AdamKasp Thanks for picking it up, I forgot about it... 😞 Do you need anything from me?

@vvasiloi
Copy link
Contributor Author

The "use output walker" parameters should allow null, because Doctrine allows it to be null, in which case it will use query hints to determine if an output walker should be used.

@GSadee GSadee marked this pull request as ready for review August 18, 2021 06:58
@GSadee GSadee changed the title [WIP] Fix pagination issue Add possibility to set pagination options on grids Aug 18, 2021
@GSadee GSadee added the Bug Confirmed bugs or bugfixes. label Aug 18, 2021
if (!isset($configuration['repository']['method'])) {
return new DataSource($repository->createQueryBuilder('o'));
return new DataSource($repository->createQueryBuilder('o'), $fetchJoinCollection, $useOutputWalkers);
Copy link
Member

Choose a reason for hiding this comment

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

Just a minor thought, but perhaps it would be better to pass the whole configuration array into the data source?

Copy link
Member

Choose a reason for hiding this comment

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

I have no strong opinion about that change. But now, it looks that every operation on the configuration array occurs in Driver, so it makes sense to do it there and pass only proper parameters to DataSource. Do you see any benefits or potential benefits of changing it?

@lchrusciel lchrusciel merged commit 0446613 into Sylius:master Aug 18, 2021
@lchrusciel
Copy link
Member

lchrusciel commented Aug 18, 2021

Thank you, Victor, Adam and Grzegorz! 🎉

lchrusciel added a commit to Sylius/Sylius that referenced this pull request Aug 18, 2021
… GridBundle 1.10 (AdamKasp, GSadee)

This PR was merged into the 1.9 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         |master 

Should be merged after merge PR Sylius/SyliusGridBundle#68 and release new version of `SyliusGridBundle`
<!--
 - Bug fixes must be submitted against the 1.9 or 1.10 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

e489775 docs about fetch join collection and output walkers
d70f712 [Documentation] Improve note about disabling pagination optioons
@vvasiloi
Copy link
Contributor Author

Thank you, Adam and Grzegorz!
I will try to not abandon my PRs like that anymore.

@vvasiloi vvasiloi deleted the pagination branch April 16, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bugs or bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Product pagination bug (again)
5 participants