Sha256: 963fc2ee7b74c7fe3c63569164d8ea8a7bfd4519c37eb6b490b920f5787d399f

Contents?: true

Size: 1.13 KB

Versions: 24

Compression:

Stored size: 1.13 KB

Contents

module Admin::Resources::DataTypes::BooleanHelper

  def display_boolean(item, attribute)
    data = item.send(attribute)
    boolean_assoc = item.class.typus_boolean(attribute)
    (data ? boolean_assoc.rassoc("true") : boolean_assoc.rassoc("false")).first
  end

  def table_boolean_field(attribute, item)
    status = item.send(attribute)
    boolean_assoc = item.class.typus_boolean(attribute)
    human_boolean = (status ? boolean_assoc.rassoc("true") : boolean_assoc.rassoc("false")).first

    options = { :controller => "/admin/#{item.class.to_resource}",
                :action => "toggle",
                :id => item.id,
                :field => attribute.gsub(/\?$/, '') }
    confirm = Typus::I18n.t("Change %{attribute}?", :attribute => item.class.human_attribute_name(attribute).downcase)
    link_to Typus::I18n.t(human_boolean), options, :confirm => confirm
  end

  def boolean_filter(filter)
    values  = @resource.typus_boolean(filter)
    items = [[Typus::I18n.t("Show by %{attribute}", :attribute => @resource.human_attribute_name(filter).downcase), ""]]
    items += values.map { |k, v| [Typus::I18n.t(k.humanize), v] }
  end

end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
typus-3.1.10 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.9 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.8 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.7 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.6 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.5 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.4 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.3 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.2 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.1 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc19 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc18 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc17 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc16 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc15 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc14 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc13 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc12 app/helpers/admin/resources/data_types/boolean_helper.rb
typus-3.1.0.rc11 app/helpers/admin/resources/data_types/boolean_helper.rb