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

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

#before_renderObject



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

def before_render
  helpers.extend(Helpers)
end

#callObject



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

def call
  render("form", model:, scope:, url:, id:)
end

#idObject



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

def id
  dom_id(item, :form)
end

#scopeObject



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

def scope
  :item
end

#titleObject



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

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

#urlObject



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

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