Class: Katalyst::Navigation::Editor::StatusBarComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/katalyst/navigation/editor/status_bar_component.rb

Constant Summary collapse

ACTIONS =
"navigation:change@document->\#{STATUS_BAR_CONTROLLER}#change\nturbo:morph-element->\#{STATUS_BAR_CONTROLLER}#morph\n".gsub(/\s+/, " ").freeze

Constants inherited from BaseComponent

BaseComponent::ITEM_CONTROLLER, BaseComponent::LIST_CONTROLLER, BaseComponent::MENU_CONTROLLER, BaseComponent::NEW_ITEM_CONTROLLER, BaseComponent::STATUS_BAR_CONTROLLER

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#item, #menu

Instance Method Summary collapse

Methods inherited from BaseComponent

#initialize, #menu_form_id

Constructor Details

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

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



12
13
14
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 12

def container
  @container
end

Instance Method Details

#action(action) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 38

def action(action, **)
  tag.li do
    button_tag(t("views.katalyst.navigation.editor.#{action}"),
               name:  "commit",
               value: action,
               form:  menu_form_id,
               **)
  end
end

#actionsObject



29
30
31
32
33
34
35
36
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 29

def actions
  tag.menu do
    concat action(:discard, class: "button button--text")
    concat action(:revert, class: "button button--text") if menu.state == :draft
    concat action(:save, class: "button button--secondary")
    concat action(:publish, class: "button button--primary")
  end
end

#callObject



14
15
16
17
18
19
20
21
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 14

def call
  tag.div(**html_attributes) do
    concat status(:published, last_update: l(menu.updated_at, format: :short))
    concat status(:draft)
    concat status(:dirty)
    concat actions
  end
end

#status(state) ⇒ Object



23
24
25
26
27
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 23

def status(state, **)
  tag.span(t("views.katalyst.navigation.editor.#{state}_html", **),
           class: "status-text",
           data:  { state => "" })
end