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, options = {}) ⇒ 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(options = {}) ⇒ 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
100 101 102 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 100 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, options = {}) ⇒ String
Render “document actions” area for search results view (normally renders next to title in the list view)
44 45 46 47 48 49 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 44 def render_index_doc_actions(document, = {}) actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge()).map { |_k, v| v } wrapping_class = .delete(:wrapping_class) || "index-document-functions" render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: , 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(options = {}) ⇒ String
Render “collection actions” area for search results view (normally renders next to pagination at the top of the result set)
58 59 60 61 62 63 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 58 def render_results_collection_tools( = {}) actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, ).map { |_k, v| v } wrapping_class = .delete(:wrapping_class) || "search-widgets" render(Blacklight::Document::ActionsComponent.new(actions: actions, options: , 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'
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 74 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
92 93 94 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 92 def render_show_doc_actions_method_from_blacklight? method(:render_show_doc_actions).owner == Blacklight::ComponentHelperBehavior end |
#show_doc_actions?(document = @document, options = {}) ⇒ Boolean
96 97 98 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 96 def show_doc_actions?(document = @document, = {}) filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge()).any? end |