filter_form 0.8.0 → 0.8.1
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.
- checksums.yaml +4 -4
- data/lib/filter_form/input_options/base.rb +13 -2
- data/lib/filter_form/input_options/checkbox/base.rb +4 -2
- data/lib/filter_form/input_options/number/money.rb +3 -1
- data/lib/filter_form/version.rb +1 -1
- data/spec/fixtures/locale.yml +1 -0
- data/spec/models/input_options_builder_spec.rb +12 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bdd28148acf26ef60072eae5ad45e275b4c2299
|
4
|
+
data.tar.gz: 3ba9fe6625752961a0dfd497c9e3d70474d44e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be205121e2fb7611e75a85bedfdfb216870fd7c733cb42621a8a9d624d5be7c1a818a529f371c04aeb6c02cc5640fbda692c59841920024d747e47ee8c304b48
|
7
|
+
data.tar.gz: 451d19c190406e4f9ef48ede4ed448ca8b41e6caea2795d05195cc8857e8432199438cf8fd389701a2303a2b7ecbbb4dcaffdd460efec6c0f83a70eeaa11e88e
|
@@ -2,6 +2,7 @@ module FilterForm
|
|
2
2
|
module InputOptions
|
3
3
|
class Base
|
4
4
|
DEFAULT_PREDICATE = nil
|
5
|
+
PREDICATE_IN = :in
|
5
6
|
|
6
7
|
attr_accessor :attribute_name, :object, :custom_predicate, :options
|
7
8
|
|
@@ -84,8 +85,14 @@ module FilterForm
|
|
84
85
|
nil
|
85
86
|
end
|
86
87
|
|
88
|
+
def multiple?
|
89
|
+
options[:input_html].try(:[], :multiple)
|
90
|
+
end
|
91
|
+
|
87
92
|
def input_name
|
88
|
-
"q[#{ input_attribute_name }_#{ predicate }]"
|
93
|
+
result = "q[#{ input_attribute_name }_#{ predicate }]"
|
94
|
+
result << "[]" if multiple?
|
95
|
+
result
|
89
96
|
end
|
90
97
|
|
91
98
|
def input_value
|
@@ -106,8 +113,12 @@ module FilterForm
|
|
106
113
|
attribute_name
|
107
114
|
end
|
108
115
|
|
116
|
+
def default_predicate
|
117
|
+
multiple? ? PREDICATE_IN : self.class::DEFAULT_PREDICATE
|
118
|
+
end
|
119
|
+
|
109
120
|
def predicate
|
110
|
-
custom_predicate ||
|
121
|
+
custom_predicate || default_predicate
|
111
122
|
end
|
112
123
|
end
|
113
124
|
end
|
@@ -4,10 +4,12 @@ module FilterForm
|
|
4
4
|
class Base < FilterForm::InputOptions::Base
|
5
5
|
include FilterForm::InputOptions::Shared::WithAssociations
|
6
6
|
|
7
|
-
DEFAULT_PREDICATE = :in
|
8
|
-
|
9
7
|
private
|
10
8
|
|
9
|
+
def default_predicate
|
10
|
+
PREDICATE_IN
|
11
|
+
end
|
12
|
+
|
11
13
|
def additional_options
|
12
14
|
{
|
13
15
|
as: :check_boxes,
|
data/lib/filter_form/version.rb
CHANGED
data/spec/fixtures/locale.yml
CHANGED
@@ -22,15 +22,20 @@ describe FilterForm::InputOptionsBuilder do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'string' do
|
25
|
-
before do
|
26
|
-
builder.attribute_name = :name
|
27
|
-
end
|
28
|
-
|
29
25
|
context 'default predicate' do
|
30
26
|
it 'returns correct options with predicate "cont"' do
|
31
|
-
|
32
|
-
|
33
|
-
expect(
|
27
|
+
builder.attribute_name = :name
|
28
|
+
|
29
|
+
expect(builder.build).to eq({ as: :string, required: false, label: 'NAME CONTAINS', input_html: { name: 'q[name_cont]' } })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "multiple" do
|
34
|
+
it "returns attribute name as array with default predicate 'in'" do
|
35
|
+
builder.attribute_name = :name
|
36
|
+
result = builder.build(input_html: { multiple: true })
|
37
|
+
|
38
|
+
expect(result).to eq({ as: :string, required: false, label: "NAME IN", input_html: { name: "q[name_in][]", multiple: true } })
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filter_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|