fancygrid 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fancygrid}
8
- s.version = "1.0.0"
8
+ s.version = "1.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Gr\303\244fenstein"]
12
- s.date = %q{2011-08-21}
12
+ s.date = %q{2011-08-23}
13
13
  s.description = %q{Enables easy table rendering in rails applications}
14
14
  s.email = %q{giniedp@online.de}
15
15
  s.extra_rdoc_files = [
@@ -1,3 +1,5 @@
1
+ require "active_support/hash_with_indifferent_access"
2
+
1
3
  module Fancygrid#:nodoc:
2
4
 
3
5
  class Grid < Fancygrid::Node
@@ -63,6 +65,9 @@ module Fancygrid#:nodoc:
63
65
  # Specifies the search options for search input fields
64
66
  attr_accessor :search_formats
65
67
 
68
+ # Specifies what operators the simple search has to ose for specific columns
69
+ attr_accessor :simple_search_operators
70
+
66
71
 
67
72
 
68
73
 
@@ -86,6 +91,7 @@ module Fancygrid#:nodoc:
86
91
  self.search_type = Fancygrid.default_search_type
87
92
  self.search_operators = Fancygrid.search_operators
88
93
  self.search_formats = {}
94
+ self.simple_search_operators = ActiveSupport::HashWithIndifferentAccess.new({})
89
95
 
90
96
  if Fancygrid.use_grid_name_as_cells_template
91
97
  self.template = File.join(Fancygrid.cells_template_directory.to_s, name.to_s)
@@ -170,7 +176,7 @@ module Fancygrid#:nodoc:
170
176
  :operator => params[:operator]
171
177
  }
172
178
 
173
- generator = Fancygrid::QueryGenerator.new(url_options)
179
+ generator = Fancygrid::QueryGenerator.new(url_options, self)
174
180
  generator.parse_options(options)
175
181
  yield(generator) if block_given?
176
182
 
@@ -361,7 +367,13 @@ module Fancygrid#:nodoc:
361
367
  end
362
368
  end
363
369
 
364
-
370
+ def simple_search_operator table, column
371
+ return simple_search_operators if simple_search_operators.is_a? Symbol
372
+ opts = (simple_search_operators || {})
373
+ opts = opts[table] || {}
374
+ return opts if opts.is_a? Symbol
375
+ opts[column]
376
+ end
365
377
 
366
378
  # Builds the javascript options for the javascript part of fancygrid
367
379
  def js_options
@@ -8,13 +8,14 @@ module Fancygrid
8
8
  :like, :is_null, :is_not_null, :is_true, :is_not_true, :is_false, :is_not_false, :in, :not_in
9
9
  ]
10
10
 
11
- attr_accessor :query
11
+ attr_accessor :query, :fancygrid
12
12
 
13
- def initialize(options=nil)
13
+ def initialize(options=nil, grid=nil)
14
14
  options ||= {}
15
15
  options = ActiveSupport::HashWithIndifferentAccess.new(options)
16
16
 
17
17
  self.query = {}
18
+ self.fancygrid = grid
18
19
 
19
20
  self.select(options[:select])
20
21
  self.apply_pagination(options[:pagination])
@@ -104,7 +105,8 @@ module Fancygrid
104
105
  # }
105
106
  #
106
107
  unless value.blank?
107
- { :column => "#{table}.#{column}", :operator => :like, :value => value }
108
+ op = (fancygrid and fancygrid.simple_search_operator(table, column) or :like).to_s
109
+ { :column => "#{table}.#{column}", :operator => op, :value => value }
108
110
  else
109
111
  nil
110
112
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancygrid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 1.0.0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Alexander Gr\xC3\xA4fenstein"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-21 00:00:00 +02:00
18
+ date: 2011-08-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency