Module: Blacklight::ComponentHelperBehavior

Extended by:
Deprecation
Included in:
CatalogHelperBehavior
Defined in:
app/helpers/blacklight/component_helper_behavior.rb

Instance Method Summary collapse

Instance Method Details

#document_action_label(action, opts) ⇒ Object

Deprecated.


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

Deprecated.


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(options)).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)

Parameters:

Options Hash (options):

  • :wrapping_class (String)

Returns:

  • (String)


44
45
46
47
48
49
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 44

def render_index_doc_actions(document, options = {})
  actions = filter_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options)).map { |_k, v| v }
  wrapping_class = options.delete(:wrapping_class) || "index-document-functions"

  render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: 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

Parameters:

  • options (Hash) (defaults to: {})

Returns:

  • (String)


32
33
34
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 32

def render_nav_actions(options = {}, &block)
  render_filtered_partials(blacklight_config.navbar.partials, options, &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)

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :wrapping_class (String)

Returns:

  • (String)


58
59
60
61
62
63
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 58

def render_results_collection_tools(options = {})
  actions = filter_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options).map { |_k, v| v }
  wrapping_class = options.delete(:wrapping_class) || "search-widgets"

  render(Blacklight::Document::ActionsComponent.new(actions: actions, options: 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'

Parameters:

  • document (SolrDocument) (defaults to: @document)
  • options (Hash)

Returns:

  • (String)


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: {}, **options)
  document = options[:document] if options.key? :document

  actions = document_actions(document, options: 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: options, url_opts: url_opts))
    end

    nil
  else
    render(Blacklight::Document::ActionsComponent.new(document: document, actions: actions, options: options, url_opts: url_opts))
  end
end

#render_show_doc_actions_method_from_blacklight?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


96
97
98
# File 'app/helpers/blacklight/component_helper_behavior.rb', line 96

def show_doc_actions?(document = @document, options = {})
  filter_partials(blacklight_config.view_config(:show).document_actions, { document: document }.merge(options)).any?
end