zable 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ module Zable
3
3
  module ActiveRecord
4
4
 
5
5
  module ClassMethods
6
- PAGE_DEFAULTS = { 'num' => 1, 'size' => 200 }
6
+ PAGE_DEFAULTS = { 'num' => 1 }
7
7
 
8
8
  def scoped_for_sort(params, scoped_object)
9
9
  hash = (params[:sort] || {}).stringify_keys
data/lib/zable/html.rb CHANGED
@@ -50,8 +50,17 @@ module Zable
50
50
  params.join("&".html_safe)
51
51
  end
52
52
 
53
- def search_params(params)
54
- params.to_a.collect do |param|
53
+ def current_sort_params
54
+ p = []
55
+ if params[:sort].present?
56
+ p << param(:sort, "attr", params[:sort][:attr])
57
+ p << param(:sort, "order", params[:sort][:order]) if params[:sort][:order].present?
58
+ end
59
+ p.join("&".html_safe)
60
+ end
61
+
62
+ def search_params
63
+ @search.to_a.collect do |param|
55
64
  param(:search, param.first, param.second)
56
65
  end.join("&".html_safe)
57
66
  end
@@ -61,8 +70,8 @@ module Zable
61
70
  end
62
71
 
63
72
  def header_cell_href(attr)
64
- all_params = [sort_params(attr), search_params(@search), (@_extra_params || {}).to_query.html_safe].reject(&:blank?).join("&".html_safe)
65
- current_url << "?".html_safe << all_params
73
+ params = [sort_params(attr), search_params, @_extra_params.to_query.html_safe].reject(&:blank?).join("&".html_safe)
74
+ current_url << "?".html_safe << params
66
75
  end
67
76
 
68
77
  def header_cell_link_text(attr)
data/lib/zable/view.rb CHANGED
@@ -11,7 +11,7 @@ module Zable
11
11
  @template = template # this refers to the view context
12
12
  raise "Must pass in valid view context" unless @template.kind_of? ActionView::Context
13
13
  @search = @template.controller.request.params[:search]
14
- @_extra_params = options[:params]
14
+ @_extra_params = options[:params] || {}
15
15
 
16
16
  @options = options
17
17
  @columns = []
@@ -61,7 +61,7 @@ module Zable
61
61
  def pagination_element
62
62
  content_tag :div, :class => 'brownFilterResultsBox' do
63
63
  page_entries_info(@collection, @options.slice(:entry_name)) <<
64
- will_paginate(@collection, :renderer => Zable::WillPaginate::LinkWithParamsRenderer.new(@options[:params] || {}))
64
+ will_paginate(@collection, :renderer => Zable::WillPaginate::LinkWithParamsRenderer.new(self, @_extra_params))
65
65
  end
66
66
  end
67
67
 
@@ -4,10 +4,17 @@ module Zable
4
4
  module WillPaginate
5
5
  class LinkWithParamsRenderer < ::WillPaginate::ViewHelpers::LinkRenderer
6
6
 
7
- def initialize(params = {})
7
+ def initialize(zable_view, params = {})
8
+ @zable_view = zable_view
8
9
  @params = params
9
10
  end
10
11
 
12
+ def url(page)
13
+ page_param = @zable_view.param(:page, :num, page)
14
+ all_params = [page_param, @zable_view.current_sort_params, @zable_view.search_params, @params.to_query.html_safe].reject(&:blank?).join("&".html_safe)
15
+ @zable_view.current_url << "?".html_safe << all_params
16
+ end
17
+
11
18
  protected
12
19
 
13
20
  def default_url_params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  version: '0'
70
70
  requirements: []
71
71
  rubyforge_project:
72
- rubygems_version: 1.8.23
72
+ rubygems_version: 1.8.25
73
73
  signing_key:
74
74
  specification_version: 3
75
75
  summary: HTML tables