wice_grid 3.0.4 → 3.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG +24 -2
  2. data/README.rdoc +282 -316
  3. data/RELEASE_NOTES_3.2.pre1.rdoc +82 -0
  4. data/Rakefile +4 -2
  5. data/SAVED_QUERIES_HOWTO.rdoc +18 -31
  6. data/VERSION +1 -1
  7. data/lib/generators/wice_grid/add_migration_for_serialized_queries_generator.rb +22 -0
  8. data/lib/generators/wice_grid/install_generator.rb +20 -0
  9. data/lib/generators/wice_grid/templates/create_wice_grid_serialized_queries.rb +13 -0
  10. data/lib/generators/wice_grid/templates/wice_grid.css.scss +139 -0
  11. data/lib/generators/wice_grid/templates/wice_grid.yml +113 -19
  12. data/lib/generators/wice_grid/templates/wice_grid_config.rb +17 -41
  13. data/lib/grid_output_buffer.rb +3 -2
  14. data/lib/grid_renderer.rb +63 -102
  15. data/lib/helpers/js_calendar_helpers.rb +27 -157
  16. data/lib/helpers/wice_grid_misc_view_helpers.rb +1 -66
  17. data/lib/helpers/wice_grid_serialized_queries_view_helpers.rb +41 -32
  18. data/lib/helpers/wice_grid_view_helpers.rb +138 -274
  19. data/lib/table_column_matrix.rb +11 -11
  20. data/lib/view_columns.rb +41 -350
  21. data/lib/view_columns/action_view_column.rb +45 -0
  22. data/lib/view_columns/column_processor_index.rb +16 -0
  23. data/lib/view_columns/view_column_boolean.rb +23 -0
  24. data/lib/view_columns/view_column_custom_dropdown.rb +81 -0
  25. data/lib/view_columns/view_column_date.rb +17 -0
  26. data/lib/view_columns/view_column_datetime.rb +85 -0
  27. data/lib/view_columns/view_column_float.rb +7 -0
  28. data/lib/view_columns/view_column_integer.rb +38 -0
  29. data/lib/view_columns/view_column_string.rb +63 -0
  30. data/lib/wice_grid.rb +23 -26
  31. data/lib/wice_grid_controller.rb +14 -15
  32. data/lib/wice_grid_misc.rb +3 -3
  33. data/lib/wice_grid_serialized_queries_controller.rb +15 -18
  34. data/lib/wice_grid_spreadsheet.rb +2 -2
  35. data/lib/will_paginate_paginator.rb +31 -0
  36. data/test/readme.txt +1 -0
  37. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_down.gif +0 -0
  38. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/arrow_up.gif +0 -0
  39. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/calendar_view_month.png +0 -0
  40. data/vendor/assets/images/icons/grid/collapse.gif +0 -0
  41. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/delete.png +0 -0
  42. data/vendor/assets/images/icons/grid/expand.gif +0 -0
  43. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_excel.png +0 -0
  44. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/page_white_find.png +0 -0
  45. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table.png +0 -0
  46. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/table_refresh.png +0 -0
  47. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/tick_all.png +0 -0
  48. data/{lib/generators/wice_grid/templates/icons → vendor/assets/images/icons/grid}/untick_all.png +0 -0
  49. data/vendor/assets/javascripts/wice_grid.js +3 -0
  50. data/vendor/assets/javascripts/wice_grid_init.js.coffee +247 -0
  51. data/vendor/assets/javascripts/wice_grid_processor.js.coffee +128 -0
  52. data/vendor/assets/javascripts/wice_grid_saved_queries_init.js.coffee +103 -0
  53. data/wice_grid.gemspec +44 -50
  54. metadata +68 -94
  55. data/lib/generators/wice_grid/templates/calendarview.css +0 -107
  56. data/lib/generators/wice_grid/templates/calendarview.js +0 -1168
  57. data/lib/generators/wice_grid/templates/icons/expand.png +0 -0
  58. data/lib/generators/wice_grid/templates/wice_grid.css +0 -173
  59. data/lib/generators/wice_grid/templates/wice_grid_jquery.js +0 -162
  60. data/lib/generators/wice_grid/templates/wice_grid_prototype.js +0 -154
  61. data/lib/generators/wice_grid/wice_grid_assets_jquery_generator.rb +0 -32
  62. data/lib/generators/wice_grid/wice_grid_assets_prototype_generator.rb +0 -34
  63. data/lib/js_adaptors/jquery_adaptor.rb +0 -157
  64. data/lib/js_adaptors/js_adaptor.rb +0 -12
  65. data/lib/js_adaptors/prototype_adaptor.rb +0 -179
  66. data/lib/tasks/wice_grid_tasks.rake +0 -28
  67. data/lib/views/create.rjs +0 -13
  68. data/lib/views/create_jq.rjs +0 -31
  69. data/lib/views/delete.rjs +0 -12
  70. data/lib/views/delete_jq.rjs +0 -26
  71. data/test/.gitignore +0 -2
  72. data/test/database.yml +0 -21
  73. data/test/schema.rb +0 -33
  74. data/test/test_helper.rb +0 -89
  75. data/test/views/projects_and_people_grid.html.erb +0 -12
  76. data/test/views/projects_and_people_grid_invalid.html.erb +0 -12
  77. data/test/views/simple_projects_grid.html.erb +0 -9
  78. data/test/wice_grid_core_ext_test.rb +0 -183
  79. data/test/wice_grid_functional_test.rb +0 -68
  80. data/test/wice_grid_misc_test.rb +0 -41
  81. data/test/wice_grid_test.rb +0 -42
  82. data/test/wice_grid_view_helper_test.rb +0 -12
@@ -1,13 +1,5 @@
1
1
  if defined?(Wice::Defaults)
2
2
 
3
- Wice::Defaults::JS_FRAMEWORK = :<%= active_js_framework %>
4
- # Wice::Defaults::JS_FRAMEWORK = :<%= inactive_js_framework %>
5
-
6
- # Style of the view helper.
7
- # +false+ is a usual view helper.
8
- # +true+ will allow to embed erb content in column (cell) definitions.
9
- Wice::Defaults::ERB_MODE = false
10
-
11
3
  # Default number of rows to show per page.
12
4
  Wice::Defaults::PER_PAGE = 20
13
5
 
@@ -23,30 +15,11 @@ if defined?(Wice::Defaults)
23
15
  # for filter related icons (filter icon, reset icon, show/hide icon), otherwise an additional table column is added.
24
16
  Wice::Defaults::REUSE_LAST_COLUMN_FOR_FILTER_ICONS = true
25
17
 
26
- Wice::Defaults::SHOW_HIDE_FILTER_ICON = 'icons/grid/page_white_find.png'
27
-
28
-
29
- # Icon to trigger filtering.
30
- Wice::Defaults::FILTER_ICON = 'icons/grid/table_refresh.png'
31
-
32
- # Icon to reset the filter.
33
- Wice::Defaults::RESET_ICON = "icons/grid/table.png"
34
-
35
- # Icon to reset the filter.
36
- Wice::Defaults::TOGGLE_MULTI_SELECT_ICON = "/images/icons/grid/expand.png"
37
-
38
- # CSV Export icon.
39
- Wice::Defaults::CSV_EXPORT_ICON = "/images/icons/grid/page_white_excel.png"
40
-
41
- # Tick-All icon for the action column.
42
- Wice::Defaults::TICK_ALL_ICON = "/images/icons/grid/tick_all.png"
43
-
44
- # Untick-All icon for the action column.
45
- Wice::Defaults::UNTICK_ALL_ICON = "/images/icons/grid/untick_all.png"
46
-
47
18
  # The label of the first option of a custom dropdown list meaning 'All items'
48
19
  Wice::Defaults::CUSTOM_FILTER_ALL_LABEL = '--'
49
20
 
21
+ # A list of classes for the table tag of the grid
22
+ Wice::Defaults::DEFAULT_TABLE_CLASSES = ['table', 'table-bordered', 'table-striped']
50
23
 
51
24
  # Allow switching between a single and multiple selection modes in custom filters (dropdown boxes)
52
25
  Wice::Defaults::ALLOW_MULTIPLE_SELECTION = true
@@ -54,9 +27,12 @@ if defined?(Wice::Defaults)
54
27
  # Show the upper pagination panel by default or not
55
28
  Wice::Defaults::SHOW_UPPER_PAGINATION_PANEL = false
56
29
 
57
- # Enabling CSV export by default
30
+ # Disabling CSV export by default
58
31
  Wice::Defaults::ENABLE_EXPORT_TO_CSV = false
59
32
 
33
+ # Default CSV field separator
34
+ Wice::Defaults::CSV_FIELD_SEPARATOR = ','
35
+
60
36
 
61
37
  # The strategy when to show the filter.
62
38
  # * <tt>:when_filtered</tt> - when the table is the result of filtering
@@ -67,11 +43,6 @@ if defined?(Wice::Defaults)
67
43
  # A boolean value specifying if a change in a filter triggers reloading of the grid.
68
44
  Wice::Defaults::AUTO_RELOAD = false
69
45
 
70
- # If set to an integer (including 0), in integer and float filters the second field will be
71
- # dynamically updated when the first field is updated
72
- Wice::Defaults::SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST = false
73
- # Wice::Defaults::SECOND_RANGE_VALUE_FOLLOWING_THE_FIRST = 1
74
-
75
46
 
76
47
  # SQL operator used for matching strings in string filters.
77
48
  Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
@@ -109,9 +80,6 @@ if defined?(Wice::Defaults)
109
80
  # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
110
81
  # Saving Queries #
111
82
 
112
- # Icon to delete a saved query
113
- Wice::Defaults::DELETE_QUERY_ICON = 'icons/grid/delete.png'
114
-
115
83
  # ActiveRecord model to store queries. Read the documentation for details
116
84
  # QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
117
85
  Wice::Defaults::QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
@@ -143,7 +111,9 @@ if defined?(Wice::Defaults)
143
111
  # In many cases <tt>Time.zone.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
144
112
  # and modify it if needed.
145
113
  Wice::Defaults::DATETIME_PARSER = lambda{|datetime_string|
146
- if Time.zone
114
+ if datetime_string.blank?
115
+ nil
116
+ elsif Time.zone
147
117
  Time.zone.parse(datetime_string)
148
118
  else
149
119
  Time.parse(datetime_string)
@@ -155,10 +125,16 @@ if defined?(Wice::Defaults)
155
125
  # format defined by +DATETIME+ and must generate a Date object.
156
126
  # In many cases <tt>Date.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
157
127
  # and modify it if needed.
158
- Wice::Defaults::DATE_PARSER = lambda{|date_string| Date.parse(date_string) }
128
+ Wice::Defaults::DATE_PARSER = lambda{|date_string|
129
+ if date_string.blank?
130
+ nil
131
+ else
132
+ Date.parse(date_string)
133
+ end
134
+ }
159
135
 
160
136
  # Icon to popup the calendar.
161
- Wice::Defaults::CALENDAR_ICON = "/images/icons/grid/calendar_view_month.png"
137
+ Wice::Defaults::CALENDAR_ICON = "/assets/icons/grid/calendar_view_month.png"
162
138
 
163
139
  # popup calendar will be shown relative to the popup trigger element or to the mouse pointer
164
140
  Wice::Defaults::POPUP_PLACEMENT_STRATEGY = :trigger # :pointer
@@ -7,7 +7,6 @@ module Wice
7
7
  attr_accessor :return_empty_strings_for_nonexistent_filters
8
8
 
9
9
  def stubborn_output_mode=(m)
10
- RAILS_DEFAULT_LOGGER.debug("=== WiceGrid: detached filters are requested, postponing output till the second call of the view helper") if m
11
10
  @stubborn_output_mode = m
12
11
  end
13
12
 
@@ -40,7 +39,9 @@ module Wice
40
39
  raise WiceGridException.new("No filter with Detached ID '#{detach_with_id}'!")
41
40
  end
42
41
  end
43
- raise WiceGridException.new("Filter with Detached ID '#{detach_with_id}' has already been requested once! There cannot be two instances of the same filter on one page") if @filters[detach_with_id] == false
42
+ if @filters[detach_with_id] == false
43
+ raise WiceGridException.new("Filter with Detached ID '#{detach_with_id}' has already been requested once! There cannot be two instances of the same filter on one page")
44
+ end
44
45
  res = @filters[detach_with_id]
45
46
  @filters[detach_with_id] = false
46
47
  return res
data/lib/grid_renderer.rb CHANGED
@@ -14,9 +14,6 @@ module Wice
14
14
  attr_reader :blank_slate_handler
15
15
  attr_reader :last_row_handler
16
16
  attr_reader :grid
17
- attr_accessor :erb_mode
18
-
19
- attr_accessor :reset_button_present, :submit_button_present, :show_hide_button_present, :csv_export_icon_present
20
17
 
21
18
  @@order_parameter_name = "order"
22
19
  @@order_direction_parameter_name = "order_direction"
@@ -41,7 +38,7 @@ module Wice
41
38
 
42
39
 
43
40
  def add_column(vc) #:nodoc:
44
- @columns_table[vc.fully_qualified_attribute_name] = vc if vc.attribute_name
41
+ @columns_table[vc.fully_qualified_attribute_name] = vc if vc.attribute
45
42
  @columns << vc
46
43
  end
47
44
 
@@ -54,21 +51,17 @@ module Wice
54
51
  end
55
52
 
56
53
  def each_column_label(filter = nil) #:nodoc:
57
- filter_columns(filter).each{|col| yield col.column_name}
54
+ filter_columns(filter).each{|col| yield col.name}
58
55
  end
59
56
 
60
57
  def column_labels(filter = nil) #:nodoc:
61
- filter_columns(filter).collect(&:column_name)
58
+ filter_columns(filter).collect(&:name)
62
59
  end
63
60
 
64
61
  def each_column(filter = nil) #:nodoc:
65
62
  filter_columns(filter).each{|col| yield col}
66
63
  end
67
64
 
68
- def contains_a_text_input? #:nodoc:
69
- filter_columns(:in_html).detect(&:contains_a_text_input)
70
- end
71
-
72
65
  def each_column_aware_of_one_last_one(filter = nil) #:nodoc:
73
66
  cols = filter_columns(filter)
74
67
  cols[0..-2].each{|col| yield col, false}
@@ -89,30 +82,24 @@ module Wice
89
82
 
90
83
 
91
84
  def each_column_with_attribute #:nodoc:
92
- @columns.select(&:attribute_name).each{|col| yield col}
85
+ @columns.select(&:attribute).each{|col| yield col}
93
86
  end
94
87
 
95
88
  alias_method :each, :each_column
96
89
  include Enumerable
97
90
 
98
91
  def csv_export_icon #:nodoc:
99
- tooltip = WiceGridNlMessageProvider.get_message(:CSV_EXPORT_TOOLTIP)
100
- @csv_export_icon_present = true
101
- image_tag(Defaults::CSV_EXPORT_ICON,
102
- :title => tooltip,
103
- :class => 'clickable export_to_csv_button',
104
- :alt => tooltip
92
+ content_tag(:div, '',
93
+ :title => NlMessage['csv_export_tooltip'],
94
+ :class => 'clickable export-to-csv-button'
105
95
  )
106
96
  end
107
97
 
108
- def pagination_panel(no_rightmost_column, hide_csv_button) #:nodoc:
98
+ def pagination_panel(number_of_columns, hide_csv_button) #:nodoc:
109
99
  panel = yield
110
100
 
111
101
  render_csv_button = @grid.export_to_csv_enabled && ! hide_csv_button
112
102
 
113
- number_of_columns = self.number_of_columns(:in_html)
114
- number_of_columns -= 1 if no_rightmost_column
115
-
116
103
  if panel.nil?
117
104
  if render_csv_button
118
105
  "<tr><td colspan=\"#{number_of_columns}\"></td><td>#{csv_export_icon}</td></tr>"
@@ -128,11 +115,6 @@ module Wice
128
115
  end
129
116
  end
130
117
 
131
- def element_to_focus #:nodoc:
132
- grid.status['foc']
133
- end
134
-
135
-
136
118
  # Adds a column with checkboxes for each record. Useful for actions with multiple records, for example, deleting
137
119
  # selected records. Please note that +action_column+ only creates the checkboxes and the 'Select All' and
138
120
  # 'Deselect All' buttons, and the form itelf as well as processing the parameters should be taken care of
@@ -141,7 +123,7 @@ module Wice
141
123
  # * <tt>:param_name</tt> - The name of the HTTP parameter.
142
124
  # The complete HTTP parameter is <tt>"#{grid_name}[#{param_name}][]"</tt>.
143
125
  # The default param_name is 'selected'.
144
- # * <tt>:td_html_attrs</tt> - a hash of HTML attributes to be included into the <tt>td</tt> tag.
126
+ # * <tt>:html</tt> - a hash of HTML attributes to be included into the <tt>td</tt> tag.
145
127
  # * <tt>:select_all_buttons</tt> - show/hide buttons 'Select All' and 'Deselect All' in the column header.
146
128
  # The default is +true+.
147
129
  # * <tt>:object_property</tt> - a method used to obtain the value for the HTTP parameter. The default is +id+.
@@ -153,7 +135,7 @@ module Wice
153
135
 
154
136
  options = {
155
137
  :param_name => :selected,
156
- :td_html_attrs => {},
138
+ :html => {},
157
139
  :select_all_buttons => true,
158
140
  :object_property => :id
159
141
  }
@@ -161,7 +143,9 @@ module Wice
161
143
  opts.assert_valid_keys(options.keys)
162
144
  options.merge!(opts)
163
145
  @action_column_present = true
164
- @columns << ActionViewColumn.new(@grid, options[:td_html_attrs], options[:param_name],
146
+ column_processor_klass = ViewColumn.get_column_processor(:action)
147
+
148
+ @columns << column_processor_klass.new(@grid, options[:html], options[:param_name],
165
149
  options[:select_all_buttons], options[:object_property], @view)
166
150
  end
167
151
 
@@ -172,15 +156,15 @@ module Wice
172
156
  # The only parameter is a hash of options. None of them is optional. If no options are supplied, the result will be a
173
157
  # column with no name, no filtering and no sorting.
174
158
  #
175
- # * <tt>:column_name</tt> - Name of the column.
176
- # * <tt>:td_html_attrs</tt> - a hash of HTML attributes to be included into the <tt>td</tt> tag.
177
- # * <tt>:class</tt> - a shortcut for <tt>:td_html_attrs => {:class => 'css_class'}</tt>
178
- # * <tt>:attribute_name</tt> - name of a database column (which normally correspond to a model attribute with the
159
+ # * <tt>:name</tt> - Name of the column.
160
+ # * <tt>:html</tt> - a hash of HTML attributes to be included into the <tt>td</tt> tag.
161
+ # * <tt>:class</tt> - a shortcut for <tt>:html => {:class => 'css_class'}</tt>
162
+ # * <tt>:attribute</tt> - name of a database column (which normally correspond to a model attribute with the
179
163
  # same name). By default the field is assumed to belong to the default table (see documentation for the
180
- # +initialize_grid+ method). Parameter <tt>:model_class</tt> allows to specify another table. Presence of
164
+ # +initialize_grid+ method). Parameter <tt>:model</tt> allows to specify another table. Presence of
181
165
  # this parameter
182
166
  # * adds sorting capabilities by this field
183
- # * automatically creates a filter based on the type of the field unless parameter <tt>:no_filter</tt> is set to true.
167
+ # * automatically creates a filter based on the type of the field unless parameter <tt>:filter</tt> is set to false.
184
168
  # The following filters exist for the following types:
185
169
  # * <tt>string</tt> - a text field
186
170
  # * <tt>integer</tt> and <tt>float</tt> - two text fields to specify the range. Both limits or only one
@@ -190,11 +174,11 @@ module Wice
190
174
  # * <tt>date</tt> - two sets of standard date dropdown lists so specify the time range.
191
175
  # * <tt>datetime</tt> - two sets of standard datetime dropdown lists so specify the time range. This filter
192
176
  # is far from being user-friendly due to the number of dropdown lists.
193
- # * <tt>:no_filter</tt> - Turns off filters even if <tt>:attribute_name</tt> is specified.
177
+ # * <tt>:filter</tt> - Disables filters when set to false.
194
178
  # This is needed if sorting is required while filters are not.
195
- # * <tt>:allow_ordering</tt> - Enable/disable ordering links in the column titles. The default is +true+
196
- # (i.e. if <tt>:attribute_name</tt> is defined, ordering is enabled)
197
- # * <tt>:model_class</tt> - Name of the model class to which <tt>:attribute_name</tt> belongs to if this is not the main table.
179
+ # * <tt>:ordering</tt> - Enable/disable ordering links in the column titles. The default is +true+
180
+ # (i.e. if <tt>:attribute</tt> is defined, ordering is enabled)
181
+ # * <tt>:model</tt> - Name of the model class to which <tt>:attribute</tt> belongs to if this is not the main table.
198
182
  # * <tt>:table_alias</tt> - In case there are two joined assocations both referring to the same table, ActiveRecord
199
183
  # constructs a query where the second join provides an alias for the joined table. Setting <tt>:table_alias</tt>
200
184
  # to this alias will enable WiceGrid to order and filter by columns belonging to different associatiations but
@@ -208,8 +192,8 @@ module Wice
208
192
  # * Hash - The keys of the hash become the labels of the generated dropdown list,
209
193
  # while the values will be values of options of the dropdown list:
210
194
  # * <tt>:auto</tt> - a powerful option which populates the dropdown list with all unique values of the field specified by
211
- # <tt>:attribute_name</tt> and <tt>:model_class</tt>.
212
- # <tt>:attribute_name</tt> throughout all pages. In other words, this runs an SQL query without +offset+ and +limit+
195
+ # <tt>:attribute</tt> and <tt>:model</tt>.
196
+ # <tt>:attribute</tt> throughout all pages. In other words, this runs an SQL query without +offset+ and +limit+
213
197
  # clauses and with <tt>distinct(table.field)</tt> instead of <tt>distinct(*)</tt>
214
198
  # * any other symbol name (method name) - The dropdown list is populated by all unique value returned by the
215
199
  # method with this name sent to <em>all</em> ActiveRecord objects throughout all pages. The main difference
@@ -253,9 +237,9 @@ module Wice
253
237
  # * <tt>:helper_style</tt> - Changes the flavor of Date and DateTime filters. The values are:
254
238
  # * <tt>:standard</tt> - the default Rails Date/DateTime helper
255
239
  # * <tt>:calendar</tt> - a Javascript popup calendar control
256
- # * <tt>:negation_in_filter</tt> - turn on/off the negation checkbox in string filters
240
+ # * <tt>:negation</tt> - turn on/off the negation checkbox in string filters
257
241
  # * <tt>:auto_reload</tt> - a boolean value specifying if a change in a filter triggers reloading of the grid. Works with all
258
- # filter types including the JS calendar, the only exception is the standard Rails date/datetime filters.
242
+ # filter types including the JS calendar, the only exception is the standard Rails date/datetime filters.
259
243
  # The default is false. (see +AUTO_RELOAD+ in the configuration file).
260
244
  #
261
245
  # The block parameter is an ActiveRecord instance. This block is called for every ActiveRecord shown, and the return
@@ -264,71 +248,70 @@ module Wice
264
248
  # tag of the current cell.
265
249
  #
266
250
  # In case of an array output, please note that if you need to define HTML attributes for all <tt><td></tt>'s in a
267
- # column, use +td_html_attrs+. Also note that if the method returns a hash with a <tt>:class</tt> or <tt>'class'</tt>
268
- # element, it will not overwrite the class defined in +td_html_attrs+, or classes added by the grid itself
269
- # (+active_filter+ and +sorted+), instead they will be all concatenated:
251
+ # column, use +html+. Also note that if the method returns a hash with a <tt>:class</tt> or <tt>'class'</tt>
252
+ # element, it will not overwrite the class defined in +html+, or classes added by the grid itself
253
+ # (+active-filter+ and +sorted+), instead they will be all concatenated:
270
254
  # <tt><td class="sorted user_class_for_columns user_class_for_this_specific_cell"></tt>
271
255
  #
272
256
  # It is up to the developer to make sure that what in rendered in column cells
273
- # corresponds to sorting and filtering specified by parameters <tt>:attribute_name</tt> and <tt>:model_class</tt>.
257
+ # corresponds to sorting and filtering specified by parameters <tt>:attribute</tt> and <tt>:model</tt>.
274
258
 
275
259
  def column(opts = {}, &block)
276
260
  options = {
277
261
  :allow_multiple_selection => Defaults::ALLOW_MULTIPLE_SELECTION,
278
- :allow_ordering => true,
279
- :attribute_name => nil,
262
+ :ordering => true,
263
+ :attribute => nil,
280
264
  :auto_reload => Defaults::AUTO_RELOAD,
281
- :boolean_filter_false_label => WiceGridNlMessageProvider.get_message(:BOOLEAN_FILTER_FALSE_LABEL),
282
- :boolean_filter_true_label => WiceGridNlMessageProvider.get_message(:BOOLEAN_FILTER_TRUE_LABEL),
265
+ :boolean_filter_false_label => NlMessage['boolean_filter_false_label'],
266
+ :boolean_filter_true_label => NlMessage['boolean_filter_true_label'],
283
267
  :class => nil,
284
- :column_name => '',
268
+ :name => '',
285
269
  :custom_filter => nil,
286
- :custom_order => nil,
287
270
  :detach_with_id => nil,
288
271
  :filter_all_label => Defaults::CUSTOM_FILTER_ALL_LABEL,
289
272
  :helper_style => Defaults::HELPER_STYLE,
290
273
  :in_csv => true,
291
274
  :in_html => true,
292
- :model_class => nil,
293
- :negation_in_filter => Defaults::NEGATION_IN_STRING_FILTERS,
294
- :no_filter => false,
275
+ :model => nil,
276
+ :negation => Defaults::NEGATION_IN_STRING_FILTERS,
277
+ :filter => true,
295
278
  :table_alias => nil,
296
- :td_html_attrs => {}
279
+ :html => {}
297
280
  }
298
281
 
299
282
  opts.assert_valid_keys(options.keys)
300
283
  options.merge!(opts)
301
284
 
302
- unless options[:model_class].nil?
303
- options[:model_class] = options[:model_class].constantize if options[:model_class].is_a? String
304
- raise WiceGridArgumentError.new("Option :model_class can be either a class or a string instance") unless options[:model_class].is_a? Class
285
+ unless options[:model].nil?
286
+ options[:model] = options[:model].constantize if options[:model].is_a? String
287
+ raise WiceGridArgumentError.new("Option :model can be either a class or a string instance") unless options[:model].is_a? Class
305
288
  end
306
289
 
307
- if options[:attribute_name].nil? && options[:model_class]
308
- raise WiceGridArgumentError.new("Option :model_class is only used together with :attribute_name")
290
+ if options[:attribute].nil? && options[:model]
291
+ raise WiceGridArgumentError.new("Option :model is only used together with :attribute")
309
292
  end
310
293
 
311
- if options[:attribute_name] && options[:attribute_name].index('.')
312
- raise WiceGridArgumentError.new("Invalid attribute name #{options[:attribute_name]}. An attribute name must not contain a table name!")
294
+ if options[:attribute] && options[:attribute].index('.')
295
+ raise WiceGridArgumentError.new("Invalid attribute name #{options[:attribute]}. An attribute name must not contain a table name!")
313
296
  end
314
297
 
315
298
  if options[:class]
316
- options[:td_html_attrs].add_or_append_class_value!(options[:class])
299
+ options[:html].add_or_append_class_value!(options[:class])
317
300
  options.delete(:class)
318
301
  end
319
302
 
320
303
  if block.nil?
321
- if ! options[:attribute_name].blank?
322
- block = lambda{|obj| obj.send(options[:attribute_name])}
304
+ if ! options[:attribute].blank?
305
+ block = lambda{|obj| obj.send(options[:attribute])}
323
306
  else
324
307
  raise WiceGridArgumentError.new(
325
- "Missing column block without attribute_name defined. You can only omit the block if attribute_name is present.")
308
+ "Missing column block without attribute defined. You can only omit the block if attribute is present.")
326
309
  end
327
310
  end
328
311
 
329
312
  klass = ViewColumn
330
- if options[:attribute_name] &&
331
- col_type_and_table_name = @grid.declare_column(options[:attribute_name], options[:model_class],
313
+ if options[:attribute] &&
314
+ col_type_and_table_name = @grid.declare_column(options[:attribute], options[:model],
332
315
  options[:custom_filter], options[:table_alias])
333
316
 
334
317
  db_column, table_name, main_table = col_type_and_table_name
@@ -369,18 +352,19 @@ module Wice
369
352
  end
370
353
  end
371
354
 
372
- klass = ViewColumnCustomDropdown
355
+ klass = ViewColumn.get_column_processor(:custom)
373
356
  else
374
- klass = ViewColumn.handled_type[col_type] || ViewColumn
357
+ klass = ViewColumn.get_column_processor(col_type)
375
358
  end # custom_filter
376
- end # attribute_name
359
+
360
+ end # attribute
377
361
 
378
362
  vc = klass.new(block, options, @grid, table_name, main_table, custom_filter, @view)
379
363
 
380
- vc.negation = options[:negation_in_filter] if vc.respond_to? :negation=
364
+ vc.negation = options[:negation] if vc.respond_to? :negation=
381
365
 
382
- vc.filter_all_label = options[:filter_all_label] if vc.kind_of?(ViewColumnCustomDropdown)
383
- if vc.kind_of?(ViewColumnBoolean)
366
+ vc.filter_all_label = options[:filter_all_label] if vc.kind_of?(ViewColumn.get_column_processor(:custom))
367
+ if vc.kind_of?(ViewColumn.get_column_processor(:boolean))
384
368
  vc.boolean_filter_true_label = options[:boolean_filter_true_label]
385
369
  vc.boolean_filter_false_label = options[:boolean_filter_false_label]
386
370
  end
@@ -487,10 +471,10 @@ module Wice
487
471
 
488
472
  def column_link(column, direction, params, extra_parameters = {}) #:nodoc:
489
473
 
490
- column_attribute_name = if column.attribute_name.index('.') or column.main_table
491
- column.attribute_name
474
+ column_attribute_name = if column.attribute.index('.') or column.main_table
475
+ column.attribute
492
476
  else
493
- column.table_alias_or_table_name + '.' + column.attribute_name
477
+ column.table_alias_or_table_name + '.' + column.attribute
494
478
  end
495
479
 
496
480
  query_params = {@grid.name => {
@@ -510,32 +494,9 @@ module Wice
510
494
  '?' + query_params.to_query
511
495
  end
512
496
 
513
- def contains_auto_reloading_inputs #:nodoc:
514
- contains_auto_reloading_elements(:has_auto_reloading_input?)
515
- end
516
-
517
- def contains_auto_reloading_inputs_with_negation_checkboxes #:nodoc:
518
- contains_auto_reloading_elements(:auto_reloading_input_with_negation_checkbox?)
519
- end
520
-
521
- def contains_auto_reloading_selects #:nodoc:
522
- contains_auto_reloading_elements(:has_auto_reloading_select?)
523
- end
524
-
525
- def contains_auto_reloading_calendars #:nodoc:
526
- contains_auto_reloading_elements(:has_auto_reloading_calendar?)
527
- end
528
-
529
- def contains_range_filters
530
- filter_columns(:in_html).detect{|column| column.filter_shown? && column.is_a?(ViewColumnInteger)}
531
- end
532
497
 
533
498
  protected
534
499
 
535
- def contains_auto_reloading_elements(what) #:nodoc:
536
- filter_columns(:in_html).detect{|column| column.filter_shown? && column.send(what)}
537
- end
538
-
539
500
 
540
501
  def filter_columns(method_name = nil) #:nodoc:
541
502
  method_name ? @columns.select(&method_name) : @columns