filter_form 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -26
- data/lib/filter_form/input_options/base.rb +6 -4
- 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: 7846d2bebe60316a75904652d6ac5eb2c71ea17b
|
4
|
+
data.tar.gz: 4b0fe390d1905a11a7b7e664c072e2b91e7f08be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f9320073c6f929ba9590edb721fa4362b8ed97548b1f23dfe747874cc285cc4a99f8d2d390361fac649b61067b189b9f2aada46009c498a0a4b3a1095fb35e
|
7
|
+
data.tar.gz: 7aa22b8d064a6f030b6caf683671c56aa3274bf42ecba1ff7003a35630453bdf49c9bac69a6ebbe1b2101172ab508d0efe8a0f5a84d6519a58a9bd7572dc1cc1
|
data/README.md
CHANGED
@@ -58,32 +58,22 @@ In your view file:
|
|
58
58
|
|
59
59
|
### Customization
|
60
60
|
|
61
|
-
####
|
62
|
-
|
63
|
-
If you want to use jQuery [Datepicker](http://jqueryui.com/datepicker/) for `date` and `datetime` automatically or [Select2](http://ivaynberg.github.io/select2/), add to your application.js file:
|
64
|
-
|
65
|
-
```js
|
66
|
-
//= require jquery
|
67
|
-
//= require jquery.ui.datepicker
|
68
|
-
//= require select2
|
61
|
+
#### Custom predicate
|
69
62
|
|
70
|
-
|
63
|
+
```erb
|
64
|
+
<%= filter_form_for @q do |f| %>
|
65
|
+
<%= f.filter_input :year, as: :select, collection: (2000..2013).to_a, predicate: :not_eq %>
|
66
|
+
<%= f.button :submit %>
|
67
|
+
<% end %>
|
71
68
|
```
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
```css
|
76
|
-
*= require jquery.ui.datepicker
|
77
|
-
*= require select2
|
78
|
-
|
79
|
-
*= require filter_form
|
80
|
-
```
|
70
|
+
#### Predicate selector
|
81
71
|
|
82
|
-
|
72
|
+
You can show predicate selector:
|
83
73
|
|
84
74
|
```erb
|
85
75
|
<%= filter_form_for @q do |f| %>
|
86
|
-
<%= f.filter_input :
|
76
|
+
<%= f.filter_input :id, predicate_selector: [['=', 'eq'], ['>', 'gt'], ['<', 'lt']] %>
|
87
77
|
<%= f.button :submit %>
|
88
78
|
<% end %>
|
89
79
|
```
|
@@ -99,15 +89,27 @@ You can wrap your select in `select2`:
|
|
99
89
|
<% end %>
|
100
90
|
```
|
101
91
|
|
102
|
-
####
|
92
|
+
#### Assets
|
103
93
|
|
104
|
-
|
94
|
+
If you want to use predicate selector, jQuery [Datepicker](http://jqueryui.com/datepicker/) for `date` and `datetime` automatically or [Select2](http://ivaynberg.github.io/select2/), add to your application.js file:
|
105
95
|
|
106
|
-
```
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
96
|
+
```js
|
97
|
+
//= require jquery
|
98
|
+
//= require jquery.ui.datepicker
|
99
|
+
|
100
|
+
//= require select2
|
101
|
+
|
102
|
+
//= require filter_form
|
103
|
+
```
|
104
|
+
|
105
|
+
And application.css:
|
106
|
+
|
107
|
+
```css
|
108
|
+
*= require jquery.ui.datepicker
|
109
|
+
|
110
|
+
*= require select2
|
111
|
+
|
112
|
+
*= require filter_form
|
111
113
|
```
|
112
114
|
|
113
115
|
### Other sources
|
@@ -60,10 +60,12 @@ module FilterForm
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def object_condition
|
63
|
-
object.base.conditions.select
|
64
|
-
|
65
|
-
condition.predicate.name == predicate.to_s
|
66
|
-
|
63
|
+
result = object.base.conditions.select { |condition| condition.a.first.name == input_attribute_name.to_s }
|
64
|
+
if result.size > 1
|
65
|
+
result.select { |condition| condition.predicate.name == predicate.to_s }.first
|
66
|
+
else
|
67
|
+
result.first
|
68
|
+
end
|
67
69
|
end
|
68
70
|
|
69
71
|
def input_attribute_name
|
data/lib/filter_form/version.rb
CHANGED