zable 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -119,6 +119,8 @@ class Item < ActiveRecord::Base
119
119
  end
120
120
  ```
121
121
 
122
+ For a walk-through on how to create a basic search form with your table, look at [this wiki page](https://github.com/derekcroft/zable/wiki/Creating-a-search-form).
123
+
122
124
  ## Pagination
123
125
 
124
126
  Optionally, you can use pagination via [will_paginate](https://github.com/mislav/will_paginate). In the view, simply set the 'paginate' option:
@@ -41,7 +41,7 @@ module Zable
41
41
 
42
42
  def current_path_with_params(*param_array)
43
43
  all_params = param_array.reject(&:blank?).map {|p| p.to_query.html_safe}.join("&".html_safe)
44
- all_params = all_params.sub("%5B", "[").sub("%5D", "]")
44
+ all_params = all_params.gsub("%5B", "[").gsub("%5D", "]")
45
45
  current_url << "?".html_safe << all_params
46
46
  end
47
47
 
@@ -50,9 +50,15 @@ module Zable
50
50
  end
51
51
 
52
52
  def sort_params(attr)
53
- params = { :sort => {:attr => attr[:name]} }
54
- params[:sort][:order] = attr[:sort_order] if attr[:sorted?]
55
- params
53
+ p = { :sort => {:attr => attr[:name]} }
54
+ p[:sort][:order] = attr[:sort_order] if attr[:sorted?]
55
+ p
56
+ end
57
+
58
+ def page_size_params
59
+ p = {}
60
+ p[:page] = {:size => params[:page][:size]} if params[:page] && params[:page][:size]
61
+ p
56
62
  end
57
63
 
58
64
  def sort_arrow_image_file(attr)
@@ -60,7 +66,7 @@ module Zable
60
66
  end
61
67
 
62
68
  def header_cell_href(attr)
63
- current_path_with_params(sort_params(attr), params.slice(:search), @_extra_params)
69
+ current_path_with_params(sort_params(attr), params.slice(:search), page_size_params, @_extra_params)
64
70
  end
65
71
 
66
72
  def header_cell_link_text(attr)
@@ -11,7 +11,12 @@ module Zable
11
11
 
12
12
  def url(page)
13
13
  page_params = {:page => {:num => page}}
14
- @zable_view.current_path_with_params(page_params, @zable_view.params.slice(:search, :sort), @params)
14
+ @zable_view.current_path_with_params(
15
+ page_params,
16
+ @zable_view.params.slice(:search, :sort),
17
+ @zable_view.page_size_params,
18
+ @params
19
+ )
15
20
  end
16
21
 
17
22
  protected
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.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-07 00:00:00.000000000 Z
13
+ date: 2013-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: will_paginate