wice_grid 3.2.0 → 3.2.1.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/CHANGELOG +9 -6
  2. data/README.rdoc +29 -0
  3. data/VERSION +1 -1
  4. data/lib/active_record_column_wrapper.rb +105 -0
  5. data/lib/columns/column_action.rb +50 -0
  6. data/lib/columns/column_boolean.rb +43 -0
  7. data/lib/columns/column_custom_dropdown.rb +119 -0
  8. data/lib/columns/column_date.rb +23 -0
  9. data/lib/columns/column_datetime.rb +113 -0
  10. data/lib/columns/column_float.rb +14 -0
  11. data/lib/columns/column_integer.rb +63 -0
  12. data/lib/columns/column_processor_index.rb +19 -0
  13. data/lib/columns/column_range.rb +74 -0
  14. data/lib/columns/column_string.rb +89 -0
  15. data/lib/columns.rb +223 -0
  16. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +1 -1
  17. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +2 -2
  18. data/lib/grid_renderer.rb +19 -9
  19. data/lib/helpers/wice_grid_view_helpers.rb +6 -10
  20. data/lib/kaminari_monkey_patching.rb +4 -4
  21. data/lib/wice_grid.rb +15 -245
  22. data/lib/wice_grid_controller.rb +4 -4
  23. data/lib/wice_grid_core_ext.rb +3 -3
  24. data/wice_grid.gemspec +15 -13
  25. metadata +17 -15
  26. data/lib/view_columns/action_view_column.rb +0 -45
  27. data/lib/view_columns/column_processor_index.rb +0 -16
  28. data/lib/view_columns/view_column_boolean.rb +0 -23
  29. data/lib/view_columns/view_column_custom_dropdown.rb +0 -80
  30. data/lib/view_columns/view_column_date.rb +0 -17
  31. data/lib/view_columns/view_column_datetime.rb +0 -85
  32. data/lib/view_columns/view_column_float.rb +0 -7
  33. data/lib/view_columns/view_column_integer.rb +0 -38
  34. data/lib/view_columns/view_column_string.rb +0 -63
  35. data/lib/view_columns.rb +0 -177
data/CHANGELOG CHANGED
@@ -1,7 +1,13 @@
1
- to do:
2
1
 
3
- 1) get rid of this :href => "javascript: toggle_multi_select
4
- at view_columns
2
+ action_column can now also take a block. If the block returns a falsy value, no checkbox will be rendered
3
+
4
+ A fix: the css class submitted to column is also added to <th> tags of the column
5
+
6
+ Filter related code has been refactored: condition generators are unified together with view column processors into one module. Writing your own filters has been simplified.
7
+
8
+ The default filter for numeric columns has been replaced by a simple one field filter which checks the values for equality, not the inclusion in a range.
9
+ New column parameter :filter_type allows to load custom alternative filters. The old numeric range filter can still be used by specifying filter_type: :range.
10
+ See lib/columns/column_processor_index.rb</tt> for the list of available filters.
5
11
 
6
12
  +++++++
7
13
  +++++++
@@ -83,9 +89,6 @@ This version of WiceGrid is accompanied by an application called _WiceGrid Examp
83
89
 
84
90
  Here's a list of changes as compared with "version 0.4":https://blog.wice.eu/2009/7/6/moving-to-github-and-wicegrid-version-0-4 :
85
91
 
86
- h4. selected_records
87
-
88
- Method @selected_records@ of WiceGrid instances allows to access the list of all records of the current selection throughout all pages in the context of a view:
89
92
 
90
93
  --- RHTML
91
94
  <%= grid(@tasks_grid) do |g|
data/README.rdoc CHANGED
@@ -624,6 +624,17 @@ To only allow single selection use <tt>:allow_multiple_selection</tt>:
624
624
  end
625
625
 
626
626
 
627
+ ==== Numeric Filters
628
+
629
+ Before version 3.2.1 the filter used for numeric columns was a range filter with two limits. Beginning with version 3.2.1
630
+ the default is a direct comparison filter with one input field. The old range filter can still be loaded using parameter <tt>:filter_type</tt>
631
+ with value <tt>:range</tt>:
632
+
633
+ g.column :filter_type => :range do |task|
634
+ ...
635
+ end
636
+
637
+
627
638
  === Defaults
628
639
 
629
640
  Default values like can be changed in <tt>config/initializers/wice_grid_config.rb</tt>.
@@ -801,6 +812,24 @@ taken care of by the application code.
801
812
  By default the name of the HTTP parameter follows pattern <tt>"#{grid_name}[#{param_name}][]"</tt>, thus
802
813
  <tt>params[grid_name][param_name]</tt> will contain an array of object IDs.
803
814
 
815
+
816
+ You can hide a certain action checkbox if you add the usual block to +g.action_column+, just like with the
817
+ +g.column+ definition. If the block returns +nil+ or +false+ no checkbox will be rendered.
818
+
819
+ <%= grid(@tasks_grid, :show_filters => :always) do |g|
820
+
821
+ ...
822
+
823
+ g.action_column do |task|
824
+ task.finished?
825
+ end
826
+
827
+ ...
828
+
829
+ end -%>
830
+
831
+
832
+
804
833
  WiceGrid is form-friendly: submitting grid in a form retains the state of the form.
805
834
 
806
835
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.2.1.pre1
@@ -0,0 +1,105 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ # to be mixed in into ActiveRecord::ConnectionAdapters::Column
5
+ module WiceGridExtentionToActiveRecordColumn #:nodoc:
6
+ attr_accessor :model
7
+ end
8
+
9
+
10
+
11
+ class ActiveRecordColumnWrapper #:nodoc:
12
+ def initialize(column, all_filter_params, main_table, table_alias, custom_filter_active, filter_type) #:nodoc:
13
+ @column = column
14
+ @filter_type = filter_type
15
+ @all_filter_params, @main_table, @table_alias, @custom_filter_active =
16
+ all_filter_params, main_table, table_alias, custom_filter_active
17
+ end
18
+
19
+
20
+ def wg_initialize_request_parameters #:nodoc:
21
+ @request_params = nil
22
+ return if @all_filter_params.nil?
23
+
24
+ # if the parameter does not specify the table name we only allow columns in the default table to use these parameters
25
+ if @main_table && @request_params = @all_filter_params[@column.name]
26
+ current_parameter_name = @column.name
27
+ elsif @request_params = @all_filter_params[alias_or_table_name(@table_alias) + '.' + @column.name]
28
+ current_parameter_name = alias_or_table_name(@table_alias) + '.' + @column.name
29
+ end
30
+
31
+ # Preprocess incoming parameters for datetime, if what's coming in is
32
+ # a datetime (with custom_filter it can be anything else, and not
33
+ # the datetime hash {:fr => ..., :to => ...})
34
+ if @request_params
35
+ if (@column.type == :datetime || @column.type == :timestamp) && @request_params.is_a?(Hash)
36
+ [:fr, :to].each do |sym|
37
+ if @request_params[sym]
38
+ if @request_params[sym].is_a?(String)
39
+ @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATETIME_PARSER).call(@request_params[sym])
40
+ elsif @request_params[sym].is_a?(Hash)
41
+ @request_params[sym] = Wice::GridTools.params_2_datetime(@request_params[sym])
42
+ end
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ # Preprocess incoming parameters for date, if what's coming in is
49
+ # a date (with custom_filter it can be anything else, and not
50
+ # the date hash {:fr => ..., :to => ...})
51
+ if @column.type == :date && @request_params.is_a?(Hash)
52
+ [:fr, :to].each do |sym|
53
+ if @request_params[sym]
54
+ if @request_params[sym].is_a?(String)
55
+ @request_params[sym] = Wice::ConfigurationProvider.value_for(:DATE_PARSER).call(@request_params[sym])
56
+ elsif @request_params[sym].is_a?(Hash)
57
+ @request_params[sym] = ::Wice::GridTools.params_2_date(@request_params[sym])
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ return wg_generate_conditions, current_parameter_name
65
+ end
66
+
67
+ def wg_generate_conditions #:nodoc:
68
+ return nil if @request_params.nil?
69
+
70
+ if @custom_filter_active
71
+ custom_processor_klass = ::Wice::Columns.get_conditions_generator_column_processor(:custom)
72
+ custom_processor = custom_processor_klass.new(self)
73
+ return custom_processor.generate_conditions(@table_alias, @request_params)
74
+ end
75
+
76
+ column_type = @filter_type || @column.type.to_s
77
+
78
+ processor_class = ::Wice::Columns.get_conditions_generator_column_processor(column_type)
79
+
80
+ if processor_class
81
+ return processor_class.new(self).generate_conditions(@table_alias, @request_params)
82
+ else
83
+ Wice.log("No processor for database type #{column_type}!!!")
84
+ nil
85
+ end
86
+ end
87
+
88
+ def name #:nodoc:
89
+ @column.name
90
+ end
91
+
92
+ def model #:nodoc:
93
+ @column.model
94
+ end
95
+
96
+
97
+ def alias_or_table_name(table_alias) #:nodoc:
98
+ table_alias || @column.model.table_name
99
+ end
100
+
101
+
102
+ end
103
+
104
+
105
+ end
@@ -0,0 +1,50 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+
7
+ class ViewColumnAction < ViewColumn #:nodoc:
8
+ def initialize(grid_obj, html, param_name, select_all_buttons, object_property, view, block = nil) #:nodoc:
9
+ @view = view
10
+ @select_all_buttons = select_all_buttons
11
+ self.grid = grid_obj
12
+ self.html = html
13
+ Wice::WgHash.add_or_append_class_value!(self.html, 'sel')
14
+ grid_name = self.grid.name
15
+ @param_name = param_name
16
+ @cell_rendering_block = lambda do |object, params|
17
+ if block && ! block.call(object)
18
+ ''
19
+ else
20
+ selected = params[grid_name] && params[grid_name][param_name] && params[grid_name][param_name].index(object.send(object_property).to_s)
21
+ check_box_tag("#{grid_name}[#{param_name}][]", object.send(object_property), selected, :id => nil)
22
+ end
23
+ end
24
+ end
25
+
26
+ def in_html #:nodoc:
27
+ true
28
+ end
29
+
30
+ def capable_of_hosting_filter_related_icons? #:nodoc:
31
+ false
32
+ end
33
+
34
+ def name #:nodoc:
35
+ return '' unless @select_all_buttons
36
+
37
+ content_tag(:div, '',
38
+ :class => 'clickable select-all',
39
+ :title => NlMessage['select_all']) + ' ' +
40
+ content_tag(:div, '',
41
+ :class => 'clickable deselect-all',
42
+ :title => NlMessage['deselect_all'])
43
+
44
+ end
45
+
46
+ end
47
+
48
+ ConditionsGeneratorColumnAction = ConditionsGeneratorColumn #:nodoc:
49
+ end
50
+ end
@@ -0,0 +1,43 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+ class ViewColumnBoolean < ViewColumnCustomDropdown #:nodoc:
7
+ include ActionView::Helpers::FormOptionsHelper
8
+
9
+ attr_accessor :boolean_filter_true_label, :boolean_filter_false_label
10
+
11
+ def render_filter_internal(params) #:nodoc:
12
+ @custom_filter = {
13
+ @filter_all_label => nil,
14
+ @boolean_filter_true_label => 't',
15
+ @boolean_filter_false_label => 'f'
16
+ }
17
+
18
+ @turn_off_select_toggling = true
19
+ super(params)
20
+ end
21
+ end
22
+
23
+
24
+ class ConditionsGeneratorColumnBoolean < ConditionsGeneratorColumn #:nodoc:
25
+ def generate_conditions(table_alias, opts) #:nodoc:
26
+ unless (opts.kind_of?(Array) && opts.size == 1)
27
+ Wice.log "invalid parameters for the grid boolean filter - must be an one item array: #{opts.inspect}"
28
+ return false
29
+ end
30
+ opts = opts[0]
31
+ if opts == 'f'
32
+ [" (#{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} = ? or #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} is null) ", false]
33
+ elsif opts == 't'
34
+ [" #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} = ?", true]
35
+ else
36
+ nil
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,119 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+ class ViewColumnCustomDropdown < ViewColumn #:nodoc:
7
+ include ActionView::Helpers::FormOptionsHelper
8
+
9
+ attr_accessor :filter_all_label
10
+ attr_accessor :custom_filter
11
+
12
+ def render_filter_internal(params) #:nodoc:
13
+ @query, @query_without_equals_sign, @parameter_name, @dom_id = form_parameter_name_id_and_query('')
14
+ @query_without_equals_sign += '%5B%5D='
15
+
16
+ @custom_filter = @custom_filter.call if @custom_filter.kind_of? Proc
17
+
18
+ if @custom_filter.kind_of? Array
19
+
20
+ @custom_filter = [[@filter_all_label, nil]] + @custom_filter.map{|label, value|
21
+ [label.to_s, value.to_s]
22
+ }
23
+
24
+ end
25
+
26
+ select_options = {:name => @parameter_name + '[]', :id => @dom_id, :class => 'custom-dropdown'}
27
+
28
+ if @turn_off_select_toggling
29
+ select_toggle = ''
30
+ else
31
+ if self.allow_multiple_selection
32
+ select_options[:multiple] = params.is_a?(Array) && params.size > 1
33
+
34
+ expand_icon_style, collapse_icon_style = nil, 'display: none'
35
+ expand_icon_style, collapse_icon_style = collapse_icon_style, expand_icon_style if select_options[:multiple]
36
+
37
+ select_toggle = content_tag(:span, '',
38
+ :title => NlMessage['expand'],
39
+ :class => 'expand-multi-select-icon clickable',
40
+ :style => expand_icon_style
41
+ ) +
42
+ content_tag(:span, '',
43
+ :title => NlMessage['collapse'],
44
+ :class => 'collapse-multi-select-icon clickable',
45
+ :style => collapse_icon_style
46
+ )
47
+ else
48
+ select_options[:multiple] = false
49
+ select_toggle = ''
50
+ end
51
+ end
52
+
53
+ if auto_reload
54
+ select_options[:class] += ' auto-reload'
55
+ end
56
+
57
+ params_for_select = (params.is_a?(Hash) && params.empty?) ? [nil] : params
58
+
59
+ '<div class="custom-dropdown-container">'.html_safe +
60
+ content_tag(:select,
61
+ options_for_select(@custom_filter, params_for_select),
62
+ select_options) + select_toggle.html_safe + '</div>'.html_safe
63
+ end
64
+
65
+
66
+ def yield_declaration_of_column_filter #:nodoc:
67
+ {
68
+ :templates => [@query_without_equals_sign],
69
+ :ids => [@dom_id]
70
+ }
71
+ end
72
+
73
+
74
+ def has_auto_reloading_select? #:nodoc:
75
+ auto_reload
76
+ end
77
+ end
78
+
79
+
80
+ class ConditionsGeneratorColumnCustomDropdown < ConditionsGeneratorColumn #:nodoc:
81
+
82
+ def generate_conditions(table_alias, opts) #:nodoc:
83
+ if opts.empty? || (opts.is_a?(Array) && opts.size == 1 && opts[0].blank?)
84
+ return false
85
+ end
86
+ opts = (opts.kind_of?(Array) && opts.size == 1) ? opts[0] : opts
87
+
88
+ if opts.kind_of?(Array)
89
+ opts_with_special_values, normal_opts = opts.partition{|v| ::Wice::GridTools.special_value(v)}
90
+
91
+ conditions_ar = if normal_opts.size > 0
92
+ [" #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} IN ( " + (['?'] * normal_opts.size).join(', ') + ' )'] + normal_opts
93
+ else
94
+ []
95
+ end
96
+
97
+ if opts_with_special_values.size > 0
98
+ special_conditions = opts_with_special_values.collect{|v| " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} is " + v}.join(' or ')
99
+ if conditions_ar.size > 0
100
+ conditions_ar[0] = " (#{conditions_ar[0]} or #{special_conditions} ) "
101
+ else
102
+ conditions_ar = " ( #{special_conditions} ) "
103
+ end
104
+ end
105
+ conditions_ar
106
+ else
107
+ if ::Wice::GridTools.special_value(opts)
108
+ " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} is " + opts
109
+ else
110
+ [" #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} = ?", opts]
111
+ end
112
+ end
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
119
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+ class ViewColumnDate < ViewColumnDatetime #:nodoc:
7
+
8
+ @@datetime_chunk_names = %w(year month day)
9
+
10
+ def render_standard_filter_internal(params) #:nodoc:
11
+ '<div class="date-filter">' +
12
+ select_date(params[:fr], {:include_blank => true, :prefix => @name1, :id => @dom_id}) + '<br/>' +
13
+ select_date(params[:to], {:include_blank => true, :prefix => @name2, :id => @dom_id2}) +
14
+ '</div>'
15
+ end
16
+
17
+ end
18
+
19
+ ConditionsGeneratorColumnDate = ConditionsGeneratorColumnDatetime #:nodoc:
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,113 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+ class ViewColumnDatetime < ViewColumn #:nodoc:
7
+ include ActionView::Helpers::DateHelper
8
+ include Wice::JsCalendarHelpers
9
+
10
+
11
+ # name_and_id_from_options in Rails Date helper does not substitute '.' with '_'
12
+ # like all other simpler form helpers do. Thus, overriding it here.
13
+ def name_and_id_from_options(options, type) #:nodoc:
14
+ options[:name] = (options[:prefix] || DEFAULT_PREFIX) + (options[:discard_type] ? '' : "[#{type}]")
15
+ options[:id] = options[:name].gsub(/([\[\(])|(\]\[)/, '_').gsub(/[\]\)]/, '').gsub(/\./, '_').gsub(/_+/, '_')
16
+ end
17
+
18
+ @@datetime_chunk_names = %w(year month day hour minute)
19
+
20
+ def prepare_for_standard_filter #:nodoc:
21
+ x = lambda{|sym|
22
+ @@datetime_chunk_names.collect{|datetime_chunk_name|
23
+ triple = form_parameter_name_id_and_query(sym => {datetime_chunk_name => ''})
24
+ [triple[0], triple[3]]
25
+ }
26
+ }
27
+
28
+ @queris_ids = x.call(:fr) + x.call(:to)
29
+
30
+ _, _, @name1, _ = form_parameter_name_id_and_query({:fr => ''})
31
+ _, _, @name2, _ = form_parameter_name_id_and_query({:to => ''})
32
+ end
33
+
34
+
35
+ def prepare_for_calendar_filter #:nodoc:
36
+ query, _, @name1, @dom_id = form_parameter_name_id_and_query(:fr => '')
37
+ query2, _, @name2, @dom_id2 = form_parameter_name_id_and_query(:to => '')
38
+
39
+ @queris_ids = [[query, @dom_id], [query2, @dom_id2] ]
40
+ end
41
+
42
+
43
+ def render_standard_filter_internal(params) #:nodoc:
44
+ '<div class="date-filter">' +
45
+ select_datetime(params[:fr], {:include_blank => true, :prefix => @name1}) + '<br/>' +
46
+ select_datetime(params[:to], {:include_blank => true, :prefix => @name2}) +
47
+ '</div>'
48
+ end
49
+
50
+ def render_calendar_filter_internal(params) #:nodoc:
51
+
52
+ html1 = date_calendar_jquery(
53
+ params[:fr], NlMessage['date_selector_tooltip_from'], :prefix => @name1, :fire_event => auto_reload, :grid_name => self.grid.name)
54
+
55
+ html2 = date_calendar_jquery(
56
+ params[:to], NlMessage['date_selector_tooltip_to'], :prefix => @name2, :fire_event => auto_reload, :grid_name => self.grid.name)
57
+
58
+ %!<div class="date-filter">#{html1}<br/>#{html2}</div>!
59
+ end
60
+
61
+
62
+ def render_filter_internal(params) #:nodoc:
63
+ if helper_style == :standard
64
+ prepare_for_standard_filter
65
+ render_standard_filter_internal(params)
66
+ else
67
+ prepare_for_calendar_filter
68
+ render_calendar_filter_internal(params)
69
+ end
70
+ end
71
+
72
+
73
+ def yield_declaration_of_column_filter #:nodoc:
74
+ {
75
+ :templates => @queris_ids.collect{|tuple| tuple[0] },
76
+ :ids => @queris_ids.collect{|tuple| tuple[1] }
77
+ }
78
+ end
79
+
80
+
81
+ def has_auto_reloading_calendar? #:nodoc:
82
+ auto_reload && helper_style == :calendar
83
+ end
84
+
85
+ end
86
+
87
+
88
+
89
+ class ConditionsGeneratorColumnDatetime < ConditionsGeneratorColumn #:nodoc:
90
+
91
+ def generate_conditions(table_alias, opts) #:nodoc:
92
+ conditions = [[]]
93
+ if opts[:fr]
94
+ conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} >= ? "
95
+ conditions << opts[:fr]
96
+ end
97
+
98
+ if opts[:to]
99
+ conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} <= ? "
100
+ conditions << opts[:to]
101
+ end
102
+
103
+ return false if conditions.size == 1
104
+
105
+ conditions[0] = conditions[0].join(' and ')
106
+ conditions
107
+ end
108
+ end
109
+
110
+ end
111
+
112
+
113
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: UTF-8
2
+ module Wice #:nodoc:
3
+
4
+
5
+ module Columns #:nodoc:
6
+
7
+ class ViewColumnFloat < ViewColumnInteger #:nodoc:
8
+ end
9
+
10
+ ConditionsGeneratorColumnFloat = ConditionsGeneratorColumnInteger #:nodoc:
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,63 @@
1
+ # encoding: UTF-8
2
+ module Wice
3
+
4
+ module Columns #:nodoc:
5
+
6
+ class ViewColumnInteger < ViewColumn #:nodoc:
7
+
8
+ def render_filter_internal(params) #:nodoc:
9
+ @contains_a_text_input = true
10
+
11
+ @query, _, parameter_name, @dom_id = form_parameter_name_id_and_query(:eq => '')
12
+
13
+ opts = {:size => 3, :id => @dom_id, :class => 'range-start'}
14
+
15
+ if auto_reload
16
+ opts[:class] += ' auto-reload'
17
+ end
18
+
19
+ text_field_tag(parameter_name, params[:eq], opts)
20
+ end
21
+
22
+ def yield_declaration_of_column_filter #:nodoc:
23
+ {
24
+ :templates => [@query],
25
+ :ids => [@dom_id]
26
+ }
27
+ end
28
+
29
+ def has_auto_reloading_input? #:nodoc:
30
+ auto_reload
31
+ end
32
+ end
33
+
34
+
35
+ class ConditionsGeneratorColumnInteger < ConditionsGeneratorColumn #:nodoc:
36
+
37
+ def generate_conditions(table_alias, opts) #:nodoc:
38
+ unless opts.kind_of? Hash
39
+ Wice.log "invalid parameters for the grid integer filter - must be a hash"
40
+ return false
41
+ end
42
+ conditions = [[]]
43
+ if opts[:eq]
44
+ if opts[:eq] =~ /\d/
45
+ conditions[0] << " #{@column_wrapper.alias_or_table_name(table_alias)}.#{@column_wrapper.name} = ? "
46
+ conditions << opts[:eq]
47
+ else
48
+ opts.delete(:eq)
49
+ end
50
+ end
51
+
52
+ if conditions.size == 1
53
+ return false
54
+ end
55
+
56
+ conditions[0] = conditions[0].join(' and ')
57
+
58
+ conditions
59
+ end
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ module Wice #:nodoc:
3
+ module Columns #:nodoc:
4
+ COLUMN_PROCESSOR_INDEX = ActiveSupport::OrderedHash[ #:nodoc:
5
+ :action , 'column_action', # Special processor for action column, columns with checkboxes
6
+ :text , 'column_string',
7
+ :string , 'column_string',
8
+ :timestamp, 'column_datetime',
9
+ :datetime , 'column_datetime',
10
+ :date , 'column_date',
11
+ :integer , 'column_integer',
12
+ :range , 'column_range',
13
+ :float , 'column_float',
14
+ :decimal , 'column_float',
15
+ :custom , 'column_custom_dropdown', # Special processor for custom filter columns
16
+ :boolean , 'column_boolean'
17
+ ]
18
+ end
19
+ end