Class: Blacklight::Document::ActionComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::Document::ActionComponent
- Defined in:
- app/components/blacklight/document/action_component.rb
Overview
Render a bookmark widget to bookmark / unbookmark a document
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
-
#initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link') ⇒ ActionComponent
constructor
A new instance of ActionComponent.
- #key ⇒ Object
- #label ⇒ Object
-
#url ⇒ Object
Action buttons get their URLs in one of three ways: - the action configuration explicitly specifies a helper method to call - a url route is inferred for ActiveModel-compliant objects (the default; note that, although Rails routing is available here, we still call out to helpers regardless, because that’s where applications might have overridden the default Rails routing behavior) - calling out to an implicit helper method with a conventional name (unlikely).
- #using_default_document_action? ⇒ Boolean
Methods inherited from Component
Constructor Details
#initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link') ⇒ ActionComponent
Returns a new instance of ActionComponent.
10 11 12 13 14 15 16 17 |
# File 'app/components/blacklight/document/action_component.rb', line 10 def initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link') @document = document @action = action @options = @url_opts = url_opts @id = id || @action.fetch(:id, "#{@action.name}Link") @link_classes = link_classes end |
Instance Method Details
#key ⇒ Object
45 46 47 |
# File 'app/components/blacklight/document/action_component.rb', line 45 def key @action.key end |
#label ⇒ Object
26 27 28 29 30 |
# File 'app/components/blacklight/document/action_component.rb', line 26 def label Deprecation.silence(Blacklight::ComponentHelperBehavior) do helpers.document_action_label(@action.name, @action) end end |
#url ⇒ Object
Action buttons get their URLs in one of three ways:
-
the action configuration explicitly specifies a helper method to call
-
a url route is inferred for ActiveModel-compliant objects (the default;
note that, although Rails routing is available here, we still call out to helpers regardless, because that's where applications might have overridden the default Rails routing behavior) -
calling out to an implicit helper method with a conventional name (unlikely)
39 40 41 42 43 |
# File 'app/components/blacklight/document/action_component.rb', line 39 def url Deprecation.silence(Blacklight::ComponentHelperBehavior) do helpers.document_action_path(@action, @url_opts.merge(({ id: @document } if @document) || {})) end end |
#using_default_document_action? ⇒ Boolean
19 20 21 22 23 24 |
# File 'app/components/blacklight/document/action_component.rb', line 19 def using_default_document_action? return true if @action.component return false unless @action.partial == 'document_action' helpers.partial_from_blacklight?(@action.partial) end |