Class: Katalyst::Content::Editor::StatusBarComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- Katalyst::Content::Editor::StatusBarComponent
- Defined in:
- app/components/katalyst/content/editor/status_bar_component.rb
Constant Summary collapse
- ACTIONS =
<<~ACTIONS.gsub(/\s+/, " ").freeze content:change@document->#{STATUS_BAR_CONTROLLER}#change turbo:morph-element->#{STATUS_BAR_CONTROLLER}#morph ACTIONS
Constants inherited from BaseComponent
BaseComponent::CONTAINER_CONTROLLER, BaseComponent::ITEM_CONTROLLER, BaseComponent::LIST_CONTROLLER, BaseComponent::NEW_ITEM_CONTROLLER, BaseComponent::STATUS_BAR_CONTROLLER
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
Attributes inherited from BaseComponent
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
#container ⇒ Object (readonly)
Returns the value of attribute container.
12 13 14 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 12 def container @container end |
Instance Method Details
#action(action) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 47 def action(action, **) tag.li do (t("views.katalyst.content.editor.#{action}"), name: "commit", value: action, form: container_form_id, **) end end |
#actions ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 38 def actions tag. do concat action(:discard, class: "button button--text") concat action(:revert, class: "button button--text") if container.draft? concat action(:save, class: "button button--secondary") concat action(:publish, class: "button button--primary") end end |
#call ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 14 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
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 24 def status(state, **) status_text = t("views.katalyst.content.editor.#{state}_html", **) = { class: "status-text", data: { state => "", turbo: false } } case state.to_sym when :published link_to status_text, url_for(container), ** when :unpublished, :draft link_to status_text, "#{url_for(container)}/preview", ** else tag.span status_text, ** end end |