Sha256: d2ab4fa8774aa5cf8aba8bcea8b08335e8df383a1fa3efe7698159c20d40212a

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

module Plutonium
  module UI
    module Display
      module Component
        class AssociationField < Phlexi::Display::Components::Association
          include Plutonium::UI::Component::Methods

          def render_value(value)
            p(**attributes) {
              if registered_resources.include?(value.class)
                href = resource_url_for(value, parent: (field.association_reflection.macro == :has_many) ? field.object : nil)
                a(class: themed(:link), href:) {
                  display_name_of value
                }
              else
                display_name_of value
              end
            }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plutonium-0.15.23 lib/plutonium/ui/display/component/association_field.rb