will_filter 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. data/.rspec +1 -0
  2. data/.watchr +18 -0
  3. data/Gemfile.lock +79 -104
  4. data/README.rdoc +17 -1
  5. data/VERSION +1 -0
  6. data/app/controllers/will_filter/filter_controller.rb +1 -0
  7. data/app/models/will_filter/filter.rb +47 -7
  8. data/app/views/will_filter/common/_results_table.html.erb +81 -48
  9. data/lib/will_filter/extensions/action_view_extension.rb +19 -19
  10. data/lib/will_filter/extensions/array_extension.rb +6 -0
  11. data/lib/will_filter/filter_condition.rb +2 -2
  12. data/lib/will_filter/version.rb +1 -1
  13. data/spec/{containers → lib/will_filter/containers}/double_spec.rb +10 -5
  14. data/spec/{extensions → lib/will_filter/extensions}/active_record_extension_spec.rb +7 -2
  15. data/spec/models/will_filter/filter_spec.rb +249 -0
  16. data/spec/spec_helper.rb +26 -26
  17. data/test/dummy/.sass-cache/f9cb1ef521115be73f1c61d3d5d64f66c947af63/actions.css.scssc +0 -0
  18. data/test/dummy/.sass-cache/f9cb1ef521115be73f1c61d3d5d64f66c947af63/results.css.scssc +0 -0
  19. data/test/dummy/app/controllers/application_controller.rb +5 -0
  20. data/test/dummy/app/models/merchant/order.rb +1 -1
  21. data/test/dummy/app/models/merchant/order_item.rb +1 -1
  22. data/test/dummy/app/views/advanced/event_members.html.erb +1 -1
  23. data/test/dummy/app/views/advanced/events.html.erb +1 -1
  24. data/test/dummy/app/views/advanced/users.html.erb +1 -1
  25. data/test/dummy/app/views/advanced/users_with_actions.html.erb +1 -1
  26. data/test/dummy/app/views/common/_event_members.html.erb +14 -1
  27. data/test/dummy/app/views/common/_events.html.erb +1 -0
  28. data/test/dummy/app/views/common/_menu.html.erb +2 -2
  29. data/test/dummy/app/views/common/_users.html.erb +39 -1
  30. data/test/dummy/app/views/simple/event_members.html.erb +1 -1
  31. data/test/dummy/app/views/simple/events.html.erb +1 -1
  32. data/test/dummy/app/views/simple/users.html.erb +1 -1
  33. data/will_filter.gemspec +5 -9
  34. metadata +42 -62
  35. data/spec/fake_app.rb +0 -51
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format=d
3
+ --drb
data/.watchr ADDED
@@ -0,0 +1,18 @@
1
+ def run_spec(file)
2
+ unless File.exist?(file)
3
+ puts "#{file} does not exist"
4
+ return
5
+ end
6
+
7
+ puts "Running #{file}"
8
+ system "bundle exec rspec #{file}"
9
+ puts
10
+ end
11
+
12
+ watch("spec/.*/*_spec.rb") do |match|
13
+ run_spec match[0]
14
+ end
15
+
16
+ watch("app/(.*/.*).rb") do |match|
17
+ run_spec %{spec/#{match[1]}_spec.rb}
18
+ end
data/Gemfile.lock CHANGED
@@ -1,156 +1,131 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- will_filter (3.1.7)
5
- coffee-script
4
+ will_filter (3.1.8)
6
5
  kaminari
7
- rails (>= 3.1.0)
6
+ rails (>= 3.2.3)
8
7
  sass
9
8
 
10
9
  GEM
11
10
  remote: http://rubygems.org/
12
11
  specs:
13
- actionmailer (3.1.0)
14
- actionpack (= 3.1.0)
15
- mail (~> 2.3.0)
16
- actionpack (3.1.0)
17
- activemodel (= 3.1.0)
18
- activesupport (= 3.1.0)
12
+ actionmailer (3.2.3)
13
+ actionpack (= 3.2.3)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.3)
16
+ activemodel (= 3.2.3)
17
+ activesupport (= 3.2.3)
19
18
  builder (~> 3.0.0)
20
19
  erubis (~> 2.7.0)
21
- i18n (~> 0.6)
22
- rack (~> 1.3.2)
23
- rack-cache (~> 1.0.3)
24
- rack-mount (~> 0.8.2)
20
+ journey (~> 1.0.1)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.2)
25
23
  rack-test (~> 0.6.1)
26
- sprockets (~> 2.0.0)
27
- activemodel (3.1.0)
28
- activesupport (= 3.1.0)
29
- bcrypt-ruby (~> 3.0.0)
24
+ sprockets (~> 2.1.2)
25
+ activemodel (3.2.3)
26
+ activesupport (= 3.2.3)
30
27
  builder (~> 3.0.0)
31
- i18n (~> 0.6)
32
- activerecord (3.1.0)
33
- activemodel (= 3.1.0)
34
- activesupport (= 3.1.0)
35
- arel (~> 2.2.1)
28
+ activerecord (3.2.3)
29
+ activemodel (= 3.2.3)
30
+ activesupport (= 3.2.3)
31
+ arel (~> 3.0.2)
36
32
  tzinfo (~> 0.3.29)
37
- activeresource (3.1.0)
38
- activemodel (= 3.1.0)
39
- activesupport (= 3.1.0)
40
- activesupport (3.1.0)
33
+ activeresource (3.2.3)
34
+ activemodel (= 3.2.3)
35
+ activesupport (= 3.2.3)
36
+ activesupport (3.2.3)
37
+ i18n (~> 0.6)
41
38
  multi_json (~> 1.0)
42
- arel (2.2.1)
43
- bcrypt-ruby (3.0.1)
39
+ arel (3.0.2)
44
40
  builder (3.0.0)
45
- capybara (1.1.1)
46
- mime-types (>= 1.16)
47
- nokogiri (>= 1.3.3)
48
- rack (>= 1.0.0)
49
- rack-test (>= 0.5.4)
50
- selenium-webdriver (~> 2.0)
51
- xpath (~> 0.1.4)
52
- childprocess (0.2.2)
53
- ffi (~> 1.0.6)
54
- coffee-script (2.2.0)
55
- coffee-script-source
56
- execjs
57
- coffee-script-source (1.1.2)
58
- database_cleaner (0.6.7)
41
+ coderay (1.0.6)
59
42
  diff-lcs (1.1.3)
60
43
  erubis (2.7.0)
61
- execjs (1.2.9)
62
- multi_json (~> 1.0)
63
- factory_girl (2.1.2)
64
- activesupport
65
- ffi (1.0.9)
66
44
  hike (1.2.1)
67
45
  i18n (0.6.0)
68
- json_pure (1.6.1)
69
- kaminari (0.12.4)
70
- rails (>= 3.0.0)
71
- mail (2.3.0)
46
+ journey (1.0.3)
47
+ json (1.6.6)
48
+ kaminari (0.13.0)
49
+ actionpack (>= 3.0.0)
50
+ activesupport (>= 3.0.0)
51
+ railties (>= 3.0.0)
52
+ mail (2.4.4)
72
53
  i18n (>= 0.4.0)
73
54
  mime-types (~> 1.16)
74
55
  treetop (~> 1.4.8)
75
- mime-types (1.16)
76
- multi_json (1.0.3)
77
- nokogiri (1.5.0)
78
- polyglot (0.3.2)
79
- rack (1.3.3)
80
- rack-cache (1.0.3)
56
+ method_source (0.7.1)
57
+ mime-types (1.18)
58
+ multi_json (1.3.2)
59
+ polyglot (0.3.3)
60
+ pry (0.9.9)
61
+ coderay (~> 1.0.5)
62
+ method_source (~> 0.7.1)
63
+ slop (>= 2.4.4, < 3)
64
+ rack (1.4.1)
65
+ rack-cache (1.2)
81
66
  rack (>= 0.4)
82
- rack-mount (0.8.3)
83
- rack (>= 1.0.0)
84
67
  rack-ssl (1.3.2)
85
68
  rack
86
69
  rack-test (0.6.1)
87
70
  rack (>= 1.0)
88
- rails (3.1.0)
89
- actionmailer (= 3.1.0)
90
- actionpack (= 3.1.0)
91
- activerecord (= 3.1.0)
92
- activeresource (= 3.1.0)
93
- activesupport (= 3.1.0)
71
+ rails (3.2.3)
72
+ actionmailer (= 3.2.3)
73
+ actionpack (= 3.2.3)
74
+ activerecord (= 3.2.3)
75
+ activeresource (= 3.2.3)
76
+ activesupport (= 3.2.3)
94
77
  bundler (~> 1.0)
95
- railties (= 3.1.0)
96
- railties (3.1.0)
97
- actionpack (= 3.1.0)
98
- activesupport (= 3.1.0)
78
+ railties (= 3.2.3)
79
+ railties (3.2.3)
80
+ actionpack (= 3.2.3)
81
+ activesupport (= 3.2.3)
99
82
  rack-ssl (~> 1.3.2)
100
83
  rake (>= 0.8.7)
101
84
  rdoc (~> 3.4)
102
85
  thor (~> 0.14.6)
103
- rake (0.9.2)
104
- rdoc (3.9.4)
86
+ rake (0.9.2.2)
87
+ rdoc (3.12)
88
+ json (~> 1.4)
105
89
  rr (1.0.4)
106
- rspec (2.6.0)
107
- rspec-core (~> 2.6.0)
108
- rspec-expectations (~> 2.6.0)
109
- rspec-mocks (~> 2.6.0)
110
- rspec-core (2.6.4)
111
- rspec-expectations (2.6.0)
112
- diff-lcs (~> 1.1.2)
113
- rspec-mocks (2.6.0)
114
- rspec-rails (2.6.1)
115
- actionpack (~> 3.0)
116
- activesupport (~> 3.0)
117
- railties (~> 3.0)
118
- rspec (~> 2.6.0)
119
- rubyzip (0.9.4)
120
- sass (3.1.7)
121
- selenium-webdriver (2.7.0)
122
- childprocess (>= 0.2.1)
123
- ffi (>= 1.0.7)
124
- json_pure
125
- rubyzip
126
- sprockets (2.0.0)
90
+ rspec (2.9.0)
91
+ rspec-core (~> 2.9.0)
92
+ rspec-expectations (~> 2.9.0)
93
+ rspec-mocks (~> 2.9.0)
94
+ rspec-core (2.9.0)
95
+ rspec-expectations (2.9.1)
96
+ diff-lcs (~> 1.1.3)
97
+ rspec-mocks (2.9.0)
98
+ rspec-rails (2.9.0)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ railties (>= 3.0)
102
+ rspec (~> 2.9.0)
103
+ sass (3.1.15)
104
+ slop (2.4.4)
105
+ spork (0.9.0)
106
+ sprockets (2.1.2)
127
107
  hike (~> 1.2)
128
108
  rack (~> 1.0)
129
109
  tilt (~> 1.1, != 1.3.0)
130
- sqlite3 (1.3.4)
131
- steak (2.0.0)
132
- capybara (>= 1.0.0)
133
- rspec-rails (>= 2.5.0)
110
+ sqlite3 (1.3.6)
134
111
  thor (0.14.6)
135
112
  tilt (1.3.3)
136
113
  treetop (1.4.10)
137
114
  polyglot
138
115
  polyglot (>= 0.3.1)
139
- tzinfo (0.3.30)
140
- xpath (0.1.4)
141
- nokogiri (~> 1.3)
116
+ tzinfo (0.3.33)
117
+ watchr (0.7)
142
118
 
143
119
  PLATFORMS
144
120
  ruby
145
121
 
146
122
  DEPENDENCIES
147
123
  bundler (>= 1.0.0)
148
- capybara
149
- database_cleaner
150
- factory_girl
124
+ pry
151
125
  rr
152
126
  rspec
153
- rspec-rails
127
+ rspec-rails (>= 2.1.0)
128
+ spork
154
129
  sqlite3
155
- steak
130
+ watchr
156
131
  will_filter!
data/README.rdoc CHANGED
@@ -46,13 +46,27 @@ Note: 'User' is a Rails ActiveRecord model
46
46
  Now all you have to do is create a view for this action and add the following tag where you want the filter to be rendered:
47
47
 
48
48
  <%= will_filter_tag(@users) %>
49
-
49
+
50
50
  And optionally you can do (for results table):
51
51
 
52
52
  <%= will_filter_table_tag(@users) %>
53
53
 
54
54
  That's it. This will render a filter box with various conditions, operators and values for the model object you selected.
55
55
 
56
+
57
+ = Documentation
58
+
59
+ Please read the following document to learn more about filter customization:
60
+
61
+ https://github.com/berk/will_filter/wiki/Customizing-Filters
62
+
63
+ Please read the following document to learn more about table tag customization:
64
+
65
+ https://github.com/berk/will_filter/wiki/Customizing-Table-View
66
+
67
+
68
+ = Screenshots
69
+
56
70
  Below are a couple of screenshot of what the filter looks like when it is rendered on a page:
57
71
 
58
72
  http://wiki.tr8n.org/images/e/e1/Wf1.png
@@ -60,6 +74,8 @@ http://wiki.tr8n.org/images/e/e1/Wf1.png
60
74
  http://wiki.tr8n.org/images/5/50/Wf2.png
61
75
 
62
76
 
77
+ = Dummy Application
78
+
63
79
  This plugin comes with a dummy test project. To try out some of the examples, run the following commands:
64
80
 
65
81
  $ git clone git://github.com/berk/will_filter.git
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.5
@@ -23,6 +23,7 @@
23
23
 
24
24
  module WillFilter
25
25
  class FilterController < ApplicationController
26
+
26
27
  def index
27
28
  @filters = WillFilter::Filter.new(WillFilter::Filter).deserialize_from_params(params).results
28
29
  end
@@ -20,10 +20,32 @@
20
20
  # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
+ #
24
+ #-- WillFilter::Filter Schema Information
25
+ #
26
+ # Table name: will_filter_filters
27
+ #
28
+ # id INTEGER not null, primary key
29
+ # type varchar(255)
30
+ # name varchar(255)
31
+ # data text
32
+ # user_id integer
33
+ # model_class_name varchar(255)
34
+ # created_at datetime
35
+ # updated_at datetime
36
+ #
37
+ # Indexes
38
+ #
39
+ # index_will_filter_filters_on_user_id (user_id)
40
+ #
41
+ #++
23
42
 
24
43
  module WillFilter
25
44
  class Filter < ActiveRecord::Base
26
- set_table_name :will_filter_filters
45
+ self.table_name = :will_filter_filters
46
+ attr_accessible :type, :name, :data, :user_id, :model_class_name
47
+
48
+ # set_table_name :will_filter_filters
27
49
  serialize :data
28
50
  before_save :prepare_save
29
51
  after_find :process_find
@@ -40,7 +62,7 @@ module WillFilter
40
62
 
41
63
  self.model_class_name = model_class.to_s
42
64
  end
43
-
65
+
44
66
  def dup
45
67
  super.tap {|ii| ii.conditions = self.conditions.dup}
46
68
  end
@@ -155,11 +177,15 @@ module WillFilter
155
177
  defs
156
178
  end
157
179
  end
158
-
159
- def container_by_sql_type(type)
180
+
181
+ def self.container_by_sql_type(type)
160
182
  raise WillFilter::FilterException.new("Unsupported data type #{type}") unless WillFilter::Config.data_types[type]
161
183
  WillFilter::Config.data_types[type]
162
184
  end
185
+
186
+ def container_by_sql_type(type)
187
+ self.class.container_by_sql_type(type)
188
+ end
163
189
 
164
190
  def default_condition_definition_for(name, sql_data_type)
165
191
  type = sql_data_type.split(" ").first.split("(").first.downcase
@@ -293,9 +319,22 @@ module WillFilter
293
319
  oper
294
320
  end
295
321
 
322
+ def conditions_for(condition_key)
323
+ @conditions.select{|cond| cond.key == condition_key}
324
+ end
325
+
326
+ def remove_condition(condition_key)
327
+ @conditions -= conditions_for(condition_key)
328
+ end
329
+
296
330
  def add_condition(condition_key, operator_key, values = [])
297
331
  add_condition_at(size, condition_key, operator_key, values)
298
332
  end
333
+
334
+ def replace_condition(condition_key, operator_key, values = [])
335
+ remove_condition(condition_key)
336
+ add_condition_at(size, condition_key, operator_key, values)
337
+ end
299
338
 
300
339
  def valid_operator?(condition_key, operator_key)
301
340
  condition_key = condition_key.to_sym if condition_key.is_a?(String)
@@ -386,10 +425,10 @@ module WillFilter
386
425
  condition = condition_at(index)
387
426
  condition.serialize_to_params(params, index)
388
427
  end
389
-
390
- params.merge(merge_params)
428
+ HashWithIndifferentAccess.new(params.merge(merge_params))
391
429
  end
392
-
430
+ alias_method :to_params, :serialize_to_params
431
+
393
432
  #############################################################################
394
433
  # allows to create a filter from params only
395
434
  #############################################################################
@@ -465,6 +504,7 @@ module WillFilter
465
504
 
466
505
  self
467
506
  end
507
+ alias_method :from_params, :deserialize_from_params
468
508
 
469
509
  #############################################################################
470
510
  # Validations
@@ -17,81 +17,114 @@
17
17
  <thead>
18
18
  <tr>
19
19
  <%
20
+ carray = [] # stores the order of the columns
21
+
20
22
  opts[:columns].each_with_index do |column, index|
23
+ cmeta = {}
24
+
21
25
  if column.is_a?(Array)
22
- key = column.first
26
+ cmeta[:key] = column[0]
27
+ cmeta[:value] = column[1]
28
+ unless column[2].nil?
29
+ if column[2].is_a?(Hash)
30
+ cmeta.merge!(column[2])
31
+ elsif column[2].is_a?(String)
32
+ cmeta[:style] = column[2]
33
+ else
34
+ raise WillFilter::FilterException.new("Unsupported table column format #{column[2]}")
35
+ end
36
+ end
23
37
  elsif column.is_a?(Hash)
24
- key = column[:key] || "key_#{index}"
38
+ cmeta = column
39
+ cmeta[:key] ||= "key_#{index}"
40
+ else
41
+ cmeta[:key] = column
42
+ end
43
+
44
+ carray << cmeta
45
+
46
+ sort_direction = filter.column_sorted?(cmeta[:key]) ? filter.order_type : "asc"
47
+ sort_direction_click = filter.column_sorted?(cmeta[:key]) ? (sort_direction == "asc" ? "desc" : "asc") : "asc"
48
+
49
+ if cmeta[:sort_key]
50
+ sort_key = cmeta[:sort_key].call(filter)
51
+ else
52
+ sort_key = cmeta[:key]
53
+ end
54
+
55
+ if cmeta[:sortable].nil?
56
+ sortable = filter.contains_column?(cmeta[:key])
25
57
  else
26
- key = column
58
+ sortable = cmeta[:sortable]
27
59
  end
28
-
29
- style = ""
30
- sort_direction = filter.column_sorted?(key) ? filter.order_type : "asc"
31
- sort_direction_click = filter.column_sorted?(key) ? (sort_direction == "asc" ? "desc" : "asc") : "asc"
32
- column_title = filter.condition_title_for(key)
33
- the_class_name = key.to_s
34
- the_class_name << " sortable" if filter.contains_column?(key)
35
- the_class_name << " current_sort" if filter.column_sorted?(key)
36
- the_class_name << " #{sort_direction}"
37
-
38
- style << "width:15px" if key == :checkbox
60
+
61
+ if cmeta[:title].is_a?(Proc)
62
+ column_title = cmeta[:title].call(filter)
63
+ else
64
+ column_title = cmeta[:title] || filter.condition_title_for(cmeta[:key])
65
+ if sortable
66
+ column_title = link_to(column_title, filter.to_params(:wf_order => cmeta[:key], :wf_order_type => sort_direction_click), :title => "sort by #{cmeta[:key]} ascending", :class => "sort_link")
67
+ end
68
+ end
69
+
70
+ # column class name
71
+ title_class_name = cmeta[:title_class] || cmeta[:key].to_s
72
+ title_class_name << " sortable" if sortable
73
+ title_class_name << " current_sort" if filter.column_sorted?(sort_key)
74
+ title_class_name << " #{sort_direction}"
75
+
76
+ # extra styling that can be applied on a column
77
+ title_style = cmeta[:title_style] || ""
78
+ title_style << ";width:15px" if cmeta[:key] == :checkbox
39
79
  %>
40
- <th class="<%= the_class_name %>" style="<%=style%>">
80
+
81
+ <th class="<%= title_class_name %>" style="<%=title_style%>">
41
82
  <div class="table_head_container">
42
- <% if filter.contains_column?(key) %>
83
+ <% if sortable %>
43
84
  <div class="sort_control">
44
- <%= link_to "", filter.serialize_to_params(:wf_order => key, :wf_order_type => 'asc'), :title => "sort by #{key} ascending", :class => 'up' %>
45
- <%= link_to "", filter.serialize_to_params(:wf_order => key, :wf_order_type => 'desc'), :title => "sort by #{key} descending", :class => 'down' %>
85
+ <%= link_to "", filter.to_params(:wf_order => sort_key, :wf_order_type => 'asc'), :title => "sort by #{sort_key} ascending", :class => 'up' %>
86
+ <%= link_to "", filter.to_params(:wf_order => sort_key, :wf_order_type => 'desc'), :title => "sort by #{sort_key} descending", :class => 'down' %>
46
87
  </div>
47
-
48
- <%= link_to column_title, filter.serialize_to_params(:wf_order => key, :wf_order_type => sort_direction_click), :class => "sort_link" %>
49
- <% elsif key == :checkbox %>
88
+
89
+ <div style='white-space: nowrap;'>
90
+ <%= column_title %>
91
+ </div>
92
+
93
+ <% elsif cmeta[:key] == :checkbox %>
50
94
  <%= check_box_tag("wf_check_all", "", false, :onClick => "wfCheckAll(this)") %>
95
+
51
96
  <% else %>
52
97
  <%= column_title %>
98
+
53
99
  <% end %>
54
100
  </div>
55
101
  </th>
56
102
  <% end %>
57
103
  </tr>
58
104
  </thead>
59
-
105
+
60
106
  <tbody>
61
107
  <% results.each_with_index do |obj, index| %>
62
108
  <tr class='data_row <%=(index % 2 == 0) ? "wf_row_even" : "wf_row_odd"%>'>
63
- <% opts[:columns].each_with_index do |column, column_index| %>
109
+ <% carray.each_with_index do |cmeta, column_index| %>
64
110
  <%
65
- style = 'padding:3px;'
66
- if column.is_a?(Array)
67
- key = column.first
68
-
69
- if column.second.is_a?(Proc)
70
- value = column.second.call(obj)
71
- else
72
- value = column.second.to_s
73
- end
74
- style << column.last if column.size > 2
75
-
76
- elsif column.is_a?(Hash)
77
- key = column[:key] || "key_#{column_index}"
78
- if column[:value]
79
- value = column[:value]
80
- value = value.call(obj) if value.is_a?(Proc)
81
- else
82
- value = obj.send(key)
83
- end
84
- style << column[:style] if column[:style]
111
+ value_style = cmeta[:style] || 'padding-top:2px;padding-bottom:2px;' # should be moved to css
112
+ value_class = cmeta[:class] || ''
85
113
 
114
+ if cmeta[:value].nil?
115
+ value = obj.send(cmeta[:key])
116
+ elsif cmeta[:value].is_a?(Proc)
117
+ value = cmeta[:value].call(obj)
86
118
  else
87
- key = column
88
- value = obj.send(key)
119
+ value = cmeta[:value]
89
120
  end
90
121
 
91
- style << "padding-left:10px;" if key == :checkbox
122
+ value_style << 'width:30px;' if cmeta[:key] == :checkbox
123
+ value_class << ' current_sort' if filter.column_sorted?(cmeta[:key])
124
+
92
125
  %>
93
- <td style='<%=style%>' <%= " class='current_sort'" if filter.column_sorted?(key) %>>
94
- <% if key == :checkbox %>
126
+ <td style='<%=value_style%>' class='<%=value_class%>'>
127
+ <% if cmeta[:key] == :checkbox %>
95
128
  <%= check_box_tag("#{value}[]", obj.id, false, :id => "wf_check_#{index}", :onClick => "wfVerifyTrigger(this)") %>
96
129
 
97
130
  <% elsif value.is_a?(Hash) %>
@@ -24,27 +24,27 @@
24
24
  module WillFilter
25
25
  module ActionViewExtension
26
26
  extend ActiveSupport::Concern
27
- module InstanceMethods
28
- def will_filter_tag(results, opts = {})
29
- render(:partial => "/will_filter/filter/container", :locals => {:wf_filter => results.wf_filter, :opts => opts})
30
- end
31
27
 
32
- def will_filter_scripts_tag(opts = {})
33
- render(:partial => "/will_filter/common/scripts", :locals => {:opts => opts})
34
- end
28
+ def will_filter_tag(results, opts = {})
29
+ render(:partial => "/will_filter/filter/container", :locals => {:wf_filter => results.wf_filter, :opts => opts})
30
+ end
35
31
 
36
- def will_filter_table_tag(results, opts = {})
37
- filter = results.wf_filter
38
- opts[:columns] ||= filter.model_column_keys
39
- render(:partial => "/will_filter/common/results_table", :locals => {:results => results, :filter => filter, :opts => opts})
40
- end
32
+ def will_filter_scripts_tag(opts = {})
33
+ render(:partial => "/will_filter/common/scripts", :locals => {:opts => opts})
34
+ end
41
35
 
42
- def will_filter_actions_bar_tag(results, actions, opts = {})
43
- filter = results.wf_filter
44
- opts[:class] ||= "wf_actions_bar_blue"
45
- opts[:style] ||= ""
46
- render(:partial => "/will_filter/common/actions_bar", :locals => {:results => results, :filter => filter, :actions => actions, :opts => opts})
47
- end
48
- end
36
+ def will_filter_table_tag(results, opts = {})
37
+ filter = results.wf_filter
38
+ opts[:columns] ||= filter.model_column_keys
39
+ render(:partial => "/will_filter/common/results_table", :locals => {:results => results, :filter => filter, :opts => opts})
40
+ end
41
+
42
+ def will_filter_actions_bar_tag(results, actions, opts = {})
43
+ filter = results.wf_filter
44
+ opts[:class] ||= "wf_actions_bar_blue"
45
+ opts[:style] ||= ""
46
+ render(:partial => "/will_filter/common/actions_bar", :locals => {:results => results, :filter => filter, :actions => actions, :opts => opts})
47
+ end
48
+
49
49
  end
50
50
  end
@@ -31,4 +31,10 @@ class Array
31
31
  @wf_filter
32
32
  end
33
33
 
34
+ def add_filter_condition(condition_key, operator_key, values = [])
35
+ sub_filter = wf_filter.dup
36
+ sub_filter.replace_condition(condition_key, operator_key, values)
37
+ sub_filter
38
+ end
39
+
34
40
  end
@@ -37,8 +37,8 @@ module WillFilter
37
37
  end
38
38
 
39
39
  def serialize_to_params(params, index)
40
- params["wf_c#{index}"] = key
41
- params["wf_o#{index}"] = operator
40
+ params["wf_c#{index}".to_sym] = key
41
+ params["wf_o#{index}".to_sym] = operator
42
42
  container.serialize_to_params(params, index)
43
43
  params
44
44
  end
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module WillFilter
25
- VERSION = "3.1.7"
25
+ VERSION = "3.1.8"
26
26
  end