Class: Katalyst::Content::Editor::NewItemComponent

Inherits:
BaseComponent
  • Object
show all
Includes:
Turbo::StreamsHelper
Defined in:
app/components/katalyst/content/editor/new_item_component.rb

Constant Summary collapse

ACTIONS =
<<~ACTIONS.gsub(/\s+/, " ").freeze
  dragstart->#{NEW_ITEM_CONTROLLER}#dragstart
ACTIONS

Constants inherited from BaseComponent

BaseComponent::CONTAINER_CONTROLLER, BaseComponent::ITEM_CONTROLLER, BaseComponent::LIST_CONTROLLER, BaseComponent::NEW_ITEM_CONTROLLER, BaseComponent::STATUS_BAR_CONTROLLER

Instance Attribute Summary

Attributes inherited from BaseComponent

#container, #item

Instance Method Summary collapse

Methods inherited from BaseComponent

#attributes_scope, #call, #container_form_id, #inspect

Constructor Details

#initialize(item:, container: item.container) ⇒ NewItemComponent

Returns a new instance of NewItemComponent.



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

def initialize(item:, container: item.container)
  super(item:, container:)
end

Instance Method Details

#item_componentObject



19
20
21
# File 'app/components/katalyst/content/editor/new_item_component.rb', line 19

def item_component(**)
  ItemComponent.new(item:, container:, **)
end

#item_typeObject



31
32
33
# File 'app/components/katalyst/content/editor/new_item_component.rb', line 31

def item_type
  item.model_name.param_key
end

#labelObject



27
28
29
# File 'app/components/katalyst/content/editor/new_item_component.rb', line 27

def label
  t("katalyst.content.editor.new_item.#{item_type}", default: item.model_name.human)
end

#row_componentObject



23
24
25
# File 'app/components/katalyst/content/editor/new_item_component.rb', line 23

def row_component(**)
  RowComponent.new(item:, container:, **)
end