Module: ActiveScaffold::Helpers::ListColumnHelpers
- Included in:
- ViewHelpers
- Defined in:
- lib/active_scaffold/bridges/file_column/list_ui.rb,
lib/active_scaffold/bridges/dragonfly/list_ui.rb,
lib/active_scaffold/bridges/paperclip/list_ui.rb,
lib/active_scaffold/bridges/carrierwave/list_ui.rb,
lib/active_scaffold/helpers/list_column_helpers.rb
Overview
Helpers that assist with the rendering of a List Column
Instance Method Summary collapse
- #active_scaffold_column_carrierwave(record, column) ⇒ Object
- #active_scaffold_column_checkbox(record, column) ⇒ Object
- #active_scaffold_column_download_link(record, column, label = nil) ⇒ Object
- #active_scaffold_column_download_link_with_filename(record, column) ⇒ Object
- #active_scaffold_column_dragonfly(record, column) ⇒ Object
- #active_scaffold_column_fulltext(record, column) ⇒ Object
- #active_scaffold_column_marked(record, column) ⇒ Object
- #active_scaffold_column_month(record, column) ⇒ Object
- #active_scaffold_column_paperclip(record, column) ⇒ Object
- #active_scaffold_column_percentage(record, column) ⇒ Object
- #active_scaffold_column_telephone(record, column) ⇒ Object
-
#active_scaffold_column_text(record, column) ⇒ Object
Overrides.
- #active_scaffold_column_thumbnail(record, column) ⇒ Object
- #active_scaffold_column_week(record, column) ⇒ Object
- #active_scaffold_inplace_edit(record, column, options = {}) ⇒ Object
- #active_scaffold_inplace_edit_tag_options(record, column) ⇒ Object
-
#all_marked? ⇒ Boolean
MARK.
- #cache_association(association, column, size) ⇒ Object
-
#clean_column_value(v) ⇒ Object
There are two basic ways to clean a column’s value: h() and sanitize().
-
#column_calculation(column) ⇒ Object
CALCULATIONS.
-
#column_heading_attributes(column, sorting, sort_direction) ⇒ Object
COLUMN HEADINGS.
- #column_heading_label(column) ⇒ Object
- #column_heading_value(column, sorting, sort_direction) ⇒ Object
- #column_override(column) ⇒ Object (also: #column_override?)
- #dragonfly_url_for_attachment(attachment, record, column) ⇒ Object
- #format_association_value(value, column, size) ⇒ Object
- #format_collection_association_value(value, column, label_method, size) ⇒ Object
- #format_column_calculation(column, calculation) ⇒ Object
-
#format_column_value(record, column, value = nil) ⇒ Object
Formatting.
- #format_grouped_search_column(value, options = {}) ⇒ Object
- #format_number_value(value, options = {}) ⇒ Object
- #format_singular_association_value(value, column, label_method) ⇒ Object
- #format_value(column_value, options = {}) ⇒ Object
- #get_column_method(record, column) ⇒ Object
- #get_column_value(record, column) ⇒ Object
-
#inplace_edit?(record, column) ⇒ Boolean
= Inline Edit = ==========.
- #inplace_edit_cloning?(column) ⇒ Boolean
- #inplace_edit_control(column) ⇒ Object
- #inplace_edit_control_css_class ⇒ Object
- #inplace_edit_data(column) ⇒ Object
- #mark_column_heading ⇒ Object
-
#override_column_ui(list_ui) ⇒ Object
(also: #override_column_ui?)
the naming convention for overriding column types with helpers.
- #render_column_calculation(column) ⇒ Object
- #render_column_heading(column, sorting, sort_direction) ⇒ Object
-
#render_list_column(text, column, record) ⇒ Object
TODO: move empty_field_text and logic in here? TODO: we need to distinguish between the automatic links we create and the ones that the dev specified.
- #tel_to(text) ⇒ Object
Instance Method Details
#active_scaffold_column_carrierwave(record, column) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/active_scaffold/bridges/carrierwave/list_ui.rb', line 4 def active_scaffold_column_carrierwave(record, column) carrierwave = record.send(column.name.to_s) return nil if carrierwave.file.blank? thumbnail_style = ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridgeHelpers.thumbnail_style content = if carrierwave.versions.keys.include?(thumbnail_style) image_tag(carrierwave.url(thumbnail_style), :border => 0).html_safe else record.send(record.send(:_mounter, column.name).send(:serialization_column)) end link_to(content, carrierwave.url, :target => '_blank') end |
#active_scaffold_column_checkbox(record, column) ⇒ Object
88 89 90 91 92 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 88 def active_scaffold_column_checkbox(record, column) = {:disabled => true, :id => nil, :object => record} .delete(:disabled) if inplace_edit?(record, column) check_box(:record, column.name, ) end |
#active_scaffold_column_download_link(record, column, label = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/active_scaffold/bridges/file_column/list_ui.rb', line 10 def active_scaffold_column_download_link(record, column, label = nil) return nil if record.send(column.name).nil? label ||= as_(:download) link_to(label, url_for_file_column(record, column.name.to_s), :popup => true) end |
#active_scaffold_column_download_link_with_filename(record, column) ⇒ Object
5 6 7 8 |
# File 'lib/active_scaffold/bridges/file_column/list_ui.rb', line 5 def active_scaffold_column_download_link_with_filename(record, column) return nil if record.send(column.name).nil? active_scaffold_column_download_link(record, column, File.basename(record.send(column.name))) end |
#active_scaffold_column_dragonfly(record, column) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/active_scaffold/bridges/dragonfly/list_ui.rb', line 4 def active_scaffold_column_dragonfly(record, column) = record.send(column.name.to_s) return nil if .blank? content = if .image? image_tag(.thumb(column.[:thumb] || ActiveScaffold::Bridges::Dragonfly::DragonflyBridgeHelpers.thumbnail_style).url, :border => 0) else .name end link_to(content, (, record, column), :target => '_blank') end |
#active_scaffold_column_fulltext(record, column) ⇒ Object
79 80 81 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 79 def active_scaffold_column_fulltext(record, column) clean_column_value(record.send(column.name)) end |
#active_scaffold_column_marked(record, column) ⇒ Object
83 84 85 86 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 83 def active_scaffold_column_marked(record, column) = {:id => nil, :object => record} content_tag(:span, check_box(:record, column.name, ), :class => 'in_place_editor_field', :data => {:ie_id => record.to_param}) end |
#active_scaffold_column_month(record, column) ⇒ Object
102 103 104 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 102 def active_scaffold_column_month(record, column) l record.send(column.name), format: :year_month end |
#active_scaffold_column_paperclip(record, column) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/active_scaffold/bridges/paperclip/list_ui.rb', line 4 def active_scaffold_column_paperclip(record, column) paperclip = record.send(column.name.to_s) return nil unless paperclip.file? content = if paperclip.styles.include?(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style) image_tag(paperclip.url(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style), :border => 0) else paperclip.original_filename end link_to(content, paperclip.url, :target => '_blank') end |
#active_scaffold_column_percentage(record, column) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 94 def active_scaffold_column_percentage(record, column) = column.[:slider] || {} = .merge(min: record.send([:min_method])) if [:min_method] = .merge(max: record.send([:max_method])) if [:max_method] value = record.send([:value_method]) if [:value_method] .merge(value: value || record.send(column.name)) end |
#active_scaffold_column_telephone(record, column) ⇒ Object
116 117 118 119 120 121 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 116 def active_scaffold_column_telephone(record, column) phone = record.send column.name return if phone.blank? phone = number_to_phone(phone) unless column.[:format] == false tel_to phone end |
#active_scaffold_column_text(record, column) ⇒ Object
Overrides
74 75 76 77 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 74 def active_scaffold_column_text(record, column) # `to_s` is necessary to convert objects in serialized columns to string before truncation. clean_column_value(truncate(record.send(column.name).to_s, :length => column.[:truncate] || 50)) end |
#active_scaffold_column_thumbnail(record, column) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/active_scaffold/bridges/file_column/list_ui.rb', line 16 def active_scaffold_column_thumbnail(record, column) return nil if record.send(column.name).nil? link_to( image_tag(url_for_file_column(record, column.name.to_s, 'thumb'), :border => 0), url_for_file_column(record, column.name.to_s), :popup => true ) end |
#active_scaffold_column_week(record, column) ⇒ Object
106 107 108 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 106 def active_scaffold_column_week(record, column) l record.send(column.name), format: :week end |
#active_scaffold_inplace_edit(record, column, options = {}) ⇒ Object
290 291 292 293 294 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 290 def active_scaffold_inplace_edit(record, column, = {}) formatted_column = [:formatted_column] || format_column_value(record, column) content_tag(:span, as_(:inplace_edit_handle), :class => 'handle') << content_tag(:span, formatted_column, (record, column)) end |
#active_scaffold_inplace_edit_tag_options(record, column) ⇒ Object
282 283 284 285 286 287 288 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 282 def (record, column) = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s} = {:id => element_cell_id(), :class => 'in_place_editor_field', :title => as_(:click_to_edit), :data => {:ie_id => record.to_param}} [:data][:ie_update] = column.inplace_edit if column.inplace_edit != true end |
#all_marked? ⇒ Boolean
MARK
340 341 342 343 344 345 346 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 340 def all_marked? if active_scaffold_config.mark.mark_all_mode == :page @page.items.detect { |record| !marked_records.include?(record.id) }.nil? else marked_records.length >= @page.pager.count.to_i end end |
#cache_association(association, column, size) ⇒ Object
248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 248 def cache_association(association, column, size) # we are not using eager loading, cache firsts records in order not to query the database for whole association in a future if column.associated_limit.nil? logger.warn "ActiveScaffold: Enable eager loading for #{column.name} association to reduce SQL queries" elsif column.associated_limit > 0 # load at least one record more, is needed to display '...' association.target = association.reader.limit(column.associated_limit + 1).select(column.select_associated_columns || "#{association.klass.quoted_table_name}.*").to_a elsif @cache_associations # set array with at least one element if size > 0, so blank? or present? works, saving [nil] may cause exceptions association.target = size.to_i.zero? ? [] : [association.klass.new] end end |
#clean_column_value(v) ⇒ Object
There are two basic ways to clean a column’s value: h() and sanitize(). The latter is useful when the column contains valid html data, and you want to just disable any scripting. People can always use field overrides to clean data one way or the other, but having this override lets people decide which way it should happen by default.
Why is it not a configuration option? Because it seems like a somewhat rare request. But it could eventually be an option in config.list (and config.show, I guess).
67 68 69 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 67 def clean_column_value(v) h(v) end |
#column_calculation(column) ⇒ Object
CALCULATIONS
401 402 403 404 405 406 407 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 401 def column_calculation(column) if column.calculate.instance_of? Proc column.calculate.call(@records) else calculate_query.calculate(column.calculate, column.name) end end |
#column_heading_attributes(column, sorting, sort_direction) ⇒ Object
COLUMN HEADINGS
358 359 360 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 358 def column_heading_attributes(column, sorting, sort_direction) {:id => active_scaffold_column_header_id(column), :class => column_heading_class(column, sorting), :title => (column.description).presence} end |
#column_heading_label(column) ⇒ Object
395 396 397 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 395 def column_heading_label(column) column.label end |
#column_heading_value(column, sorting, sort_direction) ⇒ Object
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 375 def column_heading_value(column, sorting, sort_direction) if column.name == :as_marked mark_column_heading elsif column.sortable? = {:id => nil, :class => 'as_sort', 'data-page-history' => controller_id, :remote => true, :method => :get} = {action: :index, page: 1, sort: column.name, sort_direction: sort_direction} # :id needed because rails reuse it even if it was deleted from params (like do_refresh_list does) [:id] = nil if @remove_id_from_list_links = params_for() unless active_scaffold_config.store_user_settings [:search] = search_params if respond_to?(:search_params) && search_params.present? end link_to column_heading_label(column), , else content_tag(:p, column_heading_label(column)) end end |
#column_override(column) ⇒ Object Also known as: column_override?
123 124 125 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 123 def column_override(column) override_helper column, 'column' end |
#dragonfly_url_for_attachment(attachment, record, column) ⇒ Object
16 17 18 19 |
# File 'lib/active_scaffold/bridges/dragonfly/list_ui.rb', line 16 def (, record, column) url_method = column.[:private_store] ? :url : :remote_url .send(url_method) end |
#format_association_value(value, column, size) ⇒ Object
223 224 225 226 227 228 229 230 231 232 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 223 def format_association_value(value, column, size) method = column.[:label_method] || :to_label value = if column.association.collection? format_collection_association_value(value, column, method, size) elsif value format_singular_association_value(value, column, method) end format_value value end |
#format_collection_association_value(value, column, label_method, size) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 199 def format_collection_association_value(value, column, label_method, size) if column.associated_limit.nil? firsts = value.collect(&label_method) safe_join firsts, active_scaffold_config.list.association_join_text elsif column.associated_limit.zero? size if column.associated_number? else firsts = value.loaded? ? value[0, column.associated_limit] : value.limit(column.associated_limit) firsts = firsts.map(&label_method) firsts << '…' if value.size > column.associated_limit text = safe_join firsts, active_scaffold_config.list.association_join_text text << " (#{size})" if column.associated_number? && column.associated_limit && value.size > column.associated_limit text end end |
#format_column_calculation(column, calculation) ⇒ Object
416 417 418 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 416 def format_column_calculation(column, calculation) "#{"#{as_(column.calculate)}: " unless column.calculate.is_a? Proc}#{format_column_value nil, column, calculation}" end |
#format_column_value(record, column, value = nil) ⇒ Object
Formatting
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 140 def format_column_value(record, column, value = nil) value ||= record.send(column.name) unless record.nil? if column.association.nil? if %i[select radio].include?(column.form_ui) && column.[:options] text, val = column.[:options].find { |t, v| (v.nil? ? t : v).to_s == value.to_s } value = active_scaffold_translated_option(column, text, val).first if text end if grouped_search? && column == search_group_column && search_group_function format_grouped_search_column(value, column.) elsif value.is_a? Numeric format_number_value(value, column.) else format_value(value, column.) end else if column.association.collection? associated_size = value.size if column.associated_number? # get count before cache association if column.association.respond_to_target? && !value.loaded? cache_association(record.association(column.name), column, associated_size) end end format_association_value(value, column, associated_size) end end |
#format_grouped_search_column(value, options = {}) ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 183 def format_grouped_search_column(value, = {}) case search_group_function when 'year_month' year, month = value.to_s.scan(/(\d*)(\d{2})/)[0] I18n.l(Date.new(year.to_i, month.to_i, 1), format: [:group_format] || search_group_function.to_sym) when 'year_quarter' year, quarter = value.to_s.scan(/(\d*)(\d)/)[0] I18n.t([:group_format] || search_group_function, scope: 'date.formats', year: year, quarter: quarter) when 'quarter' I18n.t([:group_format] || search_group_function, scope: 'date.formats', num: value) when 'month' I18n.l(Date.new(Time.zone.today.year, value, 1), format: [:group_format] || search_group_function.to_sym) else value end end |
#format_number_value(value, options = {}) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 165 def format_number_value(value, = {}) if value value = case [:format] when :size number_to_human_size(value, [:i18n_options] || {}) when :percentage number_to_percentage(value, [:i18n_options] || {}) when :currency number_to_currency(value, [:i18n_options] || {}) when :i18n_number send("number_with_#{value.is_a?(Integer) ? 'delimiter' : 'precision'}", value, [:i18n_options] || {}) else value end end clean_column_value(value) end |
#format_singular_association_value(value, column, label_method) ⇒ Object
215 216 217 218 219 220 221 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 215 def format_singular_association_value(value, column, label_method) if column.association.polymorphic? "#{value.class.model_name.human}: #{value.send(label_method)}" else value.send(label_method) end end |
#format_value(column_value, options = {}) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 234 def format_value(column_value, = {}) value = if column_empty?(column_value) empty_field_text elsif column_value.is_a?(Time) || column_value.is_a?(Date) l(column_value, :format => [:format] || :default) elsif [FalseClass, TrueClass].include?(column_value.class) as_(column_value.to_s.to_sym) else column_value.to_s end clean_column_value(value) end |
#get_column_method(record, column) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 20 def get_column_method(record, column) # check for an override helper column.list_method ||= begin if (method = column_override(column)) # we only pass the record as the argument. we previously also passed the formatted_value, # but mike perham pointed out that prohibited the usage of overrides to improve on the # performance of our default formatting. see issue #138. method # second, check if the dev has specified a valid list_ui for this column elsif column.list_ui && (method = override_column_ui(column.list_ui)) method elsif column.column && (method = override_column_ui(column.column.type)) method else :format_column_value end end end |
#get_column_value(record, column) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 5 def get_column_value(record, column) record = record.send(column.delegated_association.name) if column.delegated_association if record method = get_column_method(record, column) value = send(method, record, column) else value = nil end value = ' '.html_safe if value.nil? || value.blank? # fix for IE 6 return value rescue StandardError => e logger.error "#{e.class.name}: #{e.} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}, record: #{record.inspect}" raise e end |
#inplace_edit?(record, column) ⇒ Boolean
Inline Edit =
265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 265 def inplace_edit?(record, column) return unless column.inplace_edit if controller.respond_to?(:update_authorized?, true) if controller.method(:update_authorized?).parameters.size == 2 return Array(controller.send(:update_authorized?, record, column.name))[0] else ActiveSupport::Deprecation.warn 'add column = nil parameter to update_authorized? on your controller' editable = Array(controller.send(:update_authorized?, record))[0] end end editable || record.(:crud_type => :update, :column => column.name) end |
#inplace_edit_cloning?(column) ⇒ Boolean
278 279 280 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 278 def inplace_edit_cloning?(column) column.inplace_edit != :ajax && (override_form_field?(column) || column.form_ui || (column.column && override_input?(column.column.type))) end |
#inplace_edit_control(column) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 296 def inplace_edit_control(column) return unless inplace_edit?(active_scaffold_config.model, column) && inplace_edit_cloning?(column) column = column.clone column. = column..clone column.form_ui = :select if column.association && column.form_ui.nil? = (column).merge(:object => column.active_record_class.new) [:class] = "#{[:class]} inplace_field" [:"data-id"] = [:id] [:id] = nil content_tag(:div, active_scaffold_input_for(column, nil, ), :style => 'display:none;', :class => inplace_edit_control_css_class) end |
#inplace_edit_control_css_class ⇒ Object
308 309 310 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 308 def inplace_edit_control_css_class 'as_inplace_pattern' end |
#inplace_edit_data(column) ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 312 def inplace_edit_data(column) data = {} data[:ie_url] = url_for(params_for(:action => 'update_column', :column => column.name, :id => '__id__')) data[:ie_cancel_text] = column.[:cancel_text] || as_(:cancel) data[:ie_loading_text] = column.[:loading_text] || as_(:loading) data[:ie_save_text] = column.[:save_text] || as_(:update) data[:ie_saving_text] = column.[:saving_text] || as_(:saving) data[:ie_rows] = column.[:rows] || 5 if column.column.try(:type) == :text data[:ie_cols] = column.[:cols] if column.[:cols] data[:ie_size] = column.[:size] if column.[:size] data[:ie_use_html] = column.[:use_html] if column.[:use_html] if column.list_ui == :checkbox data[:ie_mode] = :inline_checkbox elsif inplace_edit_cloning?(column) data[:ie_mode] = :clone elsif column.inplace_edit == :ajax url = url_for(params_for(:controller => params_for[:controller], :action => 'render_field', :id => '__id__', :update_column => column.name)) plural = column.association.try(:collection?) && !override_form_field?(column) && %i[select record_select].include?(column.form_ui) data[:ie_render_url] = url data[:ie_mode] = :ajax data[:ie_plural] = plural end data end |
#mark_column_heading ⇒ Object
348 349 350 351 352 353 354 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 348 def mark_column_heading = { :id => "#{controller_id}_mark_heading", :class => 'mark_heading in_place_editor_field' } content_tag(:span, check_box_tag("#{controller_id}_mark_heading_span_input", '1', all_marked?), ) end |
#override_column_ui(list_ui) ⇒ Object Also known as: override_column_ui?
the naming convention for overriding column types with helpers
129 130 131 132 133 134 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 129 def override_column_ui(list_ui) @_column_ui_overrides ||= {} return @_column_ui_overrides[list_ui] if @_column_ui_overrides.include? list_ui method = "active_scaffold_column_#{list_ui}" @_column_ui_overrides[list_ui] = (method if respond_to? method) end |
#render_column_calculation(column) ⇒ Object
409 410 411 412 413 414 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 409 def render_column_calculation(column) calculation = column_calculation(column) override_formatter = "render_#{column.name}_#{column.calculate.is_a?(Proc) ? :calculate : column.calculate}" calculation = send(override_formatter, calculation) if respond_to? override_formatter format_column_calculation(column, calculation) end |
#render_column_heading(column, sorting, sort_direction) ⇒ Object
362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 362 def render_column_heading(column, sorting, sort_direction) = column_heading_attributes(column, sorting, sort_direction) if column.name == :as_marked [:data] = { :ie_mode => :inline_checkbox, :ie_url => url_for(params_for(:action => 'mark', :id => '__id__')) } else [:data] = inplace_edit_data(column) if column.inplace_edit end content_tag(:th, column_heading_value(column, sorting, sort_direction) + inplace_edit_control(column), ) end |
#render_list_column(text, column, record) ⇒ Object
TODO: move empty_field_text and logic in here? TODO: we need to distinguish between the automatic links we create and the ones that the dev specified. some logic may not apply if the dev specified the link.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 41 def render_list_column(text, column, record) if column.link && !skip_action_link?(column.link, record) link = column.link associated = record.send(column.association.name) if column.association = link.action.nil? , reason = (link, column, record, associated) unless render_action_link(link, record, :link => text, :authorized => , :not_authorized_reason => reason) elsif inplace_edit?(record, column) active_scaffold_inplace_edit(record, column, :formatted_column => text) elsif active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.wrap_tag content_tag active_scaffold_config.list.wrap_tag, text else text end rescue StandardError => e logger.error "#{e.class.name}: #{e.} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}" raise e end |
#tel_to(text) ⇒ Object
110 111 112 113 114 |
# File 'lib/active_scaffold/helpers/list_column_helpers.rb', line 110 def tel_to(text) groups = text.to_s.scan(/(?:^\+)?\d+/) extension = groups.pop if text.to_s =~ /\s*[^\d\s]+\s*\d+$/ link_to text, "tel:#{[groups.join('-'), extension].compact.join(',')}" end |