module ActiveScaffold::Helpers::ShowColumnHelpers

Helpers that assist with the rendering of a List Column

Public Instance Methods

active_scaffold_show_horizontal(record, column, ui_options: column.options) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 28
def active_scaffold_show_horizontal(record, column, ui_options: column.options)
  raise ':horizontal show_ui must be used on association column' unless column.association
  render :partial => 'show_association', :locals => {:column => column, :parent_record => record, :show_partial => :horizontal}
end
active_scaffold_show_text(record, column, ui_options: column.options) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 24
def active_scaffold_show_text(record, column, ui_options: column.options)
  simple_format(clean_column_value(record.send(column.name)), ui_options[:html_options], ui_options)
end
active_scaffold_show_vertical(record, column, ui_options: column.options) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 33
def active_scaffold_show_vertical(record, column, ui_options: column.options)
  raise ':vertical show_ui must be used on association column' unless column.association
  render :partial => 'show_association', :locals => {:column => column, :parent_record => record, :show_partial => :vertical}
end
override_show_column_ui(show_ui) click to toggle source

the naming convention for overriding show types with helpers

# File lib/active_scaffold/helpers/show_column_helpers.rb, line 55
def override_show_column_ui(show_ui)
  method = "active_scaffold_show_#{show_ui}"
  method if respond_to? method
end
show_column_override(column) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 50
def show_column_override(column)
  override_helper column, 'show_column'
end
show_column_value(record, column) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 5
def show_column_value(record, column)
  value_record = column.delegated_association ? record.send(column.delegated_association.name) : record
  return get_column_value(record, column) unless value_record
  # check for an override helper
  if (method = show_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.
    send(method, value_record, column)
  # second, check if the dev has specified a valid list_ui for this column
  elsif column.show_ui && (method = override_show_column_ui(column.show_ui))
    send(method, value_record, column, ui_options: column.show_ui_options || column.options)
  elsif column.column && (method = override_show_column_ui(column.column_type))
    send(method, value_record, column)
  else
    get_column_value(record, column)
  end
end
show_columns_for(record, parent_column = nil, hash = {}) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 38
def show_columns_for(record, parent_column = nil, hash = {})
  hash[record.class] ||= begin
    columns = active_scaffold_config_for(record.class).show.columns
    columns.constraint_columns = [parent_column.association.reverse] if parent_column
    columns
  end
end
show_label(column) click to toggle source
# File lib/active_scaffold/helpers/show_column_helpers.rb, line 46
def show_label(column)
  column.label
end