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

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

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.



7
8
9
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 7

def container
  @container
end

Instance Method Details

#action(action) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 33

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



24
25
26
27
28
29
30
31
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 24

def actions
  tag.menu do
    concat action(:discard, class: "button", data: { text_button: "" })
    concat action(:revert, class: "button", data: { text_button: "" }) if menu.state == :draft
    concat action(:save, class: "button", data: { ghost_button: "" })
    concat action(:publish, class: "button")
  end
end

#callObject



9
10
11
12
13
14
15
16
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 9

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



18
19
20
21
22
# File 'app/components/katalyst/navigation/editor/status_bar_component.rb', line 18

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