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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ecd45deccc48a229e6d8faff117fb5a87b22f4
4
- data.tar.gz: 9f70f5ff1d832d6c5169e8a639e1250550ccf397
3
+ metadata.gz: 7846d2bebe60316a75904652d6ac5eb2c71ea17b
4
+ data.tar.gz: 4b0fe390d1905a11a7b7e664c072e2b91e7f08be
5
5
  SHA512:
6
- metadata.gz: 115cdd02a42840913def1a8f18dd274678cd7bef569b6a85b2d41ee2b93cbd686e30d773cfc71e78857e5ae1bb2eb98313ce5a0ac677771fac9b8c1a74368b88
7
- data.tar.gz: f15b1c850a2d4e467d77546ce5b9ddd14d969959b37d4aa8d7ac158894db7c05fe136f0dfc517a3432a5cb7223363d7bd96069359dee811e5129c0f078c41063
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
- #### Assets
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
- //= require filter_form
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
- And application.css:
74
-
75
- ```css
76
- *= require jquery.ui.datepicker
77
- *= require select2
78
-
79
- *= require filter_form
80
- ```
70
+ #### Predicate selector
81
71
 
82
- #### Custom predicate
72
+ You can show predicate selector:
83
73
 
84
74
  ```erb
85
75
  <%= filter_form_for @q do |f| %>
86
- <%= f.filter_input :year, as: :select, collection: (2000..2013).to_a, predicate: :not_eq %>
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
- #### Predicate selector
92
+ #### Assets
103
93
 
104
- You can show predicate selector:
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
- ```erb
107
- <%= filter_form_for @q do |f| %>
108
- <%= f.filter_input :id, predicate_selector: [['=', 'eq'], ['>', 'gt'], ['<', 'lt']] %>
109
- <%= f.button :submit %>
110
- <% end %>
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 do |condition|
64
- condition.a.first.name == input_attribute_name.to_s &&
65
- condition.predicate.name == predicate.to_s
66
- end.first
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
@@ -1,3 +1,3 @@
1
1
  module FilterForm
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filter_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeny Li