Skip to content

Commit

Permalink
Allow the action's path helper to be provided as an action option
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Nov 13, 2014
1 parent 486e00f commit bb6a084
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/helpers/blacklight/catalog_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,8 @@ def render_marc_tools
def action_label action, opts
t("blacklight.tools.#{action}", default: opts[:label] || action.to_s.humanize)
end

def action_path name, action_opts, url_opts = nil
self.send(action_opts[:path] ||"#{name}_#{controller_name}_path", url_opts)
end
end
2 changes: 1 addition & 1 deletion app/views/bookmarks/_tools.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ul class="<%= controller_name %>Tools nav nav-pills">
<% document_actions.each do |name, opts| %>
<li class="<%= name %>">
<%= link_to action_label(name, opts), self.send("#{name}_#{controller_name}_path"), {:id => "#{name}Link", :name => name, :class => 'btn btn-default', :data => {:ajax_modal => "trigger"}} %>
<%= link_to action_label(name, opts), action_path(name, opts), {:id => "#{name}Link", :name => name, :class => 'btn btn-default', :data => {:ajax_modal => "trigger"}} %>
</li>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_show_tools.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<% end %>
<% document_actions.each do |name, opts| %>
<li class="#{name}">
<%= link_to action_label(name, opts), self.send("#{name}_#{controller_name}_path", :id => @document), {:id => "#{name}Link", :data => {:ajax_modal => "trigger"}} %>
<%= link_to action_label(name, opts), action_path(name, opts, id: @document), {:id => "#{name}Link", :data => {:ajax_modal => "trigger"}} %>
</li>
<% end %>
Expand Down

0 comments on commit bb6a084

Please sign in to comment.