will_filter 3.1.3 → 3.1.5
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/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/Gemfile.lock +2 -2
- data/README.rdoc +0 -3
- data/app/assets/javascripts/will_filter/filter.js +5 -5
- data/app/assets/javascripts/will_filter/filter_prototype_effects.js +1 -1
- data/app/assets/stylesheets/will_filter/exporter.css.scss +72 -49
- data/app/assets/stylesheets/will_filter/filter.css.scss +1 -0
- data/app/controllers/will_filter/application_controller.rb +1 -1
- data/app/controllers/will_filter/calendar_controller.rb +1 -1
- data/app/controllers/will_filter/exporter_controller.rb +15 -26
- data/app/controllers/will_filter/filter_controller.rb +7 -1
- data/app/models/will_filter/filter.rb +69 -12
- data/app/views/will_filter/exporter/export.html.erb +26 -2
- data/app/views/will_filter/exporter/index.html.erb +35 -43
- data/app/views/will_filter/filter/_conditions.html.erb +13 -32
- data/app/views/will_filter/filter/_conditions_footer.html.erb +17 -0
- data/app/views/will_filter/filter/_conditions_header.html.erb +38 -0
- data/app/views/will_filter/filter/_container.html.erb +3 -25
- data/lib/generators/will_filter/templates/config.yml +34 -1
- data/lib/generators/will_filter/will_filter_generator.rb +1 -1
- data/lib/tasks/will_filter_tasks.rake +1 -5
- data/lib/will_filter.rb +1 -1
- data/lib/will_filter/calendar.rb +1 -1
- data/lib/will_filter/config.rb +9 -1
- data/lib/will_filter/containers/boolean.rb +1 -1
- data/lib/will_filter/containers/date.rb +2 -8
- data/lib/will_filter/containers/date_range.rb +3 -9
- data/lib/will_filter/containers/date_time.rb +2 -8
- data/lib/will_filter/containers/date_time_range.rb +4 -16
- data/lib/will_filter/containers/double.rb +52 -0
- data/lib/will_filter/containers/double_delimited.rb +50 -0
- data/lib/will_filter/containers/double_range.rb +64 -0
- 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 +3 -3
- 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 +1 -1
- 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 +21 -3
- 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/spec/containers/double_spec.rb +16 -0
- data/spec/fake_app.rb +6 -12
- data/test/dummy/app/models/event.rb +1 -1
- data/test/dummy/app/models/event_filter.rb +4 -0
- data/test/dummy/app/models/event_user_filter.rb +4 -0
- data/test/dummy/app/models/user_filter.rb +31 -2
- data/test/dummy/config/will_filter/config.yml +9 -1
- data/test/dummy/db/migrate/20120223232000_add_rank_to_events.rb +5 -0
- data/test/dummy/db/schema.rb +2 -1
- metadata +40 -108
- data/config/will_filter/config.yml +0 -97
- data/db/migrate/20110924023807_create_will_filter_filters.rb +0 -15
@@ -3,9 +3,33 @@
|
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
5
5
|
<title>Filter Export Data Table</title>
|
6
|
-
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
font:Arial 12pt;
|
9
|
+
}
|
10
|
+
th {
|
11
|
+
padding:5px;
|
12
|
+
border-bottom:1px solid #ccc;
|
13
|
+
}
|
14
|
+
td {
|
15
|
+
padding:5px;
|
16
|
+
}
|
17
|
+
</style>
|
7
18
|
</head>
|
8
19
|
<body>
|
9
|
-
|
20
|
+
<table>
|
21
|
+
<tr>
|
22
|
+
<% @wf_filter.fields.each do |field| %>
|
23
|
+
<th><%=field %></th>
|
24
|
+
<% end %>
|
25
|
+
</tr>
|
26
|
+
<% @wf_filter.results.each do |obj| %>
|
27
|
+
<tr>
|
28
|
+
<% @wf_filter.fields.each do |field| %>
|
29
|
+
<td><%=obj.send(field).to_s %></td>
|
30
|
+
<% end %>
|
31
|
+
</tr>
|
32
|
+
<% end %>
|
33
|
+
</table>
|
10
34
|
</body>
|
11
35
|
</html>
|
@@ -1,47 +1,39 @@
|
|
1
|
-
<div
|
2
|
-
<div
|
3
|
-
<%=link_to_function(
|
1
|
+
<div class="wf_exporter_header">
|
2
|
+
<div class="end">
|
3
|
+
<%=link_to_function("×".html_safe, "wfExporter.hide()", :title=>"Close", :class => "close")%>
|
4
4
|
</div>
|
5
|
-
|
6
5
|
Exporter
|
7
|
-
</div>
|
6
|
+
</div>
|
7
|
+
|
8
8
|
<div class="wf_exporter_container">
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
<hr>
|
40
|
-
<div style="text-align:center; width:100%; padding:3px;">
|
41
|
-
Format: <%= select_tag("wf_export_format_selector", options_for_select(@wf_filter.export_formats, @wf_filter.format)) %>
|
42
|
-
</div>
|
43
|
-
<div style="text-align:center; width:100%; padding:3px;">
|
44
|
-
<%=link_to_function("<span>Export</span>".html_safe, "wfExporter.exportFilter()", :class => "wf_grey_button wf_pcb") %>
|
45
|
-
<%=link_to_function("<span>Cancel</span>".html_safe, "wfExporter.hide()", :class => "wf_grey_button wf_pcb") %>
|
46
|
-
</div>
|
9
|
+
|
10
|
+
<table style="width:100%" cellpadding="0px" cellspacing="0px;">
|
11
|
+
<thead>
|
12
|
+
<tr>
|
13
|
+
<td><input type="checkbox" id="wf_fld_all" onClick="wfExporter.selectAllFields(this);" style="width:20px;"></td>
|
14
|
+
<td>Name</td>
|
15
|
+
<td>Type</td>
|
16
|
+
</tr>
|
17
|
+
</thead>
|
18
|
+
<tbody>
|
19
|
+
<% @wf_filter.model_class.columns.each_with_index do |col, index| %>
|
20
|
+
<tr>
|
21
|
+
<td>
|
22
|
+
<input type="checkbox" id="wf_fld_chk_<%=index%>" onClick="wfExporter.selectField(this);" style="width:20px;"><input type="hidden" id="wf_fld_name_<%=index%>" value="<%=col.name%>">
|
23
|
+
</td>
|
24
|
+
<td><%=col.name %></td>
|
25
|
+
<td><%=col.type %></td>
|
26
|
+
</tr>
|
27
|
+
<% end %>
|
28
|
+
</tbody>
|
29
|
+
</table>
|
30
|
+
|
31
|
+
<hr>
|
32
|
+
<div class="center">
|
33
|
+
Format: <%= select_tag("wf_export_format_selector", options_for_select(@wf_filter.export_formats, @wf_filter.format)) %>
|
34
|
+
</div>
|
35
|
+
<div class="center">
|
36
|
+
<%=link_to_function("<span>Export</span>".html_safe, "wfExporter.exportFilter()", :class => "wf_grey_button wf_pcb") %>
|
37
|
+
<%=link_to_function("<span>Cancel</span>".html_safe, "wfExporter.hide()", :class => "wf_grey_button wf_pcb") %>
|
38
|
+
</div>
|
47
39
|
</div>
|
@@ -1,31 +1,5 @@
|
|
1
|
-
<div style="margin:0;padding:0;display:inline">
|
2
|
-
<%= hidden_field_tag(:wf_id, wf_filter.id) %>
|
3
|
-
<%= hidden_field_tag(:wf_type, wf_filter.class.name) %>
|
4
|
-
<%= hidden_field_tag(:wf_dirty, "false") %>
|
5
|
-
<%= hidden_field_tag(:wf_submitted, "false") %>
|
6
|
-
<%= hidden_field_tag(:wf_name, wf_filter.name) %>
|
7
|
-
<%= hidden_field_tag(:wf_model, wf_filter.model_class_name) %>
|
8
|
-
<%= hidden_field_tag(:wf_export_format, "") %>
|
9
|
-
<%= hidden_field_tag(:wf_export_fields, "") %>
|
10
|
-
</div>
|
11
1
|
|
12
|
-
|
13
|
-
<% if wf_filter.show_save_options? %>
|
14
|
-
<div class="end">
|
15
|
-
<%=link_to_function("<span>Save As New...</span>".html_safe, "wfFilter.saveFilter()", :class => "wf_grey_button wf_pcb") %>
|
16
|
-
<%=link_to_function("<span>Update</span>".html_safe, "wfFilter.updateFilter()", :class => "wf_grey_button wf_pcb") %>
|
17
|
-
<%=link_to_function("<span>Delete</span>".html_safe, "wfFilter.deleteFilter()", :class => "wf_grey_button wf_pcb") %>
|
18
|
-
<% if wf_filter.show_export_options? %>
|
19
|
-
<%=link_to_function("<span>Export Data...</span>".html_safe, "wfExporter.show(this)", :class => "wf_grey_button wf_pcb") %>
|
20
|
-
<% end %>
|
21
|
-
</div>
|
22
|
-
<% end %>
|
23
|
-
<div>
|
24
|
-
<% unless wf_filter.saved_filters.empty? %>
|
25
|
-
<%= select_tag(:wf_key, options_for_select(wf_filter.saved_filters, wf_filter.key), {:onChange=>"wfFilter.loadSavedFilter()"}) %>
|
26
|
-
<% end %>
|
27
|
-
</div>
|
28
|
-
</div>
|
2
|
+
<%= render :partial => '/will_filter/filter/conditions_header', :locals => {:wf_filter => wf_filter} %>
|
29
3
|
|
30
4
|
<div class="body">
|
31
5
|
|
@@ -36,6 +10,11 @@
|
|
36
10
|
<% end %>
|
37
11
|
|
38
12
|
<div class="filter_match_type">
|
13
|
+
<div class="end">
|
14
|
+
<small>
|
15
|
+
<%=link_to_function("Toggle Conditions", "wfFilter.toggleDebugger()") %>
|
16
|
+
</small>
|
17
|
+
</div>
|
39
18
|
Match <%= select_tag(:wf_match, options_for_select(wf_filter.match_options, wf_filter.match), {:onChange=>"wfFilter.markDirty()"}) %>
|
40
19
|
of the following conditions:
|
41
20
|
</div>
|
@@ -48,13 +27,15 @@
|
|
48
27
|
</div>
|
49
28
|
<% else %>
|
50
29
|
<table class="table" cellpadding="0" cellspacing="0">
|
51
|
-
<%
|
52
|
-
|
53
|
-
|
54
|
-
%>
|
55
|
-
<%= render :partial => "/will_filter/filter/condition", :locals => {:wf_filter => wf_filter, :condition => condition, :index => index}%>
|
30
|
+
<% 0.upto(wf_filter.size-1) do |index| %>
|
31
|
+
<% condition = wf_filter.condition_at(index) %>
|
32
|
+
<%= render :partial => "/will_filter/filter/condition", :locals => {:wf_filter => wf_filter, :condition => condition, :index => index}%>
|
56
33
|
<% end %>
|
57
34
|
</table>
|
58
35
|
<% end %>
|
59
36
|
|
37
|
+
<div id="wf_debugger" class="debugger" style="display:none;">
|
38
|
+
<%= raw(wf_filter.debug_sql_conditions) %>
|
39
|
+
</div>
|
40
|
+
|
60
41
|
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="actions">
|
2
|
+
Order:
|
3
|
+
<%= select_tag(:wf_order, options_for_select(wf_filter.condition_options, wf_filter.order), {:onChange=>"markDirty()"}) %>
|
4
|
+
<%= select_tag(:wf_order_type, options_for_select(wf_filter.order_type_options, wf_filter.order_type), {:onChange=>"markDirty()"}) %>
|
5
|
+
Per Page:
|
6
|
+
<%= select_tag(:wf_per_page, options_for_select(wf_filter.per_page_options, wf_filter.per_page.to_s), {:onChange=>"markDirty()"}) %>
|
7
|
+
|
8
|
+
<%=link_to_function("<span>Submit Filter</span>".html_safe, "wfFilter.submit()", :class => "wf_grey_button wf_pcb") %>
|
9
|
+
</div>
|
10
|
+
<div>
|
11
|
+
<%=link_to_function("<span><b>+</b> Add</span>".html_safe, "wfFilter.addCondition()", :class => "wf_grey_button wf_pcb") %>
|
12
|
+
<%=link_to_function("<span>Clear</span>".html_safe, "wfFilter.removeAllConditions()", :class => "wf_grey_button wf_pcb") %>
|
13
|
+
|
14
|
+
<span id="wf_loader" class="spinner" style="display:none;">
|
15
|
+
<%=image_tag "will_filter/spinner.gif" %> Loading...
|
16
|
+
</span>
|
17
|
+
</div>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div style="margin:0;padding:0;display:inline">
|
2
|
+
<%= hidden_field_tag(:wf_id, wf_filter.id) %>
|
3
|
+
<%= hidden_field_tag(:wf_type, wf_filter.class.name) %>
|
4
|
+
<%= hidden_field_tag(:wf_dirty, "false") %>
|
5
|
+
<%= hidden_field_tag(:wf_submitted, "false") %>
|
6
|
+
<%= hidden_field_tag(:wf_name, wf_filter.name) %>
|
7
|
+
|
8
|
+
<% unless WillFilter::Config.require_filter_extensions? %>
|
9
|
+
<%= hidden_field_tag(:wf_model, wf_filter.model_class_name) %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= hidden_field_tag(:wf_export_format, "") %>
|
13
|
+
<%= hidden_field_tag(:wf_export_fields, "") %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="header">
|
17
|
+
<% if wf_filter.show_export_options? %>
|
18
|
+
<div class="end" style="padding-left:3px;">
|
19
|
+
<%=link_to_function("<span>Export Data...</span>".html_safe, "wfExporter.show(this)", :class => "wf_grey_button wf_pcb") %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<% if wf_filter.show_save_options? %>
|
24
|
+
<div class="end">
|
25
|
+
<%=link_to_function("<span>Save As New...</span>".html_safe, "wfFilter.saveFilter()", :class => "wf_grey_button wf_pcb") %>
|
26
|
+
<% if params[:wf_id] %>
|
27
|
+
<%=link_to_function("<span>Update</span>".html_safe, "wfFilter.updateFilter()", :class => "wf_grey_button wf_pcb") %>
|
28
|
+
<%=link_to_function("<span>Delete</span>".html_safe, "wfFilter.deleteFilter()", :class => "wf_grey_button wf_pcb") %>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<div>
|
34
|
+
<% unless wf_filter.saved_filters.empty? %>
|
35
|
+
<%= select_tag(:wf_key, options_for_select(wf_filter.saved_filters, wf_filter.key), {:onChange=>"wfFilter.loadSavedFilter()"}) %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
</div>
|
@@ -2,36 +2,14 @@
|
|
2
2
|
|
3
3
|
<%= form_tag({}, {:method => :get, :name=>'wf_form', :id => 'wf_form', :class => 'wf_form' }) do %>
|
4
4
|
<div class="wf_container">
|
5
|
+
|
5
6
|
<div id="wf_filter_conditions" class="conditions">
|
6
|
-
|
7
|
+
<%= render :partial=> '/will_filter/filter/conditions', :locals => { :wf_filter => wf_filter } %>
|
7
8
|
</div>
|
8
9
|
|
9
10
|
<div class="footer">
|
10
|
-
|
11
|
-
<small>
|
12
|
-
<%=link_to_function("Toggle Conditions", "wfFilter.toggleDebugger()") %>
|
13
|
-
</small>
|
14
|
-
|
15
|
-
Order:
|
16
|
-
<%= select_tag(:wf_order, options_for_select(wf_filter.condition_options, wf_filter.order), {:onChange=>"markDirty()"}) %>
|
17
|
-
<%= select_tag(:wf_order_type, options_for_select(wf_filter.order_type_options, wf_filter.order_type), {:onChange=>"markDirty()"}) %>
|
18
|
-
Per Page:
|
19
|
-
<%= select_tag(:wf_per_page, options_for_select(wf_filter.per_page_options, wf_filter.per_page.to_s), {:onChange=>"markDirty()"}) %>
|
20
|
-
|
21
|
-
<%=link_to_function("<span>Submit Filter</span>".html_safe, "wfFilter.submit()", :class => "wf_grey_button wf_pcb") %>
|
22
|
-
</div>
|
23
|
-
<div>
|
24
|
-
<%=link_to_function("<span>+ Add</span>".html_safe, "wfFilter.addCondition()", :class => "wf_grey_button wf_pcb") %>
|
25
|
-
<%=link_to_function("<span>- Clear</span>".html_safe, "wfFilter.removeAllConditions()", :class => "wf_grey_button wf_pcb") %>
|
26
|
-
|
27
|
-
<span id="wf_loader" class="spinner" style="display:none;">
|
28
|
-
<%=image_tag "will_filter/spinner.gif" %> Loading...
|
29
|
-
</span>
|
30
|
-
</div>
|
11
|
+
<%= render :partial => '/will_filter/filter/conditions_footer', :locals => { :wf_filter => wf_filter } %>
|
31
12
|
</div>
|
32
13
|
|
33
|
-
<div id="wf_debugger" class="debugger" style="display:none;">
|
34
|
-
<%= raw(wf_filter.debug_sql_conditions) %>
|
35
|
-
</div>
|
36
14
|
</div>
|
37
15
|
<% end %>
|
@@ -10,6 +10,34 @@
|
|
10
10
|
#############################################################################
|
11
11
|
|
12
12
|
defaults: &defaults
|
13
|
+
|
14
|
+
###########################################################################
|
15
|
+
#
|
16
|
+
# require_filter_extension makes the filter into an abstract class
|
17
|
+
# and will require you to subclass it in order for the filter to be
|
18
|
+
# serializeable. The following will no longer work:
|
19
|
+
#
|
20
|
+
# @users = User.filter(:params => params)
|
21
|
+
#
|
22
|
+
# Use your own filter class instead:
|
23
|
+
#
|
24
|
+
# @users = User.filter(:params => params, :filter => UserFilter)
|
25
|
+
#
|
26
|
+
# In the subclass you must provide the model name to be filtered by overloading:
|
27
|
+
#
|
28
|
+
# def model_class
|
29
|
+
# User
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
###########################################################################
|
33
|
+
|
34
|
+
require_filter_extensions: false
|
35
|
+
|
36
|
+
###########################################################################
|
37
|
+
# If you would like to see some JavaScript effects
|
38
|
+
# provide your own effects class and implement required methods
|
39
|
+
###########################################################################
|
40
|
+
|
13
41
|
effects_options:
|
14
42
|
enabled: false
|
15
43
|
script_path: "will_filter/filter_prototype_effects.js"
|
@@ -29,6 +57,9 @@ defaults: &defaults
|
|
29
57
|
numeric: WillFilter::Containers::Numeric
|
30
58
|
numeric_range: WillFilter::Containers::NumericRange
|
31
59
|
numeric_delimited: WillFilter::Containers::NumericDelimited
|
60
|
+
double: WillFilter::Containers::Double
|
61
|
+
double_range: WillFilter::Containers::DoubleRange
|
62
|
+
double_delimited: WillFilter::Containers::DoubleDelimited
|
32
63
|
date_time_range: WillFilter::Containers::DateTimeRange
|
33
64
|
single_date: WillFilter::Containers::SingleDate
|
34
65
|
date: WillFilter::Containers::Date
|
@@ -46,10 +77,12 @@ defaults: &defaults
|
|
46
77
|
smallint: [nil, numeric, numeric_range, numeric_delimited]
|
47
78
|
integer: [nil, numeric, numeric_range, numeric_delimited]
|
48
79
|
int: [nil, numeric, numeric_range, numeric_delimited]
|
49
|
-
|
80
|
+
float: [nil, double, double_range, double_delimited]
|
81
|
+
double: [nil, double, double_range, double_delimited]
|
50
82
|
timestamp: [nil, date_time, date_time_range, single_date]
|
51
83
|
datetime: [nil, date_time, date_time_range, single_date]
|
52
84
|
date: [nil, date, date_range]
|
85
|
+
char: [nil, text, text_delimited]
|
53
86
|
character: [nil, text, text_delimited]
|
54
87
|
varchar: [nil, text, text_delimited]
|
55
88
|
text: [nil, text, text_delimited]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2012 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
|
@@ -23,9 +23,5 @@
|
|
23
23
|
|
24
24
|
namespace :will_filter do
|
25
25
|
|
26
|
-
desc "Sync extra files from will_filter plugin."
|
27
|
-
task :sync do
|
28
|
-
system "rsync -ruv vendor/plugins/will_filter/config/wf ./config"
|
29
|
-
end
|
30
26
|
|
31
27
|
end
|
data/lib/will_filter.rb
CHANGED
data/lib/will_filter/calendar.rb
CHANGED
data/lib/will_filter/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c) 2010-
|
2
|
+
# Copyright (c) 2010-2012 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
|
@@ -44,6 +44,14 @@ module WillFilter
|
|
44
44
|
@config ||= load_yml("/config/will_filter/config.yml")
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.require_filter_extensions?
|
48
|
+
config[:require_filter_extensions]
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.disable_filter_saving?
|
52
|
+
config[:disable_filter_saving]
|
53
|
+
end
|
54
|
+
|
47
55
|
def self.effects_options
|
48
56
|
config[:effects_options]
|
49
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 2010-2012 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
|
@@ -30,13 +30,7 @@ module WillFilter
|
|
30
30
|
|
31
31
|
def validate
|
32
32
|
return "Value must be provided" if value.blank?
|
33
|
-
return "Value must be a valid date (2008-01-01)" if date
|
34
|
-
end
|
35
|
-
|
36
|
-
def date
|
37
|
-
@date ||= Time.parse(value).to_date
|
38
|
-
rescue ArgumentError
|
39
|
-
nil
|
33
|
+
return "Value must be a valid date (2008-01-01)" if date.nil?
|
40
34
|
end
|
41
35
|
|
42
36
|
def sql_condition
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 2010-2012 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
|
@@ -36,15 +36,9 @@ module WillFilter
|
|
36
36
|
|
37
37
|
def validate
|
38
38
|
return "Start value must be provided" if @start_date.blank?
|
39
|
-
return "Start value must be a valid date (2008-01-01)" if date(@start_date)
|
39
|
+
return "Start value must be a valid date (2008-01-01)" if date(@start_date).nil?
|
40
40
|
return "End value must be provided" if @end_date.blank?
|
41
|
-
return "End value must be a valid date (2008-01-01)" if date(@end_date)
|
42
|
-
end
|
43
|
-
|
44
|
-
def date(dt)
|
45
|
-
Time.parse(dt).to_date
|
46
|
-
rescue ArgumentError
|
47
|
-
nil
|
41
|
+
return "End value must be a valid date (2008-01-01)" if date(@end_date).nil?
|
48
42
|
end
|
49
43
|
|
50
44
|
def sql_condition
|