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.
- data/.rspec +1 -0
- data/.watchr +18 -0
- data/Gemfile.lock +79 -104
- data/README.rdoc +17 -1
- data/VERSION +1 -0
- data/app/controllers/will_filter/filter_controller.rb +1 -0
- data/app/models/will_filter/filter.rb +47 -7
- data/app/views/will_filter/common/_results_table.html.erb +81 -48
- data/lib/will_filter/extensions/action_view_extension.rb +19 -19
- data/lib/will_filter/extensions/array_extension.rb +6 -0
- data/lib/will_filter/filter_condition.rb +2 -2
- data/lib/will_filter/version.rb +1 -1
- data/spec/{containers → lib/will_filter/containers}/double_spec.rb +10 -5
- data/spec/{extensions → lib/will_filter/extensions}/active_record_extension_spec.rb +7 -2
- data/spec/models/will_filter/filter_spec.rb +249 -0
- data/spec/spec_helper.rb +26 -26
- data/test/dummy/.sass-cache/f9cb1ef521115be73f1c61d3d5d64f66c947af63/actions.css.scssc +0 -0
- data/test/dummy/.sass-cache/f9cb1ef521115be73f1c61d3d5d64f66c947af63/results.css.scssc +0 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/models/merchant/order.rb +1 -1
- data/test/dummy/app/models/merchant/order_item.rb +1 -1
- data/test/dummy/app/views/advanced/event_members.html.erb +1 -1
- data/test/dummy/app/views/advanced/events.html.erb +1 -1
- data/test/dummy/app/views/advanced/users.html.erb +1 -1
- data/test/dummy/app/views/advanced/users_with_actions.html.erb +1 -1
- data/test/dummy/app/views/common/_event_members.html.erb +14 -1
- data/test/dummy/app/views/common/_events.html.erb +1 -0
- data/test/dummy/app/views/common/_menu.html.erb +2 -2
- data/test/dummy/app/views/common/_users.html.erb +39 -1
- data/test/dummy/app/views/simple/event_members.html.erb +1 -1
- data/test/dummy/app/views/simple/events.html.erb +1 -1
- data/test/dummy/app/views/simple/users.html.erb +1 -1
- data/will_filter.gemspec +5 -9
- metadata +42 -62
- data/spec/fake_app.rb +0 -51
data/.rspec
CHANGED
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.
|
5
|
-
coffee-script
|
4
|
+
will_filter (3.1.8)
|
6
5
|
kaminari
|
7
|
-
rails (>= 3.
|
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.
|
14
|
-
actionpack (= 3.
|
15
|
-
mail (~> 2.
|
16
|
-
actionpack (3.
|
17
|
-
activemodel (= 3.
|
18
|
-
activesupport (= 3.
|
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
|
-
|
22
|
-
rack (~> 1.
|
23
|
-
rack-cache (~> 1.
|
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.
|
27
|
-
activemodel (3.
|
28
|
-
activesupport (= 3.
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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.
|
38
|
-
activemodel (= 3.
|
39
|
-
activesupport (= 3.
|
40
|
-
activesupport (3.
|
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 (
|
43
|
-
bcrypt-ruby (3.0.1)
|
39
|
+
arel (3.0.2)
|
44
40
|
builder (3.0.0)
|
45
|
-
|
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
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
polyglot (0.3.
|
79
|
-
|
80
|
-
|
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.
|
89
|
-
actionmailer (= 3.
|
90
|
-
actionpack (= 3.
|
91
|
-
activerecord (= 3.
|
92
|
-
activeresource (= 3.
|
93
|
-
activesupport (= 3.
|
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.
|
96
|
-
railties (3.
|
97
|
-
actionpack (= 3.
|
98
|
-
activesupport (= 3.
|
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.
|
86
|
+
rake (0.9.2.2)
|
87
|
+
rdoc (3.12)
|
88
|
+
json (~> 1.4)
|
105
89
|
rr (1.0.4)
|
106
|
-
rspec (2.
|
107
|
-
rspec-core (~> 2.
|
108
|
-
rspec-expectations (~> 2.
|
109
|
-
rspec-mocks (~> 2.
|
110
|
-
rspec-core (2.
|
111
|
-
rspec-expectations (2.
|
112
|
-
diff-lcs (~> 1.1.
|
113
|
-
rspec-mocks (2.
|
114
|
-
rspec-rails (2.
|
115
|
-
actionpack (
|
116
|
-
activesupport (
|
117
|
-
railties (
|
118
|
-
rspec (~> 2.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
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.
|
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.
|
140
|
-
|
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
|
-
|
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
|
-
|
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
|
@@ -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
|
-
|
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
|
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
|
-
|
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
|
-
|
58
|
+
sortable = cmeta[:sortable]
|
27
59
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
80
|
+
|
81
|
+
<th class="<%= title_class_name %>" style="<%=title_style%>">
|
41
82
|
<div class="table_head_container">
|
42
|
-
<% if
|
83
|
+
<% if sortable %>
|
43
84
|
<div class="sort_control">
|
44
|
-
<%= link_to "", filter.
|
45
|
-
<%= link_to "", filter.
|
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
|
-
|
49
|
-
|
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
|
-
<%
|
109
|
+
<% carray.each_with_index do |cmeta, column_index| %>
|
64
110
|
<%
|
65
|
-
|
66
|
-
|
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
|
-
|
88
|
-
value = obj.send(key)
|
119
|
+
value = cmeta[:value]
|
89
120
|
end
|
90
121
|
|
91
|
-
|
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='<%=
|
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
|
-
|
33
|
-
|
34
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
@@ -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
|
data/lib/will_filter/version.rb
CHANGED