Add breadcrumbs bar to #index and #show pages.
authorTom Clegg <tom@curoverse.com>
Fri, 31 Jan 2014 21:59:33 +0000 (13:59 -0800)
committerTom Clegg <tom@curoverse.com>
Sat, 1 Feb 2014 23:29:49 +0000 (15:29 -0800)
16 files changed:
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/models/arvados_base.rb
apps/workbench/app/models/link.rb
apps/workbench/app/models/node.rb
apps/workbench/app/models/virtual_machine.rb
apps/workbench/app/views/application/_arvados_attr_value.html.erb
apps/workbench/app/views/application/_arvados_object.html.erb
apps/workbench/app/views/application/_breadcrumbs.html.erb [new file with mode: 0644]
apps/workbench/app/views/application/_index.html.erb
apps/workbench/app/views/application/show.html.erb
apps/workbench/app/views/jobs/index.html.erb
apps/workbench/app/views/jobs/show.html.erb [deleted file]
apps/workbench/app/views/layouts/application.html.erb
apps/workbench/app/views/user_agreements/index.html.erb
apps/workbench/app/views/users/_home.html.erb
apps/workbench/app/views/users/welcome.html.erb

index fe7012aa94b0c8218ab2675c7c5c19f29f732df5..a42016b8eca0cc4a70ead39b1dbc4ff07cf0bb23 100644 (file)
@@ -56,10 +56,7 @@ module ApplicationHelper
 
         if opts[:friendly_name]
           begin
-            friendly_name = resource_class.find(link_uuid).friendly_link_name
-            if friendly_name and not friendly_name.empty?
-              link_name = friendly_name
-            end
+            link_name = resource_class.find(link_uuid).friendly_link_name
           rescue RuntimeError
             # If that lookup failed, the link will too. So don't make one.
             return attrvalue
index 5c7e44f136b3417a8a4f9fa4db1a0d5bf1142b35..6b5ee81c0481506c67a75650e95e0d1d82b52e0b 100644 (file)
@@ -262,9 +262,7 @@ class ArvadosBase < ActiveRecord::Base
   end
 
   def friendly_link_name
-    if self.class.column_names.include? 'name'
-      self.name
-    end
+    (name if self.respond_to? :name) || uuid
   end
 
   protected
index 899a80022ced45b28ce618f2fc847f268550750a..07de4478700af803f4b54fb2be029e7e6c96aae3 100644 (file)
@@ -4,4 +4,8 @@ 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
index 0a324ff5139bb88d5fcd77a65c3b638616182bdd..6518047b8d161df66605bb5f34ad61132cd3bb8c 100644 (file)
@@ -3,6 +3,6 @@ class Node < ArvadosBase
     current_user and current_user.is_admin
   end
   def friendly_link_name
-    self.hostname
+    (hostname && !hostname.empty?) ? hostname : uuid
   end
 end
index 5f6131ebfaa9a30fa464581d0102555d4368dc38..5ff7798a959162eb27d27cf9c35fd41748bd35ac 100644 (file)
@@ -16,6 +16,6 @@ class VirtualMachine < ArvadosBase
             super]
   end
   def friendly_link_name
-    self.hostname
+    (hostname && !hostname.empty?) ? hostname : uuid
   end
 end
index e04fe45a630dc3ae44d19e6c25fb9816200bd393..cb60714ab986034b551f442cbbc02fdd7535ae25 100644 (file)
@@ -6,7 +6,8 @@
       <% if obj.attribute_editable?(attr) %>
         <%= render_editable_attribute obj, attr %>
         <% if resource_class_for_uuid(attrvalue, {referring_object: obj, referring_attr: attr}) %>
-       (<%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: true, friendly_name: true} %>)
+       <br />
+        (<%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: true, friendly_name: true} %>)
         <% end %>
       <% elsif attr == 'uuid' %>
         <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: obj, with_class_name: false, friendly_name: false} %>
index c41fa18fcf82924f1501e99be80e21d186bb4ae9..d04ca84439dd6f3216d9d72bab3797a6cc8d5df4 100644 (file)
@@ -1,5 +1,5 @@
 <% content_for :arvados_object_table do %>
-<h2><%= @object.class %> <%= @object.uuid %></h2>
+
 <%= form_for @object do |f| %>
 <table class="table topalign">
   <thead>
diff --git a/apps/workbench/app/views/application/_breadcrumbs.html.erb b/apps/workbench/app/views/application/_breadcrumbs.html.erb
new file mode 100644 (file)
index 0000000..fe1c12a
--- /dev/null
@@ -0,0 +1,19 @@
+<ul class="breadcrumb">
+  <li>
+    <%= link_to((Rails.configuration.site_name rescue Rails.application.class.parent_name), '/') %>
+    <span class="divider">/</span>
+  </li>
+  <% if params[:action] == 'index' %>
+    <li class="active">
+      <%= controller.model_class.to_s.pluralize.underscore.gsub '_', ' ' %>
+    </li>
+  <% else %>
+    <li><%= link_to(
+            controller.model_class.to_s.pluralize.underscore.gsub('_', ' '),
+            url_for({controller: params[:controller]})) %>
+      <span class="divider">/</span>
+    </li>
+    <li class="active"><%= @object.andand.friendly_link_name %>
+    </li>
+  <% end %>
+</ul>
index 4c1fdc320608bf15760ae61ff6c3b75eaba06c01..02a1aa1a36be143a0e1c4472977eb3b62fd6be96 100644 (file)
@@ -1,13 +1,9 @@
-
-<h2 class="pull-left"><%= controller.model_class.to_s.pluralize.underscore.capitalize.gsub '_', ' ' %></h2>
-<br/>
 <% if controller.model_class.creatable? %>
 <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", 
     { action: 'create', return_to: request.url }, 
     { class: 'btn btn-primary pull-right' } %>
 <% end %>
 
-
 <% if @objects.empty? %>
 <br/>
 <p style="text-align: center">
index ad7e53c1fe1d1c132113c02211a155e3bfbf3aca..e8a15f386c479f43ee94fa48e4e5548853517ab9 100644 (file)
@@ -1,7 +1,7 @@
 <% if @object.respond_to? :properties %>
 
 <% content_for :page_title do %>
-<%= @object.properties[:page_title] || @object.uuid %>
+<%= @object.properties[:page_title] || @object.friendly_link_name %>
 <% end %>
 
 <% if @object.properties[:page_content] %>
index 2188a3bcf63653b5e5dfe3bd9f726afb68dca033..99bb9dd2bbf357297f3de8977ef6184fd47b4302 100644 (file)
@@ -1,12 +1,10 @@
-<% content_for :head do %>
-<style>
+<% content_for :css do %>
   table.topalign>tbody>tr>td {
   vertical-align: top;
   }
   table.topalign>thead>tr>td {
   vertical-align: bottom;
   }
-</style>
 <% end %>
 
 <table class="topalign table">
diff --git a/apps/workbench/app/views/jobs/show.html.erb b/apps/workbench/app/views/jobs/show.html.erb
deleted file mode 100644 (file)
index 9079085..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<%= render :partial => 'application/arvados_object' %>
index 1def50ed437748c3cd9788b3bf9474ec88dbd9b5..3d2c6faec0190b18e12cb060114fbd68ad034be2 100644 (file)
 
   <div class="container">
 
+    <%= content_for?(:breadcrumbs) ? yield(:breadcrumbs) : render(partial: 'breadcrumbs') %>
     <%= yield %>
 
   </div> <!-- /container -->
index ed758af362ac79e0fc76574f6175638feb4171a2..acd5ba17cb740b7e3fd56940e2f122438ae43d46 100644 (file)
@@ -1,3 +1,5 @@
+<% content_for :breadcrumbs do '' end %>
+
 <% n_files = @required_user_agreements.collect(&:files).flatten(1).count %>
 <% content_for :page_title do %>
 <% if n_files == 1 %>
index 9ec9d80912228fd758ba136129436416ce5b8822..f59e65ef665d65f2555a1c5fc3024405e462ae0e 100644 (file)
@@ -1,3 +1,4 @@
+<% content_for :breadcrumbs do raw '<!-- -->' end %>
 <% content_for :css do %>
       .dash-list {
         padding: 9px 0;
index b78210830e53db94a1e2921b0811b3c12a2ea42f..4fe55180937c9f5caa763cac10d014642ddcfd94 100644 (file)
@@ -1,3 +1,5 @@
+<% content_for :breadcrumbs do raw '<!-- -->' end %>
+
 <%= image_tag "dax.png", style: "float: left; max-width: 25%; margin-right: 2em" %>
 <h1>Hi there!  Please log in to use <%= Rails.configuration.site_name %>.</h1>
 <div class="row-fluid">