module ActiveScaffold::Helpers::UpdateColumnHelpers

Helpers that assist with the rendering of a Form Column

Public Instance Methods

active_scaffold_update_decimal(column, options)
active_scaffold_update_float(column, options)
active_scaffold_update_for(column, scope = nil, options = {}) click to toggle source

This method decides which input to use for the given column. It does not do any rendering. It only decides which method is responsible for rendering.

# File lib/active_scaffold/helpers/update_column_helpers.rb, line 7
def active_scaffold_update_for(column, scope = nil, options = {})
  options = active_scaffold_input_options(column, scope, options)
  options.delete(:required)

  # first, check if the dev has created an override for this specific field for search
  if (method = override_update_field(column))
    send(method, options[:object], options)
  # second, check if the dev has specified a valid form_ui for this column, using specific ui for searches
  elsif column.form_ui and (method = override_update(column.form_ui))
    send(method, column, options)
 elsif column.column and column.form_ui.nil? and (method = override_update(column.column.type))
    send(method, column, options)
  else
    active_scaffold_update_generic_operators_select(column, options)<< ' ' << active_scaffold_render_input(column, options.merge(:name => "record[#{column.name}][value]"))
  end
end
active_scaffold_update_generic_operators(column) click to toggle source
# File lib/active_scaffold/helpers/update_column_helpers.rb, line 24
def active_scaffold_update_generic_operators(column)
  operators = ActiveScaffold::Actions::BatchUpdate::GenericOperators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
  if column.column.nil? || column.column.null
    operators << [as_(:null), 'NULL']
  end
  operators
end
active_scaffold_update_generic_operators_select(column, options) click to toggle source
# File lib/active_scaffold/helpers/update_column_helpers.rb, line 32
def active_scaffold_update_generic_operators_select(column, options)
  current = {:operator => 'NO_UPDATE'}
  current.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
  select_tag("[record][#{column.name}][operator]",
        options_for_select(active_scaffold_update_generic_operators(column), current[:operator]),
        :id => "#{options[:id]}_operator",
        :class => "as_batch_update_operator text_input")
end
active_scaffold_update_integer(column, options)
active_scaffold_update_numeric(column, options) click to toggle source
# File lib/active_scaffold/helpers/update_column_helpers.rb, line 41
def active_scaffold_update_numeric(column, options)
  current = {:value => nil, :opt => 'ABSOLUTE', :operator => 'NO_UPDATE'}
  current.merge!(batch_update_values[column.name][:value].symbolize_keys) if batch_update_values[column.name] && batch_update_values[column.name][:value]
  operator_options = active_scaffold_update_generic_operators(column) + ActiveScaffold::Actions::BatchUpdate::NumericOperators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
  select_options = ActiveScaffold::Actions::BatchUpdate::NumericOptions.collect {|comp| [as_(comp.downcase.to_sym), comp]}
  html = select_tag("[record][#{column.name}][operator]",
        options_for_select(operator_options, current[:operator]),
        :id => "#{options[:id]}_operator",
        :class => "as_update_numeric_option")
  html << ' ' << text_field_tag("[record][#{column.name}][value]", current[:value], active_scaffold_input_text_options)
  html << ' ' << select_tag("[record][#{column.name}][opt]",
        options_for_select(select_options, current[:opt]),
        :id => "#{options[:id]}_opt",
        :class => "as_update_numeric_option")
  html
end
active_scaffold_update_scope_select(select_options = active_scaffold_update_scope_select_options) click to toggle source
# File lib/active_scaffold/helpers/update_column_helpers.rb, line 61
def active_scaffold_update_scope_select(select_options = active_scaffold_update_scope_select_options)
  if select_options.length > 1
    select_tag("batch_scope",
               options_for_select(select_options, batch_scope || select_options.last[1]),
               :class => "text_input")
  else
    hidden_field_tag("batch_scope", select_options.first[1]) unless select_options.empty?
  end
end
active_scaffold_update_scope_select_options() click to toggle source
# File lib/active_scaffold/helpers/update_column_helpers.rb, line 71
def active_scaffold_update_scope_select_options
  select_options = []
  select_options << [as_(:listed), 'LISTED'] if active_scaffold_config.batch_update.list_mode_enabled
  select_options << [as_(:marked), 'MARKED'] if active_scaffold_config.actions.include?(:mark)
  select_options
end
override_update(update_ui) click to toggle source

the naming convention for overriding search input types with helpers

# File lib/active_scaffold/helpers/update_column_helpers.rb, line 88
def override_update(update_ui)
  method = "active_scaffold_update_#{update_ui}"
  method if respond_to? method
end
override_update_field(column) click to toggle source

the naming convention for overriding form fields with helpers

# File lib/active_scaffold/helpers/update_column_helpers.rb, line 83
def override_update_field(column)
  override_helper column, 'update_column'
end