Sha256: 13bbd6c8ba1ab6bbfff8c5bda8611e7aee63f05d1674093f1b5f346b90b5ec7c

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module RearHelpers
  module InstanceMixin

    def pager_linker page, label = nil
      label ||= page
      url = route(action, *action_params__array, pager_params(page))
      return link_to(url, label) unless xhr?
      
      onclick = "Rear.switch_page('#%s', '%s');" % [dom_id, url]
      link_to nil, label, onclick: onclick
    end

    def pager_params page = nil, filters = nil
      page.is_a?(Hash) && (filters = page) && (page = nil)
      page ||= params[:page]
      {
                 page: page.to_s,
              filters: filters || pager_filters,
        quick_filters: opted_quick_filters,
                order: order_params
      }.reject {|k,v| v.nil? || v.empty?}
    end

    def pager_filters
      @__rear__pager_filters ||= filters.inject({}) do |map,(column, setups)|
        setups.each do |comparison_function, setup|
          (value = filter?(column, comparison_function)) &&
            (map[column] ||= {})[comparison_function] = value
        end
        map
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rear-0.2.0 lib/rear/helpers/pager.rb