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 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.
11 12 13 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 11 def container @container end |
Instance Method Details
#action(action) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 46 def action(action, **) tag.li do (t("views.katalyst.content.editor.#{action}"), name: "commit", value: action, form: container_form_id, **) end end |
#actions ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 37 def actions tag. do concat action(:discard, class: "button button--text") concat action(:revert, class: "button button--text") if container.state == :draft concat action(:save, class: "button button--secondary") concat action(:publish, class: "button button--primary") end end |
#call ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 13 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
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/katalyst/content/editor/status_bar_component.rb', line 23 def status(state, **) status_text = t("views.katalyst.content.editor.#{state}_html", **) = { class: "status-text", data: { state => "", turbo: false } } case state 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 |