Class: Katalyst::Content::Editor::ItemEditorComponent

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

Defined Under Namespace

Modules: Helpers

Constant Summary

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, #container_form_id, #initialize, #inspect

Constructor Details

This class inherits a constructor from Katalyst::Content::Editor::BaseComponent

Instance Method Details

#callObject



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

def call
  tag.div(**html_attributes) do
    helpers.extend(Helpers)
    helpers.render(item, path:)
  end
end

#default_html_attributesObject



46
47
48
49
50
51
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 46

def default_html_attributes
  {
    id:,
    class: "content--item-editor",
  }
end

#idObject



26
27
28
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 26

def id
  "item-editor-#{item.id}"
end

#pathObject



38
39
40
41
42
43
44
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 38

def path
  if item.persisted?
    view_context.katalyst_content.item_path(item)
  else
    view_context.katalyst_content.items_path
  end
end

#titleObject



30
31
32
33
34
35
36
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 30

def title
  if item.persisted?
    "Edit #{item.model_name.human.downcase}"
  else
    "New #{item.model_name.human.downcase}"
  end
end