GithubHelp home page GithubHelp logo

use kaminari/will_paginate about filterer HOT 10 CLOSED

dobtco avatar dobtco commented on August 31, 2024
use kaminari/will_paginate

from filterer.

Comments (10)

ramontayag avatar ramontayag commented on August 31, 2024

Yes this is a good idea. I want to use this gem with https://github.com/davidcelis/api-pagination but it looks like it won't be compatible.

from filterer.

ajb avatar ajb commented on August 31, 2024

Thanks for the input. As for your use case, you should be able to use the
.chain method:

def chain(params = {}, opts = {})

On Mon, Dec 22, 2014 at 12:35 AM, Ramon Tayag [email protected]
wrote:

Yes this is a good idea. I want to use this gem with
https://github.com/davidcelis/api-pagination but it looks like it won't
be compatible.


Reply to this email directly or view it on GitHub
#11 (comment).

Adam Becker
510.928.9111
@AdamJacobBecker

from filterer.

olliebennett avatar olliebennett commented on August 31, 2024

Can the chain method be used to integrate with kaminari?

I also back this feature request as the filterer gem - while fantastic for managing filters - is let down by its pagination logic (specifically the view helper).

If it's not possible to integrate kaminari (or will-paginate), I could attempt to improve the pagination logic within this gem.

from filterer.

olliebennett avatar olliebennett commented on August 31, 2024

I believe the following is the appropriate way to integrate kaminari:

# Without Kaminari:
@filterer = PersonFilterer.new(params)
# With Kaminari:
@filterer = PersonFilterer.chain(params).page(params[:page]).per(100)

And the respective change in the view:

# Without Kaminari:
@filterer.results.each do |person|
# With Kaminari:
@filterer.each do |person|

This implementation appears to ignore the sort configuration in the filterer, however. Is that the reason this issue remains open?

from filterer.

ajb avatar ajb commented on August 31, 2024

Hey @olliebennett,

Yes, that workaround will work for now. The reason this issue is open is that I'm planning to remove the current pagination methods/views and make usage of kaminari/will_paginate the primary method for pagination.

from filterer.

olliebennett avatar olliebennett commented on August 31, 2024

Great - thanks for the response. Should the 'sort' options be obeyed when using Kaminari in the above manner? In my trials the sort (and direction) params are ignored. I believe this is due to the following code in base.rb:

def find_results
  @results = opts.delete(:starting_query) || starting_query
  add_params_to_query
  return if @opts[:chainable]
  order_results

Would it be a problem to move order_results above the chainable check? Perhaps (in order to preserve backwards compatibility) we could have a new chain_with_ordering method or pass a new :include_ordering option?

If there are no obvious pitfalls with this that you can see, I can attempt to provide a PR for this. Can continue discussion in a separate issue if you prefer? Thanks again

from filterer.

ajb avatar ajb commented on August 31, 2024

I believe this is due to the following code in base.rb:

Yeah, tbh I don't really remember why the code works that way. I'm 👍 on adding an include_ordering option until the next major release.

from filterer.

ajb avatar ajb commented on August 31, 2024

This will be released in 1.0.0.

from filterer.

ramontayag avatar ramontayag commented on August 31, 2024

Great - thanks!

from filterer.

ajb avatar ajb commented on August 31, 2024

Hi all,

I just pushed 1.0.0.beta.1 to Rubygems. If you have a chance to take a look, maybe read the documentation, and provide some feedback, it would be super helpful!

from filterer.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.