Class: Katalyst::Content::EditorComponent

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

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.



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

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.



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

def scope
  @scope
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#default_html_attributesObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/components/katalyst/content/editor_component.rb', line 37

def default_html_attributes
  {
    id:    container_form_id,
    class: "content--editor",
    data:  {
      controller: "content--editor--container",
      action:     %w[
        submit->content--editor--container#reindex
        content:drop->content--editor--container#drop
        content:reindex->content--editor--container#reindex
        turbo:render@document->content--editor--container#connect
        content:reset->content--editor--container#reset
      ],
    },
  }
end

#errorsObject



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

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

#item(item:) ⇒ Object



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

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

#item_editor(item:) ⇒ Object



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

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

#status_barObject



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

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