Sha256: 01ecbdcb2e4067e9414ff6fa4d80be6e2d24a6c90369b3faf9c3dc29413a2ea2

Contents?: true

Size: 1.39 KB

Versions: 8

Compression:

Stored size: 1.39 KB

Contents

module Pageflow
  # A registry of additional rows to display in attribute tables on
  # admin pages.
  #
  # @since 12.2
  module Admin
    class AttributesTableRows
      # @api private
      def initialize
        @rows = {}
      end

      # Insert an additional row into an attribute table.
      #
      # @param resource_name [Symbol] Either :entry, :account or :site.
      #
      # @param name [Symbol] Name of the attribute to display.
      #
      # @param options [Hash] Supports same options as
      #   ActiveAdmin::Views::AttributesTable#row, in addition to:
      #
      # @option options [Symbol] :before Insert row before row with
      #   given name. Append to table if not found.
      #
      # @option options [Symbol] :after Insert row after row with
      #   given name. Append to table if not found.
      #
      # @yieldparam resource [ActiveRecord::Base] A block which is
      #   evaluated in the context of the Arbre template to render the
      #   contents of the cell.
      def register(resource_name, name, options = {}, &block)
        @rows[resource_name] ||= []
        @rows[resource_name] << {
          name: name,
          block: block,
          options: options.except(:before, :after),
          **options.slice(:before, :after)
        }
      end

      # @api private
      def for(resource_name)
        @rows.fetch(resource_name, [])
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/admin/attributes_table_rows.rb
pageflow-17.0.3 lib/pageflow/admin/attributes_table_rows.rb
pageflow-17.0.2 lib/pageflow/admin/attributes_table_rows.rb
pageflow-17.0.1 lib/pageflow/admin/attributes_table_rows.rb
pageflow-17.0.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-16.2.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-16.1.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-16.0.0 lib/pageflow/admin/attributes_table_rows.rb