Class: Katalyst::Content::EditorComponent

Inherits:
Katalyst::Content::Editor::BaseComponent show all
Defined in:
app/components/katalyst/content/editor_component.rb

Constant Summary collapse

ACTIONS =
"submit->\#{CONTAINER_CONTROLLER}#reindex\ncontent:drop->\#{CONTAINER_CONTROLLER}#drop\ncontent:reindex->\#{CONTAINER_CONTROLLER}#reindex\ncontent:reset->\#{CONTAINER_CONTROLLER}#reset\n".gsub(/\s+/, " ").freeze

Constants inherited from Katalyst::Content::Editor::BaseComponent

Katalyst::Content::Editor::BaseComponent::CONTAINER_CONTROLLER, Katalyst::Content::Editor::BaseComponent::ITEM_CONTROLLER, Katalyst::Content::Editor::BaseComponent::LIST_CONTROLLER, Katalyst::Content::Editor::BaseComponent::NEW_ITEM_CONTROLLER, Katalyst::Content::Editor::BaseComponent::STATUS_BAR_CONTROLLER

Instance Attribute Summary collapse

Attributes inherited from Katalyst::Content::Editor::BaseComponent

#container

Instance Method Summary collapse

Methods inherited from Katalyst::Content::Editor::BaseComponent

#attributes_scope, #call, #container_form_id, #inspect

Constructor Details

#initialize(container:, url: [:admin, container], scope: :container) ⇒ EditorComponent

Returns a new instance of EditorComponent.



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

def initialize(container:, url: [:admin, container], scope: :container, **)
  super(container:, **)

  @url   = url
  @scope = scope
end

Instance Attribute Details

#scopeObject (readonly)

Returns the value of attribute scope.



13
14
15
# File 'app/components/katalyst/content/editor_component.rb', line 13

def scope
  @scope
end

#urlObject (readonly)

Returns the value of attribute url.



13
14
15
# File 'app/components/katalyst/content/editor_component.rb', line 13

def url
  @url
end

Instance Method Details

#default_html_attributesObject



42
43
44
45
46
47
48
49
50
# File 'app/components/katalyst/content/editor_component.rb', line 42

def default_html_attributes
  {
    id:   container_form_id,
    data: {
      controller: CONTAINER_CONTROLLER,
      action:     ACTIONS,
    },
  }
end

#errorsObject



38
39
40
# File 'app/components/katalyst/content/editor_component.rb', line 38

def errors
  Katalyst::Content.config.errors_component.constantize.new(container:)
end

#item(item:) ⇒ Object



34
35
36
# File 'app/components/katalyst/content/editor_component.rb', line 34

def item(item:)
  Editor::ItemComponent.new(container:, item:)
end

#item_editor(item:) ⇒ Object



30
31
32
# File 'app/components/katalyst/content/editor_component.rb', line 30

def item_editor(item:)
  Editor::ItemEditorComponent.new(container:, item:)
end

#new_itemsObject



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

def new_items
  Editor::NewItemsComponent.new(container:)
end

#status_barObject



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

def status_bar
  Editor::StatusBarComponent.new(container:)
end