facet_for 0.0.5 → 0.0.6

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.
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in facet_for.gemspec
4
4
  gemspec
5
+ gem 'rake'
@@ -1,3 +1,3 @@
1
1
  module FacetFor
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/facet_for.rb CHANGED
@@ -153,9 +153,7 @@ module FacetFor
153
153
  when :not_null
154
154
  return label("#{@facet[:column_name]}_not_null",
155
155
  "#{@facet[:column_name].to_s.humanize} Is Not Null?")
156
- when :cont_any
157
- return ''
158
- when :cont
156
+ when :cont, :cont_any
159
157
  return label("#{@facet[:column_name]}_cont",
160
158
  "#{@facet[:column_name].to_s.humanize} Contains")
161
159
  when :not_cont
@@ -212,10 +210,26 @@ module FacetFor
212
210
  when :cont, :not_cont, :start, :not_start, :end, :not_end, :gteq, :lteq
213
211
  facet_html << text_field
214
212
  when :cont_any
213
+ collection_type = :array
214
+ if @facet[:collection].first.class == 'String'
215
+ collection_type = :string
216
+ end
217
+
215
218
  @facet[:collection].each do |check|
216
219
  facet_html << "<div class=\"facet_input cont_any check_box\">"
217
- facet_html << check_box(check)
218
- facet_html << label(self.name_for("#{@facet[:column_name]}_#{@facet[:type].to_s}", true), check)
220
+
221
+ if collection_type == :array
222
+ facet_html << check_box(check[1])
223
+ else
224
+ facet_html << check_box(check)
225
+ end
226
+
227
+ if collection_type == :array
228
+ facet_html << label(self.name_for("#{@facet[:column_name]}_#{@facet[:type].to_s}", true), check[0])
229
+ else
230
+ facet_html << label(self.name_for("#{@facet[:column_name]}_#{@facet[:type].to_s}", true), check)
231
+ end
232
+
219
233
  facet_html << "</div>"
220
234
  end
221
235
 
@@ -275,7 +289,18 @@ module FacetFor
275
289
  name = "#{@facet[:column_name]}_eq"
276
290
  selected = @facet[:object].send(name)
277
291
 
278
- select_tag self.name_for(name), options_from_collection_for_select(@facet[:collection], :id, :to_s, selected), :include_blank => true
292
+ if @facet[:collection].class == Array and
293
+ @facet[:collection].first.class == String
294
+
295
+ return select_tag self.name_for(name),
296
+ options_for_select(@facet[:collection], selected),
297
+ :include_blank => true
298
+ else
299
+ return select_tag self.name_for(name),
300
+ options_from_collection_for_select(@facet[:collection], :id, :to_s,
301
+ selected), :include_blank => true
302
+ end
303
+
279
304
  end
280
305
 
281
306
  def label(string_name, string_label = nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facet_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-02 00:00:00.000000000Z
12
+ date: 2012-01-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ransack
16
- requirement: &77892390 !ruby/object:Gem::Requirement
16
+ requirement: &75492170 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *77892390
24
+ version_requirements: *75492170
25
25
  description: Provides helpers for creating search forms with Ransack
26
26
  email:
27
27
  - jbarket@sleepunit.com
@@ -50,12 +50,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  - - ! '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
+ segments:
54
+ - 0
55
+ hash: 625741645
53
56
  required_rubygems_version: !ruby/object:Gem::Requirement
54
57
  none: false
55
58
  requirements:
56
59
  - - ! '>='
57
60
  - !ruby/object:Gem::Version
58
61
  version: '0'
62
+ segments:
63
+ - 0
64
+ hash: 625741645
59
65
  requirements: []
60
66
  rubyforge_project: facet_for
61
67
  rubygems_version: 1.8.10