Sha256: 9a7a6fde612a27525d8058e0fed23458aeabb30dbb25e5c79bc3c8385d590f0c

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module Katalyst
  module Content
    module Editor
      class BaseComponent < ViewComponent::Base
        include Katalyst::HtmlAttributes

        CONTAINER_CONTROLLER  = "content--editor--container"
        LIST_CONTROLLER       = "content--editor--list"
        ITEM_CONTROLLER       = "content--editor--item"
        STATUS_BAR_CONTROLLER = "content--editor--status-bar"
        NEW_ITEM_CONTROLLER   = "content--editor--new-item"

        attr_accessor :container, :item

        delegate :config, to: ::Katalyst::Content

        def initialize(container:, item: nil, **)
          super(**)

          @container = container
          @item = item
        end

        def call; end

        def container_form_id
          dom_id(container, :items)
        end

        def attributes_scope
          "#{container.model_name.param_key}[items_attributes][]"
        end

        def inspect
          if item.present?
            "<#{self.class.name} container: #{container.inspect}, item: #{item.inspect}>"
          else
            "<#{self.class.name} container: #{container.inspect}>"
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
katalyst-content-2.7.0 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.6.2 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.6.1 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.6.0 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.5.1 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.5.0 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.4.2 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.4.1 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.3.2 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.3.1 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.3.0 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.2.0 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.1.4 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.1.3 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.1.2 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.1.1 app/components/katalyst/content/editor/base_component.rb
katalyst-content-2.1.0 app/components/katalyst/content/editor/base_component.rb