-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Feature] Add cursor pagination to Livewire #3215
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
Conversation
Nice PR, the only concern is the version constraint with laravel. @calebporzio maybe its time to only support the current laravel version (it's not a big deal nowadays to keep your app up to date). |
about this PR i don't think the laravel version will be a big concern cause its just a trait that user can add it manually. and we can notice them in docs that this feature only works with laravel 8.41+ But in general I agree with you. And I think not only the Laravel version should be limited to the latest version, but also the php version should be limited to the versions that are actively supported. |
Before another pagination trait gets added, is it possible to ensure this one supports multiple pagination instances on a single component from the start? That's LW's biggest failing at the moment in my opinion. |
I can add this feature for both pagination traits but I need to change the livewire paginator api and since users maybe publishes the views and uses custom themes it might not be backward compatible so we can't merge it with current version branch. but still i am looking at this problem and may come with a solution without breaking things |
Yeah, even just adding support on this new trait would be good, since there would be no breaking changes. |
i am working on a new pr that add multiple pagination on single component but @calebporzio need to review and accept it |
add method_exists check for $route->getMissing() function
@ariaieboy - I haven't really dug into this problem, but is it possible to support his in the existing WithPagination trait? |
it can be implemented in the same WithPagination trait but i think keep them seperated is better option. |
in this PR #3264 i've added multiple cursor pagination on single component. i've used an array to define the paginations queryStrings. we add just watch that PR and if that was ok let me know so i work on it to add regular pagination to it and update my PR according to that. |
@ariaieboy I've been working on adding multiple pagination support to the existing with pagination trait that doesn't have breaking changes, but I'm just waiting for my two other pagination PRs to be merged and I will submit it. |
@joshhanley - I think we're good now? I don't see any open PRs for you - yeah? Let me know if you need more from me |
Ok, Josh's other PRs are all merged now. I'm open to supporting cursor pagination - ideally it would be contained within the same trait with minimal forking |
@calebporzio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ariaieboy just a few comments and changes 🙂 also not sure why the dist/livewire.js
is showing up and licence.md
. Can you make sure it's up to date with master so they're not showing in this PR?
Thanks!
rbase master to the branch
@@ -75,8 +86,10 @@ public function resetPage($pageName = 'page') | |||
|
|||
public function setPage($page, $pageName = 'page') | |||
{ | |||
$page = intval($page); | |||
$page = $page <= 0 ? 1 : $page ; | |||
if (is_numeric($page)){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since cursor pagination use string as the identifier we should not cast the $page to intger all the time
@@ -48,20 +48,12 @@ public function double_page_value_should_be_casted_to_int() | |||
->call('gotoPage', 2.5) | |||
->assertSet('page', 2); | |||
} | |||
|
|||
/** @test */ | |||
public function string_page_value_should_be_reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as i said since cursor pagination use string as identifier we should not reeset strings
@joshhanley @calebporzio |
Thanks so much for this @ariaieboy! |
1️⃣ Is this something that is wanted/needed? Did you create an issue / discussion about it first?
#3182
2️⃣ Does it contain multiple, unrelated changes? Please separate the PRs out.
No
3️⃣ Does it include tests, if possible? (Not a deal-breaker, just a nice-to-have)
No, I looked at the default pagination tests they only test that page property is set currectly or Not
since the cursor pagination dont use numbers as refrrence for pagination and use a encoded string based from the data i couldnt add test for it if you guys give me a hint i may can add some test for it.
4️⃣ Please include a thorough description of the improvement and reasons why it's useful.
laravel introduced cursor pagination in laravel v8.41.0 this PR aim to add this feature to livewire pagination system.
with this PR users can replace
withPagination
trait withwithCursorPagination
trait and changepaginate()
method withcursorPaginate()
and use cursor pagination instead of regular pagination in livewire5️⃣ Thanks for contributing! 🙌