From 4e92e5890ae7b44545052db029863e886a36cc79 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sat, 1 Feb 2014 15:16:52 -0800 Subject: [PATCH] Allow controller to override page name for breadcrumbs. --- apps/workbench/app/controllers/application_controller.rb | 5 +++++ .../app/controllers/pipeline_instances_controller.rb | 2 ++ apps/workbench/app/models/link.rb | 4 ---- .../app/views/application/_breadcrumb_page_name.html.erb | 1 + .../workbench/app/views/application/_breadcrumbs.html.erb | 3 ++- .../app/views/links/_breadcrumb_page_name.html.erb | 8 ++++++++ 6 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 apps/workbench/app/views/application/_breadcrumb_page_name.html.erb create mode 100644 apps/workbench/app/views/links/_breadcrumb_page_name.html.erb diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 201c063235..8d23c71a73 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -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 diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb index 99a4dddddd..507131f8eb 100644 --- a/apps/workbench/app/controllers/pipeline_instances_controller.rb +++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb @@ -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 diff --git a/apps/workbench/app/models/link.rb b/apps/workbench/app/models/link.rb index 07de447870..899a80022c 100644 --- a/apps/workbench/app/models/link.rb +++ b/apps/workbench/app/models/link.rb @@ -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 index 0000000000..67387fdf30 --- /dev/null +++ b/apps/workbench/app/views/application/_breadcrumb_page_name.html.erb @@ -0,0 +1 @@ +<%= controller.breadcrumb_page_name %> diff --git a/apps/workbench/app/views/application/_breadcrumbs.html.erb b/apps/workbench/app/views/application/_breadcrumbs.html.erb index fe1c12a01a..26709ad9b8 100644 --- a/apps/workbench/app/views/application/_breadcrumbs.html.erb +++ b/apps/workbench/app/views/application/_breadcrumbs.html.erb @@ -13,7 +13,8 @@ url_for({controller: params[:controller]})) %> / -
  • <%= @object.andand.friendly_link_name %> +
  • + <%= render partial: 'breadcrumb_page_name' %>
  • <% end %> 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 index 0000000000..00acb846e4 --- /dev/null +++ b/apps/workbench/app/views/links/_breadcrumb_page_name.html.erb @@ -0,0 +1,8 @@ +<% if @object %> +(<%= @object.link_class %>) +<%= @object.name %>: +<%= @object.tail_kind.sub 'arvados#', ' ' %> +→ +<%= @object.head_kind.sub 'arvados#', ' ' %> +<% end %> + -- 2.39.5