Module: Blacklight::ComponentHelperBehavior
- Extended by:
- Deprecation
- Included in:
- CatalogHelperBehavior
- Defined in:
- app/helpers/blacklight/component_helper_behavior.rb
Instance Method Summary collapse
- #document_action_label(action, opts) ⇒ Object deprecated Deprecated.
- #document_action_path(action_opts, url_opts = {}) ⇒ Object deprecated Deprecated.
- #document_actions(document, options: {}) ⇒ Object
-
#render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent) ⇒ String
Render “document actions” area for search results view (normally renders next to title in the list view).
-
#render_nav_actions(options = {}, &block) ⇒ String
Render “document actions” area for navigation header (normally renders “Saved Searches”, “History”, “Bookmarks”) These things are added by add_nav_action and the default config is provided by DefaultComponentConfiguration.
-
#render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent) ⇒ String
Render “collection actions” area for search results view (normally renders next to pagination at the top of the result set).
-
#render_show_doc_actions(document = @document, url_opts: {}, **options) ⇒ String
Render “document actions” for the item detail ‘show’ view.
- #render_show_doc_actions_method_from_blacklight? ⇒ Boolean
- #show_doc_actions?(document = @document, options = {}) ⇒ Boolean
Instance Method Details
#document_action_label(action, opts) ⇒ Object
7 8 9 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 7 def document_action_label action, opts t("blacklight.tools.#{action}", default: opts.label || action.to_s.humanize) end |
#document_action_path(action_opts, url_opts = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 13 def document_action_path action_opts, url_opts = {} if action_opts.path send(action_opts.path, url_opts) elsif url_opts[:id].class.respond_to?(:model_name) url_for([action_opts.key.to_sym, url_opts[:id]]) else send("#{action_opts.key}_#{controller_name}_path", url_opts) end end |
#document_actions(document, options: {}) ⇒ Object
98 99 100 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 98 def document_actions(document, options: {}) filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge()).map { |_k, v| v } end |
#render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent) ⇒ String
Render “document actions” area for search results view (normally renders next to title in the list view)
44 45 46 47 48 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 44 def render_index_doc_actions(document, wrapping_class: "index-document-functions", component: Blacklight::Document::ActionsComponent) actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }).map { |_k, v| v } render(component.new(document: document, actions: actions, classes: wrapping_class)) end |
#render_nav_actions(options = {}, &block) ⇒ String
Render “document actions” area for navigation header (normally renders “Saved Searches”, “History”, “Bookmarks”) These things are added by add_nav_action and the default config is provided by DefaultComponentConfiguration
32 33 34 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 32 def render_nav_actions( = {}, &block) render_filtered_partials(blacklight_config..partials, , &block) end |
#render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent) ⇒ String
Render “collection actions” area for search results view (normally renders next to pagination at the top of the result set)
57 58 59 60 61 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 57 def render_results_collection_tools(wrapping_class: "search-widgets", component: Blacklight::Document::ActionsComponent) actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, {}).map { |_k, v| v } render(component.new(actions: actions, classes: wrapping_class)) end |
#render_show_doc_actions(document = @document, url_opts: {}, **options) ⇒ String
Render “document actions” for the item detail ‘show’ view. (this normally renders next to title)
By default includes ‘Bookmarks’
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 72 def render_show_doc_actions(document = @document, url_opts: {}, **) document = [:document] if .key? :document actions = document_actions(document, options: ) if block_given? # TODO: Deprecate this behavior and replace it with a separate component? # Deprecation.warn(Blacklight::ComponentHelperBehavior, 'Pass a block to #render_show_doc_actions is deprecated') actions.each do |action| yield action, render((action.component || Blacklight::Document::ActionComponent).new(action: action, document: document, options: , url_opts: url_opts)) end nil else render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: , url_opts: url_opts)) end end |
#render_show_doc_actions_method_from_blacklight? ⇒ Boolean
90 91 92 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 90 def render_show_doc_actions_method_from_blacklight? method(:render_show_doc_actions).owner == Blacklight::ComponentHelperBehavior end |
#show_doc_actions?(document = @document, options = {}) ⇒ Boolean
94 95 96 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 94 def show_doc_actions?(document = @document, = {}) filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge()).any? end |