will_filter 3.1.9 → 3.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +31 -1
- data/app/assets/stylesheets/will_filter/filter.css.scss +3 -3
- data/app/controllers/will_filter/calendar_controller.rb +1 -1
- data/app/controllers/will_filter/exporter_controller.rb +2 -1
- data/app/controllers/will_filter/filter_controller.rb +1 -1
- data/app/models/will_filter/filter.rb +82 -10
- data/app/views/will_filter/calendar/index.html.erb +5 -5
- data/app/views/will_filter/common/_actions_bar.html.erb +2 -0
- data/app/views/will_filter/common/_details_table.html.erb +49 -0
- data/app/views/will_filter/common/_results_table.html.erb +31 -12
- data/lib/generators/will_filter/templates/config.yml +23 -0
- data/lib/generators/will_filter/templates/create_will_filter_filters.rb +23 -0
- data/lib/generators/will_filter/will_filter_generator.rb +1 -1
- data/lib/will_filter/calendar.rb +1 -1
- data/lib/will_filter/config.rb +1 -1
- data/lib/will_filter/containers/boolean.rb +1 -1
- data/lib/will_filter/containers/date.rb +1 -1
- data/lib/will_filter/containers/date_range.rb +1 -1
- data/lib/will_filter/containers/date_time.rb +1 -1
- data/lib/will_filter/containers/date_time_range.rb +1 -1
- data/lib/will_filter/containers/double.rb +1 -1
- data/lib/will_filter/containers/double_delimited.rb +1 -1
- data/lib/will_filter/containers/double_range.rb +1 -1
- data/lib/will_filter/containers/filter_list.rb +1 -1
- data/lib/will_filter/containers/list.rb +1 -1
- data/lib/will_filter/containers/nil.rb +1 -1
- data/lib/will_filter/containers/numeric.rb +1 -1
- data/lib/will_filter/containers/numeric_delimited.rb +1 -1
- data/lib/will_filter/containers/numeric_range.rb +1 -1
- data/lib/will_filter/containers/single_date.rb +1 -1
- data/lib/will_filter/containers/text.rb +1 -1
- data/lib/will_filter/containers/text_delimited.rb +1 -1
- data/lib/will_filter/engine.rb +1 -1
- data/lib/will_filter/extensions/action_controller_extension.rb +1 -1
- data/lib/will_filter/extensions/action_view_extension.rb +30 -17
- data/lib/will_filter/extensions/active_record_extension.rb +1 -1
- data/lib/will_filter/extensions/array_extension.rb +1 -1
- data/lib/will_filter/filter_condition.rb +1 -1
- data/lib/will_filter/filter_container.rb +1 -1
- data/lib/will_filter/filter_exception.rb +1 -1
- data/lib/will_filter/railtie.rb +1 -1
- data/lib/will_filter/version.rb +2 -2
- data/test/dummy/db/schema.rb +12 -12
- data/will_filter.gemspec +2 -11
- metadata +16 -110
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -2,3 +2,27 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
# Declare your gem's dependencies in will_filter.gemspec.
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem 'bundler', ['>= 1.0.0']
|
7
|
+
|
8
|
+
gem 'jquery-rails'
|
9
|
+
gem 'jquery-ui-rails'
|
10
|
+
gem 'bootstrap-sass'
|
11
|
+
gem 'kaminari'
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'rspec'
|
15
|
+
gem 'rspec-rails'
|
16
|
+
gem 'pry'
|
17
|
+
gem 'sqlite3'
|
18
|
+
gem 'spork'
|
19
|
+
gem 'watchr'
|
20
|
+
gem 'rr'
|
21
|
+
end
|
22
|
+
|
23
|
+
group :assets do
|
24
|
+
gem 'sass-rails', '~> 3.2.3'
|
25
|
+
gem 'coffee-rails', '~> 3.2.1'
|
26
|
+
gem 'uglifier', '>= 1.0.3'
|
27
|
+
end
|
28
|
+
|
data/Gemfile.lock
CHANGED
@@ -37,13 +37,29 @@ GEM
|
|
37
37
|
i18n (~> 0.6)
|
38
38
|
multi_json (~> 1.0)
|
39
39
|
arel (3.0.2)
|
40
|
+
bootstrap-sass (2.1.1.0)
|
40
41
|
builder (3.0.0)
|
41
42
|
coderay (1.0.6)
|
43
|
+
coffee-rails (3.2.2)
|
44
|
+
coffee-script (>= 2.2.0)
|
45
|
+
railties (~> 3.2.0)
|
46
|
+
coffee-script (2.2.0)
|
47
|
+
coffee-script-source
|
48
|
+
execjs
|
49
|
+
coffee-script-source (1.6.3)
|
42
50
|
diff-lcs (1.1.3)
|
43
51
|
erubis (2.7.0)
|
52
|
+
execjs (1.4.0)
|
53
|
+
multi_json (~> 1.0)
|
44
54
|
hike (1.2.1)
|
45
55
|
i18n (0.6.0)
|
46
56
|
journey (1.0.3)
|
57
|
+
jquery-rails (3.0.4)
|
58
|
+
railties (>= 3.0, < 5.0)
|
59
|
+
thor (>= 0.14, < 2.0)
|
60
|
+
jquery-ui-rails (4.0.2)
|
61
|
+
jquery-rails
|
62
|
+
railties (>= 3.1.0)
|
47
63
|
json (1.6.6)
|
48
64
|
kaminari (0.13.0)
|
49
65
|
actionpack (>= 3.0.0)
|
@@ -101,6 +117,10 @@ GEM
|
|
101
117
|
railties (>= 3.0)
|
102
118
|
rspec (~> 2.9.0)
|
103
119
|
sass (3.1.15)
|
120
|
+
sass-rails (3.2.6)
|
121
|
+
railties (~> 3.2.0)
|
122
|
+
sass (>= 3.1.10)
|
123
|
+
tilt (~> 1.3)
|
104
124
|
slop (2.4.4)
|
105
125
|
spork (0.9.0)
|
106
126
|
sprockets (2.1.2)
|
@@ -114,18 +134,28 @@ GEM
|
|
114
134
|
polyglot
|
115
135
|
polyglot (>= 0.3.1)
|
116
136
|
tzinfo (0.3.33)
|
137
|
+
uglifier (2.1.2)
|
138
|
+
execjs (>= 0.3.0)
|
139
|
+
multi_json (~> 1.0, >= 1.0.2)
|
117
140
|
watchr (0.7)
|
118
141
|
|
119
142
|
PLATFORMS
|
120
143
|
ruby
|
121
144
|
|
122
145
|
DEPENDENCIES
|
146
|
+
bootstrap-sass
|
123
147
|
bundler (>= 1.0.0)
|
148
|
+
coffee-rails (~> 3.2.1)
|
149
|
+
jquery-rails
|
150
|
+
jquery-ui-rails
|
151
|
+
kaminari
|
124
152
|
pry
|
125
153
|
rr
|
126
154
|
rspec
|
127
|
-
rspec-rails
|
155
|
+
rspec-rails
|
156
|
+
sass-rails (~> 3.2.3)
|
128
157
|
spork
|
129
158
|
sqlite3
|
159
|
+
uglifier (>= 1.0.3)
|
130
160
|
watchr
|
131
161
|
will_filter!
|
@@ -139,7 +139,7 @@
|
|
139
139
|
font-family: Arial;
|
140
140
|
margin:0px;
|
141
141
|
padding: 2px !important;
|
142
|
-
|
142
|
+
@include rounded-corners(10px);
|
143
143
|
}
|
144
144
|
|
145
145
|
select {
|
@@ -149,7 +149,7 @@
|
|
149
149
|
margin:0px;
|
150
150
|
padding: 1px !important;
|
151
151
|
background-color:#EDEDED;
|
152
|
-
|
152
|
+
@include rounded-corners(10px);
|
153
153
|
}
|
154
154
|
|
155
155
|
a {
|
@@ -167,7 +167,7 @@
|
|
167
167
|
.end {float:right;}
|
168
168
|
.begin {float:left;}
|
169
169
|
.center {text-align:center;}
|
170
|
-
.full_width {width:100
|
170
|
+
.full_width {width:100% !important;}
|
171
171
|
|
172
172
|
.boolean_container {
|
173
173
|
vertical-align:middle;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -25,6 +25,7 @@ require 'csv'
|
|
25
25
|
|
26
26
|
module WillFilter
|
27
27
|
class ExporterController < ApplicationController
|
28
|
+
|
28
29
|
def index
|
29
30
|
@wf_filter = WillFilter::Filter.deserialize_from_params(params)
|
30
31
|
render :layout => false
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -50,6 +50,8 @@ module WillFilter
|
|
50
50
|
before_save :prepare_save
|
51
51
|
after_find :process_find
|
52
52
|
|
53
|
+
JOIN_NAME_INDICATOR = '>'
|
54
|
+
|
53
55
|
#############################################################################
|
54
56
|
# Basics
|
55
57
|
#############################################################################
|
@@ -108,6 +110,10 @@ module WillFilter
|
|
108
110
|
@fields ||= []
|
109
111
|
end
|
110
112
|
|
113
|
+
def extra_params
|
114
|
+
@extra_params ||= {}
|
115
|
+
end
|
116
|
+
|
111
117
|
#############################################################################
|
112
118
|
# a list of indexed fields where at least one of them has to be in a query
|
113
119
|
# otherwise the filter may hang the database
|
@@ -244,6 +250,28 @@ module WillFilter
|
|
244
250
|
"#{order} #{order_type}"
|
245
251
|
end
|
246
252
|
|
253
|
+
def order_model
|
254
|
+
@order_model ||= begin
|
255
|
+
order_parts = order.split('.')
|
256
|
+
if order_parts.size > 1
|
257
|
+
order_parts.first.camelcase
|
258
|
+
else
|
259
|
+
model_class_name
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def order_clause
|
265
|
+
@order_clause ||= begin
|
266
|
+
order_parts = order.split('.')
|
267
|
+
if order_parts.size > 1
|
268
|
+
"#{order_parts.first.camelcase.constantize.table_name}.#{order_parts.last} #{order_type}"
|
269
|
+
else
|
270
|
+
"#{model_class_name.constantize.table_name}.#{order_parts.first} #{order_type}"
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
247
275
|
def column_sorted?(key)
|
248
276
|
key.to_s == order
|
249
277
|
end
|
@@ -280,8 +308,14 @@ module WillFilter
|
|
280
308
|
# Can be overloaded for custom titles
|
281
309
|
#############################################################################
|
282
310
|
def condition_title_for(key)
|
283
|
-
|
284
|
-
title.
|
311
|
+
title_parts = key.to_s.split('.')
|
312
|
+
title = key.to_s.gsub(".", ": ").gsub("_", " ")
|
313
|
+
title = title.split(" ").collect{|part| part.split("/").last.capitalize}.join(" ")
|
314
|
+
if title_parts.size > 1
|
315
|
+
"#{JOIN_NAME_INDICATOR} #{title}"
|
316
|
+
else
|
317
|
+
title
|
318
|
+
end
|
285
319
|
end
|
286
320
|
|
287
321
|
def condition_options
|
@@ -290,7 +324,22 @@ module WillFilter
|
|
290
324
|
definition.keys.each do |cond|
|
291
325
|
opts << [condition_title_for(cond), cond.to_s]
|
292
326
|
end
|
293
|
-
opts.sort_by{
|
327
|
+
opts = opts.sort_by{|opt| opt.first.gsub(JOIN_NAME_INDICATOR, 'zzz') }
|
328
|
+
|
329
|
+
separated = []
|
330
|
+
opts.each_with_index do |opt, index|
|
331
|
+
if index > 0
|
332
|
+
prev_opt_parts = opts[index-1].first.split(":")
|
333
|
+
curr_opt_parts = opt.first.split(":")
|
334
|
+
|
335
|
+
if (prev_opt_parts.size != curr_opt_parts.size) or (curr_opt_parts.size > 1 and (prev_opt_parts.first != curr_opt_parts.first))
|
336
|
+
key_parts = opt.last.split('.')
|
337
|
+
separated << ["-------------- #{curr_opt_parts.first.gsub("#{JOIN_NAME_INDICATOR} ", '')} --------------", "#{key_parts.first}.id"]
|
338
|
+
end
|
339
|
+
end
|
340
|
+
separated << opt
|
341
|
+
end
|
342
|
+
separated
|
294
343
|
end
|
295
344
|
end
|
296
345
|
|
@@ -331,6 +380,15 @@ module WillFilter
|
|
331
380
|
add_condition_at(size, condition_key, operator_key, values)
|
332
381
|
end
|
333
382
|
|
383
|
+
def add_condition!(condition_key, operator_key, values = [])
|
384
|
+
add_condition(condition_key, operator_key, values)
|
385
|
+
self
|
386
|
+
end
|
387
|
+
|
388
|
+
def clone_with_condition(condition_key, operator_key, values = [])
|
389
|
+
dup.add_condition!(condition_key, operator_key, values)
|
390
|
+
end
|
391
|
+
|
334
392
|
def replace_condition(condition_key, operator_key, values = [])
|
335
393
|
remove_condition(condition_key)
|
336
394
|
add_condition_at(size, condition_key, operator_key, values)
|
@@ -425,10 +483,25 @@ module WillFilter
|
|
425
483
|
condition = condition_at(index)
|
426
484
|
condition.serialize_to_params(params, index)
|
427
485
|
end
|
428
|
-
|
486
|
+
|
487
|
+
params.merge!(extra_params)
|
488
|
+
params.merge!(merge_params)
|
489
|
+
HashWithIndifferentAccess.new(params)
|
429
490
|
end
|
430
491
|
alias_method :to_params, :serialize_to_params
|
431
492
|
|
493
|
+
def to_url_params
|
494
|
+
params = []
|
495
|
+
serialize_to_params.each do |name, value|
|
496
|
+
params << "#{name.to_s}=#{ERB::Util.url_encode(value)}"
|
497
|
+
end
|
498
|
+
params.join("&")
|
499
|
+
end
|
500
|
+
|
501
|
+
def to_s
|
502
|
+
to_url_params
|
503
|
+
end
|
504
|
+
|
432
505
|
#############################################################################
|
433
506
|
# allows to create a filter from params only
|
434
507
|
#############################################################################
|
@@ -619,7 +692,6 @@ module WillFilter
|
|
619
692
|
#############################################################################
|
620
693
|
# Saved Filters
|
621
694
|
#############################################################################
|
622
|
-
|
623
695
|
def user_filters
|
624
696
|
@user_filters ||= begin
|
625
697
|
conditions = ["model_class_name = ?", self.model_class_name]
|
@@ -644,12 +716,12 @@ module WillFilter
|
|
644
716
|
if include_default
|
645
717
|
filters = default_filters
|
646
718
|
if (filters.size > 0)
|
647
|
-
filters.insert(0, ["Select
|
719
|
+
filters.insert(0, ["-- Select Default Filter --", "-1"])
|
648
720
|
end
|
649
721
|
end
|
650
722
|
|
651
723
|
if user_filters.any?
|
652
|
-
filters << ["Select
|
724
|
+
filters << ["-- Select Saved Filter --", "-2"] if include_default
|
653
725
|
user_filters.each do |filter|
|
654
726
|
filters << [filter.name, filter.id.to_s]
|
655
727
|
end
|
@@ -717,12 +789,12 @@ module WillFilter
|
|
717
789
|
#############################################################################
|
718
790
|
def export_formats
|
719
791
|
formats = []
|
720
|
-
formats << ["Generic
|
792
|
+
formats << ["-- Generic Formats --", -1]
|
721
793
|
WillFilter::Config.default_export_formats.each do |frmt|
|
722
794
|
formats << [frmt, frmt]
|
723
795
|
end
|
724
796
|
if custom_formats.size > 0
|
725
|
-
formats << ["Custom
|
797
|
+
formats << ["-- Custom Formats --", -2]
|
726
798
|
custom_formats.each do |frmt|
|
727
799
|
formats << frmt
|
728
800
|
end
|
@@ -23,9 +23,9 @@
|
|
23
23
|
<%=link_to_function("«".html_safe, "wfCalendar.goToStartDate('#{@calendar.previous_start_date}')", :style=>"font-size:16px;")%>
|
24
24
|
|
25
25
|
<% if @calendar.mode != 'annual' %>
|
26
|
-
<%= select_tag("month", options_for_select(WillFilter::Calendar.month_options, @calendar.month), {:id => "wf_calendar_month", :onChange=>"wfCalendar.goToStartDate('')"}) %>
|
26
|
+
<%= select_tag("month", options_for_select(WillFilter::Calendar.month_options, @calendar.month), {:id => "wf_calendar_month", :onChange=>"wfCalendar.goToStartDate('')", :style => "width:auto;"}) %>
|
27
27
|
<% end %>
|
28
|
-
<%= select_tag("year", options_for_select(WillFilter::Calendar.year_options, @calendar.year), {:id => "wf_calendar_year",:onChange=>"wfCalendar.goToStartDate('')"}) %>
|
28
|
+
<%= select_tag("year", options_for_select(WillFilter::Calendar.year_options, @calendar.year), {:id => "wf_calendar_year",:onChange=>"wfCalendar.goToStartDate('')", :style => "width:auto;"}) %>
|
29
29
|
|
30
30
|
<%=link_to_function("»".html_safe, "wfCalendar.goToStartDate('#{@calendar.next_start_date}')", :style=>"font-size:16px;")%>
|
31
31
|
|
@@ -37,11 +37,11 @@
|
|
37
37
|
<div style="text-align:center; margin-top:10px; padding:5px; border-top:1px solid #ccc;">
|
38
38
|
<div style="margin:5px;">
|
39
39
|
Time:
|
40
|
-
<%= select_tag("wf_calendar_hour", options_for_select(WillFilter::Calendar.hour_options, @calendar.hour)) %>
|
40
|
+
<%= select_tag("wf_calendar_hour", options_for_select(WillFilter::Calendar.hour_options, @calendar.hour), :style => "width:auto;") %>
|
41
41
|
:
|
42
|
-
<%= select_tag("wf_calendar_minute", options_for_select(WillFilter::Calendar.minute_options, @calendar.minute)) %>
|
42
|
+
<%= select_tag("wf_calendar_minute", options_for_select(WillFilter::Calendar.minute_options, @calendar.minute), :style => "width:auto;") %>
|
43
43
|
:
|
44
|
-
<%= select_tag("wf_calendar_second", options_for_select(WillFilter::Calendar.second_options, @calendar.second)) %>
|
44
|
+
<%= select_tag("wf_calendar_second", options_for_select(WillFilter::Calendar.second_options, @calendar.second), :style => "width:auto;") %>
|
45
45
|
</div>
|
46
46
|
<%=link_to_function("<span>Set Date and Time</span>".html_safe, "wfCalendar.setDateTime()", :class => "wf_grey_button wf_pcb") %>
|
47
47
|
<%=link_to_function("<span>Cancel</span>".html_safe, "wfCalendar.hide()", :class => "wf_grey_button wf_pcb") %>
|
@@ -1,5 +1,7 @@
|
|
1
|
+
<% if results.size > 0 %>
|
1
2
|
<div class="<%=opts[:class]%>" style="<%=opts[:style]%>">
|
2
3
|
<% actions.each do |action| %>
|
3
4
|
<%=link_to_function("<span>#{action.first}</span>".html_safe, "#{action.last}", :class => "wf_grey_button wf_pcb") %>
|
4
5
|
<% end %>
|
5
6
|
</div>
|
7
|
+
<% end %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<%= stylesheet_link_tag("will_filter/filter") -%>
|
2
|
+
|
3
|
+
<table class="<%=opts[:table_class]%>" style="<%=opts[:table_style]%>">
|
4
|
+
<% opts[:columns].each_with_index do |column, column_index|
|
5
|
+
style = 'padding:3px;'
|
6
|
+
if column.is_a?(Array)
|
7
|
+
key = column.first
|
8
|
+
if column.second.is_a?(Proc)
|
9
|
+
value = column.second.call(object)
|
10
|
+
else
|
11
|
+
value = column.second.to_s
|
12
|
+
end
|
13
|
+
style << column.last if column.size > 2
|
14
|
+
|
15
|
+
elsif column.is_a?(Hash)
|
16
|
+
key = column[:key] || "key_#{column_index}"
|
17
|
+
if column[:value]
|
18
|
+
value = column[:value]
|
19
|
+
value = value.call(object) if value.is_a?(Proc)
|
20
|
+
else
|
21
|
+
value = object.send(key)
|
22
|
+
end
|
23
|
+
style << column[:style] if column[:style]
|
24
|
+
else
|
25
|
+
key = column
|
26
|
+
value = object.send(key)
|
27
|
+
end
|
28
|
+
%>
|
29
|
+
<tr>
|
30
|
+
<th style="<%=opts[:key_style]%>">
|
31
|
+
<%= key.to_s.titleize %>
|
32
|
+
</th>
|
33
|
+
<td style="<%=opts[:value_style]%>">
|
34
|
+
<% if value.is_a?(Hash) %>
|
35
|
+
<%= value.to_json %>
|
36
|
+
|
37
|
+
<% elsif value.is_a?(Time) %>
|
38
|
+
<%= value.strftime("%m/%d/%Y %l:%M:%S") %>
|
39
|
+
|
40
|
+
<% elsif value.is_a?(Date) %>
|
41
|
+
<%= value.strftime("%m/%d/%Y") %>
|
42
|
+
|
43
|
+
<% else %>
|
44
|
+
<%= value.to_s %>
|
45
|
+
<% end %>
|
46
|
+
</td>
|
47
|
+
</tr>
|
48
|
+
<% end %>
|
49
|
+
</table>
|
@@ -1,14 +1,13 @@
|
|
1
|
+
<%= stylesheet_link_tag("will_filter/filter") -%>
|
2
|
+
|
3
|
+
<% if results.size > 0 %>
|
1
4
|
<table class='wf_paginator' style="margin-top:10px; margin-bottom:10px;">
|
2
5
|
<tr>
|
3
6
|
<td style='text-align:left'>
|
4
7
|
<%= paginate(results) %>
|
5
8
|
</td>
|
6
9
|
<td style='text-align:right'>
|
7
|
-
|
8
|
-
Showing <%= results.offset_value + 1 %> - <%= results.offset_value + results.length %> of <%= results.total_count %>
|
9
|
-
<% else %>
|
10
|
-
No results found
|
11
|
-
<% end %>
|
10
|
+
Showing <%= results.offset_value + 1 %> - <%= results.offset_value + results.length %> of <%= results.total_count %>
|
12
11
|
</td>
|
13
12
|
</tr>
|
14
13
|
</table>
|
@@ -62,8 +61,8 @@
|
|
62
61
|
|
63
62
|
carray << cmeta
|
64
63
|
|
65
|
-
sort_direction = filter.column_sorted?(cmeta[:key]) ? filter.order_type : "asc"
|
66
|
-
sort_direction_click = filter.column_sorted?(cmeta[:key]) ? (sort_direction == "asc" ? "desc" : "asc") : "asc"
|
64
|
+
sort_direction = filter && filter.column_sorted?(cmeta[:key]) ? filter.order_type : "asc"
|
65
|
+
sort_direction_click = filter && filter.column_sorted?(cmeta[:key]) ? (sort_direction == "asc" ? "desc" : "asc") : "asc"
|
67
66
|
|
68
67
|
if cmeta[:sort_key]
|
69
68
|
sort_key = cmeta[:sort_key].call(filter)
|
@@ -72,7 +71,7 @@
|
|
72
71
|
end
|
73
72
|
|
74
73
|
if cmeta[:sortable].nil?
|
75
|
-
sortable = filter.contains_column?(cmeta[:key])
|
74
|
+
sortable = filter && filter.contains_column?(cmeta[:key])
|
76
75
|
else
|
77
76
|
sortable = cmeta[:sortable]
|
78
77
|
end
|
@@ -80,7 +79,13 @@
|
|
80
79
|
if cmeta[:title].is_a?(Proc)
|
81
80
|
column_title = cmeta[:title].call(filter)
|
82
81
|
else
|
83
|
-
column_title = cmeta[:title] || filter.condition_title_for(cmeta[:key])
|
82
|
+
# column_title = cmeta[:title] || filter ? filter.condition_title_for(cmeta[:key]) : "Undefined"
|
83
|
+
if filter
|
84
|
+
column_title = cmeta[:title] || filter.condition_title_for(cmeta[:key])
|
85
|
+
else
|
86
|
+
column_title = cmeta[:title] || cmeta[:key].to_s.titleize
|
87
|
+
end
|
88
|
+
|
84
89
|
if sortable
|
85
90
|
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")
|
86
91
|
end
|
@@ -89,7 +94,7 @@
|
|
89
94
|
# column class name
|
90
95
|
title_class_name = cmeta[:title_class] || cmeta[:key].to_s
|
91
96
|
title_class_name << " sortable" if sortable
|
92
|
-
title_class_name << " current_sort" if filter.column_sorted?(sort_key)
|
97
|
+
title_class_name << " current_sort" if filter && filter.column_sorted?(sort_key)
|
93
98
|
title_class_name << " #{sort_direction}"
|
94
99
|
|
95
100
|
# extra styling that can be applied on a column
|
@@ -132,7 +137,7 @@
|
|
132
137
|
<tr class='data_row <%=(index % 2 == 0) ? "wf_row_even" : "wf_row_odd"%>'>
|
133
138
|
<% carray.each_with_index do |cmeta, column_index| %>
|
134
139
|
<%
|
135
|
-
value_style = cmeta[:style] || 'padding-top:2px;padding-bottom:2px;' # should be moved to css
|
140
|
+
value_style = cmeta[:style] || 'padding-top:2px;padding-bottom:2px;vertical-align:middle;' # should be moved to css
|
136
141
|
value_class = cmeta[:class] || ''
|
137
142
|
|
138
143
|
if cmeta[:value].nil?
|
@@ -144,7 +149,7 @@
|
|
144
149
|
end
|
145
150
|
|
146
151
|
value_style << 'width:30px;' if cmeta[:key] == :checkbox
|
147
|
-
value_class << ' current_sort' if filter.column_sorted?(cmeta[:key])
|
152
|
+
value_class << ' current_sort' if filter and filter.column_sorted?(cmeta[:key])
|
148
153
|
|
149
154
|
if cmeta[:filterable]
|
150
155
|
filter_value = cmeta[:value].nil? ? value : obj.send(cmeta[:key])
|
@@ -202,3 +207,17 @@
|
|
202
207
|
}
|
203
208
|
}
|
204
209
|
</script>
|
210
|
+
|
211
|
+
<% else %>
|
212
|
+
|
213
|
+
<table class='wf_paginator' style="margin-top:10px; margin-bottom:10px;">
|
214
|
+
<tr>
|
215
|
+
<td style='text-align:left'>
|
216
|
+
No results found
|
217
|
+
</td>
|
218
|
+
<td style='text-align:right'>
|
219
|
+
</td>
|
220
|
+
</tr>
|
221
|
+
</table>
|
222
|
+
|
223
|
+
<% end %>
|
@@ -1,3 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
1
24
|
#############################################################################
|
2
25
|
# will_filter configuration
|
3
26
|
#
|
@@ -1,3 +1,26 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
1
24
|
class CreateWillFilterFilters < ActiveRecord::Migration
|
2
25
|
def change
|
3
26
|
create_table :will_filter_filters do |t|
|
data/lib/will_filter/calendar.rb
CHANGED
data/lib/will_filter/config.rb
CHANGED
data/lib/will_filter/engine.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -25,26 +25,39 @@ module WillFilter
|
|
25
25
|
module ActionViewExtension
|
26
26
|
extend ActiveSupport::Concern
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
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
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def will_filter_scripts_tag(opts = {})
|
33
|
+
render(:partial => "/will_filter/common/scripts", :locals => {:opts => opts})
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
def will_filter_table_tag(results, opts = {})
|
37
|
+
filter = results.wf_filter
|
38
|
+
if results.size > 0
|
39
|
+
opts[:columns] ||= (filter ? filter.model_column_keys : results.first.class.columns.collect{|col| col.name.to_sym})
|
40
|
+
else
|
41
|
+
opts[:columns] = []
|
40
42
|
end
|
43
|
+
render(:partial => "/will_filter/common/results_table", :locals => {:results => results, :filter => filter, :opts => opts})
|
44
|
+
end
|
45
|
+
|
46
|
+
def will_filter_actions_bar_tag(results, actions, opts = {})
|
47
|
+
filter = results.wf_filter
|
48
|
+
opts[:class] ||= "wf_actions_bar_blue"
|
49
|
+
opts[:style] ||= ""
|
50
|
+
render(:partial => "/will_filter/common/actions_bar", :locals => {:results => results, :filter => filter, :actions => actions, :opts => opts})
|
51
|
+
end
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
def will_filter_details_tag(obj, opts = {})
|
54
|
+
opts[:columns] ||= obj.attribute_names.sort
|
55
|
+
opts[:table_class] ||= "wf_details_table"
|
56
|
+
opts[:table_style] ||= ""
|
57
|
+
opts[:key_style] ||= "width:200px;"
|
58
|
+
opts[:value_style] ||= "text-align:left"
|
59
|
+
render(:partial => "/will_filter/common/details_table", :locals => {:object => obj, :opts => opts})
|
60
|
+
end
|
48
61
|
|
49
62
|
end
|
50
63
|
end
|
data/lib/will_filter/railtie.rb
CHANGED
data/lib/will_filter/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2013 Michael Berkovich
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -22,5 +22,5 @@
|
|
22
22
|
#++
|
23
23
|
|
24
24
|
module WillFilter
|
25
|
-
VERSION = "3.1.
|
25
|
+
VERSION = "3.1.10"
|
26
26
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -16,8 +16,8 @@ ActiveRecord::Schema.define(:version => 20120223232000) do
|
|
16
16
|
create_table "event_users", :force => true do |t|
|
17
17
|
t.integer "event_id"
|
18
18
|
t.integer "user_id"
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
19
|
+
t.datetime "created_at", :null => false
|
20
|
+
t.datetime "updated_at", :null => false
|
21
21
|
end
|
22
22
|
|
23
23
|
add_index "event_users", ["event_id", "user_id"], :name => "index_event_users_on_event_id_and_user_id"
|
@@ -31,8 +31,8 @@ ActiveRecord::Schema.define(:version => 20120223232000) do
|
|
31
31
|
t.string "headline"
|
32
32
|
t.datetime "start_time"
|
33
33
|
t.datetime "end_time"
|
34
|
-
t.datetime "created_at"
|
35
|
-
t.datetime "updated_at"
|
34
|
+
t.datetime "created_at", :null => false
|
35
|
+
t.datetime "updated_at", :null => false
|
36
36
|
t.float "rank"
|
37
37
|
end
|
38
38
|
|
@@ -42,15 +42,15 @@ ActiveRecord::Schema.define(:version => 20120223232000) do
|
|
42
42
|
t.integer "order_id"
|
43
43
|
t.string "name"
|
44
44
|
t.integer "price"
|
45
|
-
t.datetime "created_at"
|
46
|
-
t.datetime "updated_at"
|
45
|
+
t.datetime "created_at", :null => false
|
46
|
+
t.datetime "updated_at", :null => false
|
47
47
|
end
|
48
48
|
|
49
49
|
create_table "merchant_orders", :force => true do |t|
|
50
50
|
t.integer "user_id"
|
51
51
|
t.integer "amount"
|
52
|
-
t.datetime "created_at"
|
53
|
-
t.datetime "updated_at"
|
52
|
+
t.datetime "created_at", :null => false
|
53
|
+
t.datetime "updated_at", :null => false
|
54
54
|
end
|
55
55
|
|
56
56
|
create_table "users", :force => true do |t|
|
@@ -58,8 +58,8 @@ ActiveRecord::Schema.define(:version => 20120223232000) do
|
|
58
58
|
t.string "last_name"
|
59
59
|
t.date "birthday"
|
60
60
|
t.string "sex"
|
61
|
-
t.datetime "created_at"
|
62
|
-
t.datetime "updated_at"
|
61
|
+
t.datetime "created_at", :null => false
|
62
|
+
t.datetime "updated_at", :null => false
|
63
63
|
end
|
64
64
|
|
65
65
|
create_table "will_filter_filters", :force => true do |t|
|
@@ -68,8 +68,8 @@ ActiveRecord::Schema.define(:version => 20120223232000) do
|
|
68
68
|
t.text "data"
|
69
69
|
t.integer "user_id"
|
70
70
|
t.string "model_class_name"
|
71
|
-
t.datetime "created_at"
|
72
|
-
t.datetime "updated_at"
|
71
|
+
t.datetime "created_at", :null => false
|
72
|
+
t.datetime "updated_at", :null => false
|
73
73
|
end
|
74
74
|
|
75
75
|
add_index "will_filter_filters", ["user_id"], :name => "index_will_filter_filters_on_user_id"
|
data/will_filter.gemspec
CHANGED
@@ -20,15 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.licenses = ['MIT']
|
22
22
|
|
23
|
-
s.add_dependency 'rails', ['
|
24
|
-
s.add_dependency 'kaminari', ['
|
25
|
-
s.add_dependency 'sass', ['>= 0']
|
26
|
-
s.add_development_dependency 'pry', ['>= 0']
|
27
|
-
s.add_development_dependency 'bundler', ['>= 1.0.0']
|
28
|
-
s.add_development_dependency 'sqlite3', ['>= 0']
|
29
|
-
s.add_development_dependency 'rspec', ['>= 0']
|
30
|
-
s.add_development_dependency 'rspec-rails', ['>= 2.1.0']
|
31
|
-
s.add_development_dependency 'spork', ['>= 0']
|
32
|
-
s.add_development_dependency 'watchr', ['>= 0']
|
33
|
-
s.add_development_dependency 'rr', ['>= 0']
|
23
|
+
s.add_dependency 'rails', ['~> 3.2.3']
|
24
|
+
s.add_dependency 'kaminari', ['~> 0.13.0']
|
34
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,129 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 3.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: kaminari
|
27
|
-
requirement: &2157123600 !ruby/object:Gem::Requirement
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
25
|
none: false
|
29
26
|
requirements:
|
30
|
-
- -
|
27
|
+
- - ~>
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *2157123600
|
29
|
+
version: 3.2.3
|
36
30
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
31
|
+
name: kaminari
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
34
|
requirements:
|
41
|
-
- -
|
35
|
+
- - ~>
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
37
|
+
version: 0.13.0
|
44
38
|
type: :runtime
|
45
39
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: pry
|
49
|
-
requirement: &2157121060 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *2157121060
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: bundler
|
60
|
-
requirement: &2157119180 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ! '>='
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.0.0
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *2157119180
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sqlite3
|
71
|
-
requirement: &2157117660 !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
|
-
requirements:
|
74
|
-
- - ! '>='
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: *2157117660
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rspec
|
82
|
-
requirement: &2157116020 !ruby/object:Gem::Requirement
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
41
|
none: false
|
84
42
|
requirements:
|
85
|
-
- -
|
43
|
+
- - ~>
|
86
44
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
88
|
-
type: :development
|
89
|
-
prerelease: false
|
90
|
-
version_requirements: *2157116020
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: rspec-rails
|
93
|
-
requirement: &2157113260 !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
|
-
requirements:
|
96
|
-
- - ! '>='
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: 2.1.0
|
99
|
-
type: :development
|
100
|
-
prerelease: false
|
101
|
-
version_requirements: *2157113260
|
102
|
-
- !ruby/object:Gem::Dependency
|
103
|
-
name: spork
|
104
|
-
requirement: &2157110820 !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: *2157110820
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: watchr
|
115
|
-
requirement: &2157107520 !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
|
-
requirements:
|
118
|
-
- - ! '>='
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
version: '0'
|
121
|
-
type: :development
|
122
|
-
prerelease: false
|
123
|
-
version_requirements: *2157107520
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: rr
|
126
|
-
requirement: &2157106320 !ruby/object:Gem::Requirement
|
127
|
-
none: false
|
128
|
-
requirements:
|
129
|
-
- - ! '>='
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: *2157106320
|
45
|
+
version: 0.13.0
|
135
46
|
description: will_filter is a powerful customizable framework for filtering active_record
|
136
47
|
models.
|
137
48
|
email:
|
@@ -178,6 +89,7 @@ files:
|
|
178
89
|
- app/views/will_filter/calendar/_quarter.html.erb
|
179
90
|
- app/views/will_filter/calendar/index.html.erb
|
180
91
|
- app/views/will_filter/common/_actions_bar.html.erb
|
92
|
+
- app/views/will_filter/common/_details_table.html.erb
|
181
93
|
- app/views/will_filter/common/_results_table.html.erb
|
182
94
|
- app/views/will_filter/common/_results_table_summary.html.erb
|
183
95
|
- app/views/will_filter/common/_scripts.html.erb
|
@@ -340,21 +252,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
340
252
|
- - ! '>='
|
341
253
|
- !ruby/object:Gem::Version
|
342
254
|
version: '0'
|
343
|
-
segments:
|
344
|
-
- 0
|
345
|
-
hash: 2634563707694904433
|
346
255
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
347
256
|
none: false
|
348
257
|
requirements:
|
349
258
|
- - ! '>='
|
350
259
|
- !ruby/object:Gem::Version
|
351
260
|
version: '0'
|
352
|
-
segments:
|
353
|
-
- 0
|
354
|
-
hash: 2634563707694904433
|
355
261
|
requirements: []
|
356
262
|
rubyforge_project:
|
357
|
-
rubygems_version: 1.8.
|
263
|
+
rubygems_version: 1.8.23
|
358
264
|
signing_key:
|
359
265
|
specification_version: 3
|
360
266
|
summary: A filtering engine plugin for Rails 3.1
|