Class: Katalyst::Content::Editor::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
HtmlAttributes
Defined in:
app/components/katalyst/content/editor/base_component.rb

Constant Summary collapse

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"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container:, item: nil) ⇒ BaseComponent

Returns a new instance of BaseComponent.



19
20
21
22
23
24
# File 'app/components/katalyst/content/editor/base_component.rb', line 19

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

  @container = container
  @item = item
end

Instance Attribute Details

#containerObject

Returns the value of attribute container.



15
16
17
# File 'app/components/katalyst/content/editor/base_component.rb', line 15

def container
  @container
end

#itemObject

Returns the value of attribute item.



15
16
17
# File 'app/components/katalyst/content/editor/base_component.rb', line 15

def item
  @item
end

Instance Method Details

#attributes_scopeObject



32
33
34
# File 'app/components/katalyst/content/editor/base_component.rb', line 32

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

#callObject



26
# File 'app/components/katalyst/content/editor/base_component.rb', line 26

def call; end

#container_form_idObject



28
29
30
# File 'app/components/katalyst/content/editor/base_component.rb', line 28

def container_form_id
  dom_id(container, :items)
end

#inspectObject



36
37
38
39
40
41
42
# File 'app/components/katalyst/content/editor/base_component.rb', line 36

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