datatablesnet 1.1.3 → 1.1.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/datatablesnet/datatable.rb +20 -17
- data/lib/datatablesnet/version.rb +1 -1
- metadata +3 -3
@@ -111,7 +111,7 @@ module Datatable
|
|
111
111
|
|
112
112
|
config = {:options => options, :columns =>columns, :table_options => table_options}
|
113
113
|
config.to_json
|
114
|
-
|
114
|
+
|
115
115
|
render :partial => "datatablesnet/table", :locals => { :table_id => id, :columns => columns, :rows => rows, :config => config}
|
116
116
|
end
|
117
117
|
|
@@ -128,7 +128,7 @@ module Datatable
|
|
128
128
|
column_options = {}
|
129
129
|
column_options_map.each do |k,v|
|
130
130
|
if column[k].present?
|
131
|
-
column_options[v] = column[k]
|
131
|
+
column_options[v] = column[k] unless k==:width and request.env['HTTP_USER_AGENT'] =~ /Firefox/
|
132
132
|
end
|
133
133
|
end
|
134
134
|
column_options["fnRender"] = NoEscape.new(options[:render]) if column[:render].present?
|
@@ -150,7 +150,11 @@ module Datatable
|
|
150
150
|
end
|
151
151
|
|
152
152
|
if options[:server_side]
|
153
|
-
|
153
|
+
if request.env['HTTP_USER_AGENT'] =~ /Firefox/
|
154
|
+
column_defs << {"sClass" => "hidden"}
|
155
|
+
else
|
156
|
+
column_defs << {"bVisible" => false}
|
157
|
+
end
|
154
158
|
end
|
155
159
|
|
156
160
|
return column_defs
|
@@ -192,7 +196,7 @@ module Datatable
|
|
192
196
|
label.to_s.gsub(/\b\w/){$&.upcase}
|
193
197
|
end
|
194
198
|
|
195
|
-
def parse_params params
|
199
|
+
def parse_params klass, params
|
196
200
|
grid_options = {}
|
197
201
|
columns = []
|
198
202
|
order_by = {}
|
@@ -224,13 +228,14 @@ module Datatable
|
|
224
228
|
if key =~ /.*_to/
|
225
229
|
field_name = key[6..-4]
|
226
230
|
search_by[field_name] = {} unless search_by[field_name].present?
|
227
|
-
search_by[field_name][:to] =
|
231
|
+
search_by[field_name][:to] = convert_param(klass, field_name, value)
|
228
232
|
elsif key =~ /.*_from/
|
229
233
|
field_name = key[6..-6]
|
230
234
|
search_by[field_name] = {} unless search_by[field_name].present?
|
231
|
-
search_by[field_name][:from] =
|
235
|
+
search_by[field_name][:from] = convert_param(klass, field_name,value)
|
232
236
|
else
|
233
|
-
|
237
|
+
field_name = key[6..-1]
|
238
|
+
search_by[field_name] = convert_param(klass, field_name, value)
|
234
239
|
end
|
235
240
|
end
|
236
241
|
end
|
@@ -248,21 +253,19 @@ module Datatable
|
|
248
253
|
grid_options
|
249
254
|
end
|
250
255
|
|
251
|
-
def
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
value = value
|
258
|
-
end
|
256
|
+
def convert_param klass, field_name, value
|
257
|
+
case klass.columns_hash[field_name].type
|
258
|
+
when :date, :datetime
|
259
|
+
value = Date.parse(value)
|
260
|
+
when :integer, :float, :decimal
|
261
|
+
value = value.to_i
|
259
262
|
end
|
260
263
|
value
|
261
264
|
end
|
262
265
|
|
263
266
|
|
264
267
|
def build_condition(klass, params={}, options = {})
|
265
|
-
grid_options = parse_params params
|
268
|
+
grid_options = parse_params klass, params
|
266
269
|
build_condition_internal(klass, grid_options, options[:conditions].present? ? options[:conditions] : nil)
|
267
270
|
end
|
268
271
|
|
@@ -320,7 +323,7 @@ module Datatable
|
|
320
323
|
def find(klass, params={}, options = {})
|
321
324
|
puts params.to_json
|
322
325
|
|
323
|
-
grid_options = parse_params params
|
326
|
+
grid_options = parse_params klass, params
|
324
327
|
|
325
328
|
options[:page] = grid_options[:page]
|
326
329
|
options[:per_page] = grid_options[:per_page]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 4
|
9
|
+
version: 1.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Matt Fields
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-09-01 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|