wice_grid_mongoid 6.0.3 → 6.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/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.3
1
+ 6.0.4
@@ -93,6 +93,7 @@ module Wice
93
93
  @@handled_type[Integer] = self
94
94
  @@handled_type[Float] = self
95
95
  # @@handled_type[BigDecimal] = self
96
+ VALID_NUMBER_RE = /(\d+)((G|M|K)B?)?/i
96
97
 
97
98
  def generate_conditions(opts) #:nodoc:
98
99
  unless opts.kind_of? Hash
@@ -100,16 +101,29 @@ module Wice
100
101
  return false
101
102
  end
102
103
 
103
- if !opts[:fr] || !(opts[:fr] =~ /\d/) || !opts[:to] || !(opts[:to] =~ /\d/)
104
+ if !opts[:fr] || !(opts[:fr] =~ VALID_NUMBER_RE) || !opts[:to] || !(opts[:to] =~ VALID_NUMBER_RE)
104
105
  Wice.log "invalid parameters for the grid integer filter - either range limits are not supplied or they are not numeric"
105
106
  return false
106
107
  end
107
-
108
- @criteria.where(@field.name.to_sym.gt => opts[:fr].to_i)
109
- @criteria.where(@field.name.to_sym.lt => opts[:to].to_i)
108
+ from = parse_number(opts[:fr])
109
+ to = parse_number(opts[:to])
110
+ @criteria.where(@field.name.to_sym.gt => from)
111
+ @criteria.where(@field.name.to_sym.lt => to)
110
112
 
111
113
  return true
112
114
  end
115
+
116
+ private
117
+ def parse_number(num_str)
118
+ match_data = VALID_NUMBER_RE.match(num_str)
119
+ num = match_data[1].to_i
120
+ num = case match_data[3].downcase
121
+ when 'g': num * 1024*1024*1024
122
+ when 'm': num * 1024*1024
123
+ when 'k': num * 1024
124
+ end if match_data.size > 3
125
+ num
126
+ end
113
127
  end
114
128
 
115
129
  class FilterConditionsGeneratorDate < FilterConditionsGenerator #:nodoc:
data/lib/grid_renderer.rb CHANGED
@@ -294,6 +294,8 @@ module Wice
294
294
  :filter_all_label => Defaults::CUSTOM_FILTER_ALL_LABEL,
295
295
  :helper_style => Defaults::HELPER_STYLE,
296
296
  :icon => nil,
297
+ :th_class => nil,
298
+ :subtitle => nil,
297
299
  :in_csv => true,
298
300
  :in_html => true,
299
301
  :model_class => nil,
@@ -284,13 +284,13 @@ module Wice
284
284
  end
285
285
 
286
286
  if column.attribute_name && column.allow_ordering
287
-
288
- css_class = grid.filtered_by?(column) ? 'active_filter' : nil
289
-
287
+ css_class = []
288
+ css_class << 'active_filter' if grid.filtered_by?(column)
289
+ css_class << column.th_class if column.th_class
290
290
  direction = 'asc'
291
291
  link_style = nil
292
292
  if grid.ordered_by?(column)
293
- css_class = css_class.nil? ? 'sorted' : css_class + ' sorted'
293
+ css_class << 'sorted'
294
294
  link_style = grid.order_direction
295
295
  direction = 'desc' if grid.order_direction == 'asc'
296
296
  end
@@ -298,6 +298,8 @@ module Wice
298
298
  col_link = link_to(column_name,
299
299
  rendering.column_link(column, direction, params, options[:extra_request_parameters]),
300
300
  :class => link_style)
301
+ col_link << content_tag(:p, column.subtitle) if column.subtitle
302
+ css_class = css_class.join(' ')
301
303
  content << content_tag(:th, col_link, Hash.make_hash(:class, css_class))
302
304
  column.css_class = css_class
303
305
  else
data/lib/view_columns.rb CHANGED
@@ -8,7 +8,7 @@ module Wice
8
8
  include ActionView::Helpers::AssetTagHelper
9
9
 
10
10
  # fields defined from the options parameter
11
- FIELDS = [:attribute_name, :column_name, :icon, :td_html_attrs, :no_filter, :model_class, :allow_multiple_selection,
11
+ FIELDS = [:attribute_name, :column_name, :icon, :subtitle, :th_class, :td_html_attrs, :no_filter, :model_class, :allow_multiple_selection,
12
12
  :in_html, :in_csv, :helper_style, :table_alias, :custom_order, :detach_with_id, :allow_ordering, :auto_reload]
13
13
 
14
14
  attr_accessor *FIELDS
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wice_grid_mongoid}
8
- s.version = "6.0.3"
8
+ s.version = "6.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yuri Leikind", "Aleksandr Furmanov"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wice_grid_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
4
+ hash: 39
5
5
  prerelease: false
6
6
  segments:
7
7
  - 6
8
8
  - 0
9
- - 3
10
- version: 6.0.3
9
+ - 4
10
+ version: 6.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yuri Leikind