Sha256: 2b9e4712e52413ce645a217005a45aca7c302ac14108b81137941949cf4f1c17

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

module Admin::Resources::DataTypes::StringHelper

  def display_string(item, attribute)
    item.send(attribute)
  end

  alias_method :display_decimal, :display_string
  alias_method :display_float, :display_string
  alias_method :display_integer, :display_string
  alias_method :display_position, :display_string
  alias_method :display_text, :display_string

  def string_filter(filter)
    values = set_context.send(filter.to_s).to_a

    items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
    array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
    items += array
  end

  def table_string_field(attribute, item)
    (raw_content = item.send(attribute)).present? ? raw_content : "—".html_safe
  end

  alias_method :table_decimal_field, :table_string_field
  alias_method :table_float_field, :table_string_field
  alias_method :table_integer_field, :table_string_field
  alias_method :table_virtual_field, :table_string_field
  alias_method :table_password_field, :table_string_field

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-3.1.0.rc17 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc16 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc15 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc14 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc13 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc12 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc11 app/helpers/admin/resources/data_types/string_helper.rb
typus-3.1.0.rc10 app/helpers/admin/resources/data_types/string_helper.rb