facet_for 0.0.3 → 0.0.4
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/lib/facet_for/version.rb +1 -1
- data/lib/facet_for.rb +32 -11
- metadata +4 -4
    
        data/lib/facet_for/version.rb
    CHANGED
    
    
    
        data/lib/facet_for.rb
    CHANGED
    
    | @@ -153,6 +153,8 @@ 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 ''
         | 
| 156 158 | 
             
                  when :cont
         | 
| 157 159 | 
             
                    return label("#{@facet[:column_name]}_cont",
         | 
| 158 160 | 
             
                                 "#{@facet[:column_name].to_s.humanize} Contains")
         | 
| @@ -209,6 +211,15 @@ module FacetFor | |
| 209 211 | 
             
                  case @facet[:type]
         | 
| 210 212 | 
             
                  when :cont, :not_cont, :start, :not_start, :end, :not_end, :gteq, :lteq
         | 
| 211 213 | 
             
                    facet_html << text_field
         | 
| 214 | 
            +
                  when :cont_any
         | 
| 215 | 
            +
                    @facet[:collection].each do |check|
         | 
| 216 | 
            +
                      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)
         | 
| 219 | 
            +
                      facet_html << "</div>"
         | 
| 220 | 
            +
                    end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
                    facet_html
         | 
| 212 223 | 
             
                  when :collection
         | 
| 213 224 | 
             
                    facet_html << facet_collection
         | 
| 214 225 | 
             
                  when :null, :not_null, :true, :false
         | 
| @@ -244,21 +255,27 @@ module FacetFor | |
| 244 255 | 
             
                  predicate = options[:predicate] || @facet[:type]
         | 
| 245 256 | 
             
                  name = "#{@facet[:column_name]}_#{predicate.to_s}"
         | 
| 246 257 |  | 
| 247 | 
            -
                   | 
| 248 | 
            -
             | 
| 249 | 
            -
                  end
         | 
| 258 | 
            +
                  text_field_tag self.name_for(name), @facet[:object].send(name)
         | 
| 259 | 
            +
                end
         | 
| 250 260 |  | 
| 251 | 
            -
             | 
| 261 | 
            +
                def check_box(value = "1")
         | 
| 262 | 
            +
                  name = "#{@facet[:column_name]}_#{@facet[:type]}"
         | 
| 263 | 
            +
                  return check_box_tag(self.name_for(name, true), value, check_box_checked(value))
         | 
| 252 264 | 
             
                end
         | 
| 253 265 |  | 
| 254 | 
            -
                def  | 
| 255 | 
            -
                   | 
| 266 | 
            +
                def check_box_checked(value = "1")
         | 
| 267 | 
            +
                  name = "#{@facet[:column_name]}_#{@facet[:type]}"
         | 
| 268 | 
            +
                  selected = @facet[:object].send(name)
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                  return (!selected.nil? and selected.include?(value))
         | 
| 271 | 
            +
             | 
| 256 272 | 
             
                end
         | 
| 257 273 |  | 
| 258 274 | 
             
                def facet_collection
         | 
| 259 | 
            -
                   | 
| 260 | 
            -
             | 
| 261 | 
            -
             | 
| 275 | 
            +
                  name = "#{@facet[:column_name]}_#{@facet[:type]}"
         | 
| 276 | 
            +
                  selected = @facet[:object].send(name)
         | 
| 277 | 
            +
             | 
| 278 | 
            +
                  select_tag self.name_for(name), options_for_collection_select(@facet[:collection], :id, :to_s, selected), :include_blank => true
         | 
| 262 279 | 
             
                end
         | 
| 263 280 |  | 
| 264 281 | 
             
                def label(string_name, string_label = nil)
         | 
| @@ -266,8 +283,12 @@ module FacetFor | |
| 266 283 | 
             
                  label_tag self.name_for(string_name), display_label
         | 
| 267 284 | 
             
                end
         | 
| 268 285 |  | 
| 269 | 
            -
                def name_for(string_name)
         | 
| 270 | 
            -
                  "#{@facet[:object_name]}[#{string_name}]" | 
| 286 | 
            +
                def name_for(string_name, array = false)
         | 
| 287 | 
            +
                  name = "#{@facet[:object_name]}[#{string_name}]"
         | 
| 288 | 
            +
                  name += '[]' if array
         | 
| 289 | 
            +
             | 
| 290 | 
            +
                  name.to_sym
         | 
| 271 291 | 
             
                end
         | 
| 292 | 
            +
             | 
| 272 293 | 
             
              end
         | 
| 273 294 | 
             
            end
         | 
    
        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. | 
| 4 | 
            +
              version: 0.0.4
         | 
| 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-10- | 
| 12 | 
            +
            date: 2011-10-31 00:00:00.000000000Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: ransack
         | 
| 16 | 
            -
              requirement: & | 
| 16 | 
            +
              requirement: &85757450 !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: * | 
| 24 | 
            +
              version_requirements: *85757450
         | 
| 25 25 | 
             
            description: Provides helpers for creating search forms with Ransack
         | 
| 26 26 | 
             
            email:
         | 
| 27 27 | 
             
            - jbarket@sleepunit.com
         |