Module: Blacklight::ComponentHelperBehavior
- Included in:
- ComponentHelper
- Defined in:
- app/helpers/blacklight/component_helper_behavior.rb
Instance Method Summary collapse
- #document_action_label(action, opts) ⇒ Object
- #document_action_path(action_opts, url_opts = nil) ⇒ Object
- #render_filtered_partials(partials, options = {}, &block) ⇒ 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, options = {}, &block) ⇒ String
Render “document actions” for the item detail 'show' view.
- #show_doc_actions?(document = @document, options = {}) ⇒ Boolean
Instance Method Details
#document_action_label(action, opts) ⇒ Object
4 5 6 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 4 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 = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 8 def document_action_path action_opts, url_opts = nil if action_opts.path self.send(action_opts.path, url_opts) elsif url_opts[:id].class.respond_to?(:model_name) url_for([action_opts.key, url_opts[:id]]) else self.send("#{action_opts.key}_#{controller_name}_path", url_opts) end end |
#render_filtered_partials(partials, options = {}, &block) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 57 def render_filtered_partials(partials, ={}, &block) content = [] filter_partials(partials, ).each do |key, config| config.key ||= key rendered = render(partial: config.partial || key.to_s, locals: { document_action_config: config }.merge()) if block_given? yield config, rendered else content << rendered end end safe_join(content, "\n") unless block_given? 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)
38 39 40 41 42 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 38 def render_index_doc_actions(document, ={}) wrapping_class = .delete(:wrapping_class) || "index-document-functions" rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge()) content_tag("div", rendered, class: wrapping_class) unless rendered.blank? 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
26 27 28 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 26 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)
51 52 53 54 55 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 51 def render_results_collection_tools( = {}) wrapping_class = .delete(:wrapping_class) || "search-widgets" rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).collection_actions, ) content_tag("div", rendered, class: wrapping_class) unless rendered.blank? end |
#render_show_doc_actions(document = @document, options = {}, &block) ⇒ String
Render “document actions” for the item detail 'show' view. (this normally renders next to title)
By default includes 'Bookmarks'
80 81 82 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 80 def render_show_doc_actions(document=@document, ={}, &block) render_filtered_partials(blacklight_config.show.document_actions, { document: document }.merge(), &block) end |
#show_doc_actions?(document = @document, options = {}) ⇒ Boolean
84 85 86 |
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 84 def show_doc_actions?(document = @document, = {}) filter_partials(blacklight_config.show.document_actions, { document: document }.merge()).any? end |