Sha256: 69475868dca736226b9464ca3762585e86c09fb6614fba02a7d1f462c9ff23ac

Contents?: true

Size: 1.39 KB

Versions: 66

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 :theming.
      #
      # @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

66 entries across 66 versions & 1 rubygems

Version Path
pageflow-15.8.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-14.5.2 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.7.1 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.7.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.6.1 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.6.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.5.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.4.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.3.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.2.2 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.2.1 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.2.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.2 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.1 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0.rc0 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0.beta6 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0.beta5 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0.beta4 lib/pageflow/admin/attributes_table_rows.rb
pageflow-15.1.0.beta3 lib/pageflow/admin/attributes_table_rows.rb