filter_form 0.8.2 → 0.8.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61f48ddb9a951f24ca2c7f1c637f8c46387ebb63
|
4
|
+
data.tar.gz: a44a6a392a2f1714c06ce37d3eb83f20d8c89e3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 912056cb716eabd7eb85bb4182cfbffb18819cc202c396f62b8001c2b3b637b0a124ba7acb788f8c26c49f1499e0696d95a1c3d268551f97359e9291b2e8dc6a
|
7
|
+
data.tar.gz: 612c03cae32f18acf25a6543bc03c33597a442387582b435f08638437a28f092c808b612639e8fe212db3b3dba9e166ae038a3566fcdee9d0a1f42e1a0948a2f
|
@@ -101,10 +101,10 @@ module FilterForm
|
|
101
101
|
|
102
102
|
def object_condition
|
103
103
|
if options[:predicate_selector]
|
104
|
-
object.base.conditions.select { |condition| condition.a.first.name == input_attribute_name
|
104
|
+
object.base.conditions.select { |condition| condition.a.first.name == input_attribute_name }.first
|
105
105
|
else
|
106
106
|
object.base.conditions.select do |condition|
|
107
|
-
condition.a.first.name == input_attribute_name
|
107
|
+
condition.a.first.name == input_attribute_name && condition.predicate.name == predicate.to_s
|
108
108
|
end.first
|
109
109
|
end
|
110
110
|
end
|
@@ -12,13 +12,14 @@ require 'filter_form/input_options/datetime/base'
|
|
12
12
|
|
13
13
|
module FilterForm
|
14
14
|
class InputOptionsBuilder
|
15
|
-
attr_accessor :
|
15
|
+
attr_accessor :object, :custom_predicate, :custom_type
|
16
|
+
attr_reader :attribute_name
|
16
17
|
|
17
18
|
def initialize(options)
|
18
|
-
@attribute_name = options[:attribute_name]
|
19
19
|
@object = options[:object]
|
20
20
|
@custom_predicate = options[:custom_predicate]
|
21
21
|
@custom_type = options[:custom_type]
|
22
|
+
self.attribute_name = options[:attribute_name]
|
22
23
|
end
|
23
24
|
|
24
25
|
|
@@ -26,6 +27,10 @@ module FilterForm
|
|
26
27
|
input_options_class.new(attribute_name: attribute_name, object: object, custom_predicate: custom_predicate, options: options).simple_form_options
|
27
28
|
end
|
28
29
|
|
30
|
+
def attribute_name=(new_attribute_name)
|
31
|
+
@attribute_name = new_attribute_name.to_s
|
32
|
+
end
|
33
|
+
|
29
34
|
private
|
30
35
|
|
31
36
|
def input_options_class
|
@@ -77,7 +82,7 @@ module FilterForm
|
|
77
82
|
elsif money?
|
78
83
|
:money
|
79
84
|
else
|
80
|
-
object.klass.columns_hash[attribute_name
|
85
|
+
object.klass.columns_hash[attribute_name].type
|
81
86
|
end
|
82
87
|
end
|
83
88
|
end
|
data/lib/filter_form/version.rb
CHANGED
@@ -8,15 +8,14 @@ describe FilterForm::InputOptionsBuilder do
|
|
8
8
|
let(:builder) { FilterForm::InputOptionsBuilder.new(object: search) }
|
9
9
|
|
10
10
|
context 'boolean' do
|
11
|
-
before do
|
12
|
-
builder.attribute_name = :married
|
13
|
-
end
|
14
|
-
|
15
11
|
context 'default predicate' do
|
16
12
|
it 'returns correct options with predicate "true"' do
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
builder.attribute_name = :married
|
14
|
+
|
15
|
+
result = builder.build
|
16
|
+
|
17
|
+
expected_result = { as: :boolean, required: false, label: 'MARRIED IS TRUE', input_html: { name: 'q[married_true]', checked: false } }
|
18
|
+
expect(result).to eq(expected_result)
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
@@ -41,29 +40,27 @@ describe FilterForm::InputOptionsBuilder do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
context 'text' do
|
44
|
-
before do
|
45
|
-
builder.attribute_name = :about
|
46
|
-
end
|
47
|
-
|
48
43
|
context 'default predicate' do
|
49
44
|
it 'returns correct options with predicate "cont"' do
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
builder.attribute_name = :about
|
46
|
+
|
47
|
+
result = builder.build
|
48
|
+
|
49
|
+
expected_result = { as: :string, required: false, label: 'ABOUT CONTAINS', input_html: { name: 'q[about_cont]' } }
|
50
|
+
expect(result).to eq(expected_result)
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
55
|
context 'money' do
|
58
|
-
before do
|
59
|
-
builder.attribute_name = :amount
|
60
|
-
end
|
61
|
-
|
62
56
|
context 'default predicate' do
|
63
57
|
it 'returns correct options with predicate "eq"' do
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
builder.attribute_name = :amount
|
59
|
+
|
60
|
+
result = builder.build
|
61
|
+
|
62
|
+
expected_result = { as: :integer, required: false, label: 'AMOUNT EQUALS', input_html: { name: 'q[amount_eq]', step: 'any' } }
|
63
|
+
expect(result).to eq(expected_result)
|
67
64
|
end
|
68
65
|
end
|
69
66
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evgeny Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|