Class: Katalyst::Content::Editor::StatusBarComponent

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

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#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 Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



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

def container
  @container
end

Instance Method Details

#action(action) ⇒ Object



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

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

#actionsObject



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

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

#callObject



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

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

#status(state) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 19

def status(state, **)
  status_text  = t("views.katalyst.content.editor.#{state}_html", **)
  html_options = { class: "status-text", data: { state => "", turbo: false } }

  case state.to_sym
  when :published
    link_to status_text, url_for(container), **html_options
  when :unpublished, :draft
    link_to status_text, "#{url_for(container)}/preview", **html_options
  else
    tag.span status_text, **html_options
  end
end