Sha256: 345938fa02c4b32353d56ea1b3642991d618ed55a11dbbd58e4e0b2338e6ad20

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 Bytes

Contents

module Admin::Resources::DisplayHelper

  def build_display(item, fields)
    fields.map do |attribute, type|
      value = if (type == :boolean) || (data = item.send(attribute)).present?
                send("display_#{type}", item, attribute)
              else
                "—".html_safe
              end

      [@resource.human_attribute_name(attribute), value]
    end
  end

  def typus_relationships
    String.new.tap do |html|
      @resource.typus_defaults_for(:relationships).each do |relationship|
        association = @resource.reflect_on_association(relationship.to_sym)
        next if association.macro == :belongs_to
        next if admin_user.cannot?('read', association.class_name.constantize)
        html << send("typus_form_#{association.macro}", relationship)
      end
    end.html_safe
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc17 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc16 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc15 app/helpers/admin/resources/display_helper.rb