Class: Katalyst::Content::Editor::StatusBarComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Katalyst::Content::Editor::StatusBarComponent
show all
- Defined in:
- app/components/katalyst/content/editor/status_bar_component.rb
Instance Attribute Summary collapse
#item
Instance Method Summary
collapse
#attributes_scope, #container_form_id, #initialize, #inspect
Instance Attribute Details
#container ⇒ Object
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
|
#actions ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 33
def actions
tag. 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
|
#call ⇒ Object
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
|