Class: Wice::Columns::ViewColumn
- Includes:
- ActionView::Helpers::AssetTagHelper, ActionView::Helpers::FormTagHelper, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper
- Defined in:
- lib/wice/columns.rb
Overview
:nodoc:
Direct Known Subclasses
ViewColumnAction, ViewColumnBootstrapDatepicker, ViewColumnCustomDropdown, ViewColumnHtml5Datepicker, ViewColumnInteger, ViewColumnJqueryDatepicker, ViewColumnRailsDateHelper, ViewColumnRailsDatetimeHelper, ViewColumnRange, ViewColumnString
Constant Summary collapse
- FIELDS =
fields defined from the options parameter
[:attribute, :name, :html, :filter, :model, :allow_multiple_selection, :in_html, :in_csv, :table_alias, :custom_order, :detach_with_id, :ordering, :auto_reload, :filter_control_options, :sort_by]
Instance Attribute Summary collapse
-
#cell_rendering_block ⇒ Object
a Proc object which would return contents of one cell.
-
#contains_a_text_input ⇒ Object
readonly
A boolean flag: whether a column has a text input or not.
-
#custom_filter ⇒ Object
specification for a custom filter: an array of option label + option value pairs for the select, or a Proc object which returns this array.
-
#filter_control_options ⇒ Object
options for rendering filter controls.
-
#grid ⇒ Object
reference to the WiceGrid instance.
-
#main_table ⇒ Object
name of the main table (first argument to initialize_grid).
-
#table_name ⇒ Object
name of the table.
Instance Method Summary collapse
-
#add_css_class(klass_value) ⇒ Object
:nodoc:.
-
#attribute_name_fully_qualified_for_all_but_main_table_columns ⇒ Object
Returns a reference to the column in the form: “table_name.column_name”, unless it is a column in the main table, in which case it will return just “column_name”,.
-
#auto_reloading_input_with_negation_checkbox? ⇒ Boolean
:nodoc:.
-
#capable_of_hosting_filter_related_icons? ⇒ Boolean
:nodoc:.
-
#config ⇒ Object
:nodoc:.
-
#controller ⇒ Object
:nodoc:.
-
#css_class ⇒ Object
:nodoc:.
-
#detachness ⇒ Object
:nodoc:.
-
#filter_shown? ⇒ Boolean
:nodoc:.
-
#filter_shown_in_main_table? ⇒ Boolean
:nodoc:.
-
#form_parameter_name_id_and_query(v) ⇒ Object
:nodoc:.
-
#fully_qualified_attribute_name ⇒ Object
Returns a reference to the column in the form: “table_name.column_name”.
-
#has_auto_reloading_calendar? ⇒ Boolean
:nodoc:.
-
#has_auto_reloading_input? ⇒ Boolean
:nodoc:.
-
#has_auto_reloading_select? ⇒ Boolean
:nodoc:.
-
#initialize(block, options, grid_obj, tname, mtable, cfilter, view) ⇒ ViewColumn
constructor
:nodoc:.
-
#render_filter ⇒ Object
:nodoc:.
-
#render_filter_internal(_params) ⇒ Object
:nodoc:.
-
#table_alias_or_table_name ⇒ Object
:nodoc:.
-
#yield_declaration ⇒ Object
:nodoc:.
-
#yield_declaration_of_column_filter ⇒ Object
:nodoc:.
Methods included from ActionView::Helpers::TagHelper
Constructor Details
#initialize(block, options, grid_obj, tname, mtable, cfilter, view) ⇒ ViewColumn
:nodoc:
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/wice/columns.rb', line 131 def initialize(block, , grid_obj, tname, mtable, cfilter, view) #:nodoc: self.cell_rendering_block = block self.grid = grid_obj self.table_name = tname self.main_table = mtable self.custom_filter = cfilter @view = view FIELDS.each do |field| self.send(field.to_s + '=', [field]) end end |
Instance Attribute Details
#cell_rendering_block ⇒ Object
a Proc object which would return contents of one cell
108 109 110 |
# File 'lib/wice/columns.rb', line 108 def cell_rendering_block @cell_rendering_block end |
#contains_a_text_input ⇒ Object (readonly)
A boolean flag: whether a column has a text input or not
126 127 128 |
# File 'lib/wice/columns.rb', line 126 def contains_a_text_input @contains_a_text_input end |
#custom_filter ⇒ Object
specification for a custom filter: an array of option label + option value pairs for the select, or a Proc object which returns this array. Or nil if it is not a custom filter
123 124 125 |
# File 'lib/wice/columns.rb', line 123 def custom_filter @custom_filter end |
#filter_control_options ⇒ Object
options for rendering filter controls. Supported options are specific to the type.
129 130 131 |
# File 'lib/wice/columns.rb', line 129 def @filter_control_options end |
#grid ⇒ Object
reference to the WiceGrid instance
111 112 113 |
# File 'lib/wice/columns.rb', line 111 def grid @grid end |
#main_table ⇒ Object
name of the main table (first argument to initialize_grid)
117 118 119 |
# File 'lib/wice/columns.rb', line 117 def main_table @main_table end |
#table_name ⇒ Object
name of the table
114 115 116 |
# File 'lib/wice/columns.rb', line 114 def table_name @table_name end |
Instance Method Details
#add_css_class(klass_value) ⇒ Object
:nodoc:
144 145 146 147 148 149 150 151 152 |
# File 'lib/wice/columns.rb', line 144 def add_css_class(klass_value) #:nodoc: self.html ||= {} if html[:class].nil? html[:class] = klass_value else html[:class] += ' ' unless html[:class].empty? html[:class] << klass_value end end |
#attribute_name_fully_qualified_for_all_but_main_table_columns ⇒ Object
Returns a reference to the column in the form: “table_name.column_name”, unless it is a column in the main table, in which case it will return just “column_name”,
208 209 210 211 |
# File 'lib/wice/columns.rb', line 208 def attribute_name_fully_qualified_for_all_but_main_table_columns return attribute if main_table return fully_qualified_attribute_name end |
#auto_reloading_input_with_negation_checkbox? ⇒ Boolean
:nodoc:
238 239 240 |
# File 'lib/wice/columns.rb', line 238 def auto_reloading_input_with_negation_checkbox? #:nodoc: false end |
#capable_of_hosting_filter_related_icons? ⇒ Boolean
:nodoc:
230 231 232 |
# File 'lib/wice/columns.rb', line 230 def #:nodoc: self.attribute.blank? && self.name.blank? && !self.filter_shown? end |
#config ⇒ Object
:nodoc:
181 182 183 |
# File 'lib/wice/columns.rb', line 181 def config #:nodoc: @view.config end |
#controller ⇒ Object
:nodoc:
185 186 187 |
# File 'lib/wice/columns.rb', line 185 def controller #:nodoc: @view.controller end |
#css_class ⇒ Object
:nodoc:
154 155 156 157 158 159 160 |
# File 'lib/wice/columns.rb', line 154 def css_class #:nodoc: if html && html[:class] html[:class] else '' end end |
#detachness ⇒ Object
:nodoc:
166 167 168 |
# File 'lib/wice/columns.rb', line 166 def detachness #:nodoc: (!detach_with_id.blank?).to_s end |
#filter_shown? ⇒ Boolean
:nodoc:
218 219 220 |
# File 'lib/wice/columns.rb', line 218 def filter_shown? #:nodoc: self.attribute && self.filter end |
#filter_shown_in_main_table? ⇒ Boolean
:nodoc:
222 223 224 |
# File 'lib/wice/columns.rb', line 222 def filter_shown_in_main_table? #:nodoc: filter_shown? && !self.detach_with_id end |
#form_parameter_name_id_and_query(v) ⇒ Object
:nodoc:
198 199 200 201 202 203 204 |
# File 'lib/wice/columns.rb', line 198 def form_parameter_name_id_and_query(v) #:nodoc: query = form_parameter_template(v) query_without_equals_sign = query.sub(/=$/, '') parameter_name = CGI.unescape(query_without_equals_sign) dom_id = id_out_of_name(parameter_name) [query, query_without_equals_sign, parameter_name, dom_id.tr('.', '_')] end |
#fully_qualified_attribute_name ⇒ Object
Returns a reference to the column in the form: “table_name.column_name”.
214 215 216 |
# File 'lib/wice/columns.rb', line 214 def fully_qualified_attribute_name table_alias_or_table_name ? (table_alias_or_table_name + '.' + attribute) : nil end |
#has_auto_reloading_calendar? ⇒ Boolean
:nodoc:
246 247 248 |
# File 'lib/wice/columns.rb', line 246 def has_auto_reloading_calendar? #:nodoc: false end |
#has_auto_reloading_input? ⇒ Boolean
:nodoc:
234 235 236 |
# File 'lib/wice/columns.rb', line 234 def has_auto_reloading_input? #:nodoc: false end |
#has_auto_reloading_select? ⇒ Boolean
:nodoc:
242 243 244 |
# File 'lib/wice/columns.rb', line 242 def has_auto_reloading_select? #:nodoc: false end |
#render_filter ⇒ Object
:nodoc:
189 190 191 192 |
# File 'lib/wice/columns.rb', line 189 def render_filter #:nodoc: params = @grid.filter_params(self) render_filter_internal(params) end |
#render_filter_internal(_params) ⇒ Object
:nodoc:
194 195 196 |
# File 'lib/wice/columns.rb', line 194 def render_filter_internal(_params) #:nodoc: '<!-- implement me! -->' end |
#table_alias_or_table_name ⇒ Object
:nodoc:
226 227 228 |
# File 'lib/wice/columns.rb', line 226 def table_alias_or_table_name #:nodoc: table_alias || table_name end |
#yield_declaration ⇒ Object
:nodoc:
170 171 172 173 174 175 176 177 178 179 |
# File 'lib/wice/columns.rb', line 170 def yield_declaration #:nodoc: declaration = yield_declaration_of_column_filter if declaration { filterName: self.name, detached: detachness, declaration: declaration } end end |
#yield_declaration_of_column_filter ⇒ Object
:nodoc:
162 163 164 |
# File 'lib/wice/columns.rb', line 162 def yield_declaration_of_column_filter #:nodoc: nil end |