Sha256: c8b4d9ea289c0a51d160de783dd7d638e42c5178d1c36c1214838b97a6e6dd88

Contents?: true

Size: 830 Bytes

Versions: 6

Compression:

Stored size: 830 Bytes

Contents

module Admin::Resources::DisplayHelper

  def build_display(item, fields)
    fields.map do |attribute, type|
      value = if (type == :boolean) || (data = item.send(attribute))
                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.typus_constantize)
        html << send("typus_form_#{association.macro}", relationship)
      end
    end.html_safe
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typus-3.1.0.rc12 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc11 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc10 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc9 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc8 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc7 app/helpers/admin/resources/display_helper.rb