filter_form 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/filter_form/input_options/base.rb +7 -1
- data/lib/filter_form/input_options/checkbox/base.rb +2 -0
- data/lib/filter_form/input_options/number/base.rb +2 -0
- data/lib/filter_form/input_options/select/base.rb +2 -0
- data/lib/filter_form/input_options/string/base.rb +2 -0
- data/lib/filter_form/input_options_builder.rb +1 -14
- data/lib/filter_form/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dcaf4e227c17f563b101cefe9a484d9fd066d48
|
4
|
+
data.tar.gz: 7bdd04c0838a27f3e04789a51de8b73e0d4b3d80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f17dca9f965ebf77df3b5b2c7cbb6982cd706e0f41f20573d24c0076aba27896f769124aefac747d9ff03e401a0d2fb4f5c82a1938fdbaeb175f7c427c0dee7
|
7
|
+
data.tar.gz: ccfbb999edd00621a83ff4e968816572cbab2667ef9c40c340f6205b78ad0568de7e8e305b88963442c1b5e08d2669c1cd23a28b9aef2938b24531933ec82310
|
data/README.md
CHANGED
@@ -33,13 +33,13 @@ In your view file:
|
|
33
33
|
|
34
34
|
```erb
|
35
35
|
<%= filter_form_for @q do |f| %>
|
36
|
+
<%= f.filter_input :married # boolean %>
|
36
37
|
<%= f.filter_input :name # string %>
|
37
38
|
<%= f.filter_input :age # integer %>
|
39
|
+
<%= f.filter_input :birthday # date %>
|
38
40
|
<%= f.filter_input :city # belongs_to %>
|
39
41
|
<%= f.filter_input :parents # has_many %>
|
40
|
-
<%= f.filter_input :birthday # date %>
|
41
42
|
<%= f.filter_input :amount # money %>
|
42
|
-
<%= f.filter_input :married # boolean %>
|
43
43
|
<%= f.button :submit %>
|
44
44
|
<% end %>
|
45
45
|
```
|
@@ -3,7 +3,9 @@ module FilterForm
|
|
3
3
|
class Base
|
4
4
|
include ActiveModel::Model
|
5
5
|
|
6
|
-
|
6
|
+
DEFAULT_PREDICATE = nil
|
7
|
+
|
8
|
+
attr_accessor :attribute_name, :object, :custom_predicate, :options
|
7
9
|
|
8
10
|
def simple_form_options
|
9
11
|
default_options.merge(additional_options).merge(options)
|
@@ -81,6 +83,10 @@ module FilterForm
|
|
81
83
|
def input_attribute_name
|
82
84
|
attribute_name
|
83
85
|
end
|
86
|
+
|
87
|
+
def predicate
|
88
|
+
custom_predicate || self.class::DEFAULT_PREDICATE
|
89
|
+
end
|
84
90
|
end
|
85
91
|
end
|
86
92
|
end
|
@@ -17,7 +17,7 @@ module FilterForm
|
|
17
17
|
attr_accessor :attribute_name, :object, :custom_predicate, :custom_type
|
18
18
|
|
19
19
|
def build(options)
|
20
|
-
input_options_class.new(attribute_name: attribute_name, object: object,
|
20
|
+
input_options_class.new(attribute_name: attribute_name, object: object, custom_predicate: custom_predicate, options: options).simple_form_options
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
@@ -34,19 +34,6 @@ module FilterForm
|
|
34
34
|
"FilterForm::InputOptions::#{ class_name }".constantize
|
35
35
|
end
|
36
36
|
|
37
|
-
def predicate
|
38
|
-
return custom_predicate if custom_predicate
|
39
|
-
|
40
|
-
case type
|
41
|
-
when :string
|
42
|
-
:cont
|
43
|
-
when :boolean
|
44
|
-
:true
|
45
|
-
else
|
46
|
-
:eq
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
37
|
def type
|
51
38
|
custom_type ? map_type(custom_type) : map_type(attribute_type)
|
52
39
|
end
|
data/lib/filter_form/version.rb
CHANGED