Sha256: 3abc6f7b0913468708abfde5d84b3b5c93807c03dba7c6b821e8beb50bbd6ab5

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module Selectable
      class FormComponent < ViewComponent::Base # :nodoc:
        include Katalyst::Tables::Identifiable::Defaults

        attr_reader :id, :primary_key

        # @param collection [Katalyst::Tables::Collection::Core] the collection to render
        # @param id [String] the id of the form element (defaults to <resources>_selection_form)
        # @param primary_key [String] the primary key of the record in the collection (defaults to :id)
        def initialize(collection:,
                       id: nil,
                       primary_key: :id)
          super

          @collection  = collection
          @id          = id || Selectable.default_form_id(collection)
          @primary_key = primary_key
        end

        def inspect
          "#<#{self.class.name} id: #{id.inspect}, primary_key: #{primary_key.inspect}>"
        end

        private

        def form_controller
          FORM_CONTROLLER
        end

        def form_target(value)
          "#{FORM_CONTROLLER}-target=#{value}"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katalyst-tables-3.3.4 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.3.3 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.3.2 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.3.1 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.3.0 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.2.0 app/components/katalyst/tables/selectable/form_component.rb
katalyst-tables-3.1.0 app/components/katalyst/tables/selectable/form_component.rb