Module: ActiveScaffold::Helpers::ShowColumnHelpers

Included in:
ViewHelpers
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb

Overview

Helpers that assist with the rendering of a List Column

Instance Method Summary collapse

Instance Method Details

#active_scaffold_show_text(column, record) ⇒ Object



24
25
26
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 24

def active_scaffold_show_text(column, record)
  simple_format(clean_column_value(record.send(column.name)))
end

#override_show_column_ui(list_ui) ⇒ Object

the naming convention for overriding show types with helpers



41
42
43
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 41

def override_show_column_ui(list_ui)
  "active_scaffold_show_#{list_ui}"
end

#override_show_column_ui?(list_ui) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 36

def override_show_column_ui?(list_ui)
  respond_to?(override_show_column_ui(list_ui))
end

#show_column_override(column) ⇒ Object



28
29
30
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 28

def show_column_override(column)
  "#{column.name.to_s.gsub('?', '')}_show_column" # parse out any question marks (see issue 227)
end

#show_column_override?(column) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 32

def show_column_override?(column)
  respond_to?(show_column_override(column))
end

#show_column_value(record, column) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb', line 5

def show_column_value(record, column)
  # check for an override helper
  if 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(show_column_override(column), record)
  # second, check if the dev has specified a valid list_ui for this column
  elsif column.list_ui and override_show_column_ui?(column.list_ui)
    send(override_show_column_ui(column.list_ui), column, record)
  else
    if column.column and override_show_column_ui?(column.column.type)
      send(override_show_column_ui(column.column.type), column, record)
    else
      get_column_value(record, column)
    end
  end
end