Allow controller to override page name for breadcrumbs.
authorTom Clegg <tom@curoverse.com>
Sat, 1 Feb 2014 23:16:52 +0000 (15:16 -0800)
committerTom Clegg <tom@curoverse.com>
Sat, 1 Feb 2014 23:29:49 +0000 (15:29 -0800)
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/pipeline_instances_controller.rb
apps/workbench/app/models/link.rb
apps/workbench/app/views/application/_breadcrumb_page_name.html.erb [new file with mode: 0644]
apps/workbench/app/views/application/_breadcrumbs.html.erb
apps/workbench/app/views/links/_breadcrumb_page_name.html.erb [new file with mode: 0644]

index 201c063235ea2026d242f0a754c9ffb4d1c7b3e6..8d23c71a739f6c62c1ac02ce5ea1aec0ca415488 100644 (file)
@@ -129,6 +129,11 @@ class ApplicationController < ActionController::Base
     controller_name.classify.constantize
   end
 
+  def breadcrumb_page_name
+    (@breadcrumb_page_name ||
+     (@object.friendly_link_name if @object.respond_to? :friendly_link_name))
+  end
+
   protected
     
   def find_object_by_uuid
index 99a4ddddddbeb87e9f0cdaafea0642fc9a57c33d..507131f8ebcf63c319a861532494554351887b80 100644 (file)
@@ -4,6 +4,8 @@ class PipelineInstancesController < ApplicationController
   include PipelineInstancesHelper
 
   def compare
+    @breadcrumb_page_name = 'compare'
+
     @rows = []          # each is {name: S, components: [...]}
 
     # Build a table: x=pipeline y=component
index 07de4478700af803f4b54fb2be029e7e6c96aae3..899a80022ced45b28ce618f2fc847f268550750a 100644 (file)
@@ -4,8 +4,4 @@ class Link < ArvadosBase
   def self.by_tail(t, opts={})
     where(opts.merge :tail_kind => t.kind, :tail_uuid => t.uuid)
   end
-
-  def friendly_link_name
-    "(#{link_class}) #{tail_kind.sub 'arvados#', ' '} #{name} #{head_kind.sub 'arvados#', ' '}"
-  end
 end
diff --git a/apps/workbench/app/views/application/_breadcrumb_page_name.html.erb b/apps/workbench/app/views/application/_breadcrumb_page_name.html.erb
new file mode 100644 (file)
index 0000000..67387fd
--- /dev/null
@@ -0,0 +1 @@
+<%= controller.breadcrumb_page_name %>
index fe1c12a01abc11ad6acb623280da4887a5161bfd..26709ad9b8fcb7bfd65eedf1971ec10aca9feb0a 100644 (file)
@@ -13,7 +13,8 @@
             url_for({controller: params[:controller]})) %>
       <span class="divider">/</span>
     </li>
-    <li class="active"><%= @object.andand.friendly_link_name %>
+    <li class="active">
+      <%= render partial: 'breadcrumb_page_name' %>
     </li>
   <% end %>
 </ul>
diff --git a/apps/workbench/app/views/links/_breadcrumb_page_name.html.erb b/apps/workbench/app/views/links/_breadcrumb_page_name.html.erb
new file mode 100644 (file)
index 0000000..00acb84
--- /dev/null
@@ -0,0 +1,8 @@
+<% if @object %>
+(<%= @object.link_class %>)
+<%= @object.name %>:
+<%= @object.tail_kind.sub 'arvados#', ' ' %>
+&rarr;
+<%= @object.head_kind.sub 'arvados#', ' ' %>
+<% end %>
+