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



15
16
17
18
19
20
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 15

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

#default_html_attributesObject



42
43
44
45
46
47
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 42

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

#idObject



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

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

#pathObject



34
35
36
37
38
39
40
# File 'app/components/katalyst/content/editor/item_editor_component.rb', line 34

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

#titleObject



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

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