3504: Fix collection chooser. Fix generic link render to use uuid if nothing
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 19 Aug 2014 13:40:07 +0000 (09:40 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 19 Aug 2014 13:40:07 +0000 (09:40 -0400)
else is available.  Fix tags for objects other than collections.

apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/controllers/projects_controller.rb
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/views/collections/_choose_rows.html.erb
apps/workbench/app/views/collections/_show_source_summary.html.erb
apps/workbench/app/views/collections/show.html.erb
apps/workbench/app/views/projects/_show_contents_rows.html.erb

index 4003faece87778dd9cdef746be5cd25c250a12ec..57c6bb5f4278f3719565557149df511e616ccef0 100644 (file)
@@ -45,6 +45,9 @@ class CollectionsController < ApplicationController
   def choose
     params[:limit] ||= 40
 
+    find_objects_for_index
+    @collections = @objects
+
     @filters += [['link_class','=','name'],
                  ['head_uuid','is_a','arvados#collection']]
 
@@ -55,7 +58,7 @@ class CollectionsController < ApplicationController
 
     @objects = Collection.
       filter([['uuid','in',@name_links.collect(&:head_uuid)]])
-    preload_links_for_objects @objects.to_a
+    preload_links_for_objects (@collections.to_a + @objects.to_a)
     super
   end
 
index a45c740a5d923e0790221ccd057bd880fe02dd20..ea9e5039c08be7da593d5a5be909e3681480b90b 100644 (file)
@@ -176,13 +176,13 @@ class ProjectsController < ApplicationController
                                   filters: @filters,
                                   offset: @offset)
       @next_page_href = next_page_href(partial: :contents_rows)
+    end
 
-      uuids = @objects.map { |ob| ob.uuid }
-      @object_tags = {}
-      Link.limit(uuids.length*20).filter([["head_uuid", "in", uuids], ["link_class", "=", "tag"]]).each do |t|
-        @object_tags[t.head_uuid] ||= []
-        @object_tags[t.head_uuid] << t
-      end
+    uuids = @objects.map { |ob| ob.uuid }
+    @object_tags = {}
+    Link.limit(uuids.length*20).filter([["head_uuid", "in", uuids], ["link_class", "=", "tag"]]).each do |t|
+      @object_tags[t.head_uuid] ||= []
+      @object_tags[t.head_uuid] << t
     end
   end
 
index 78727923070ae66d2c1051b03bd31ea399370e35..e3f6fdc3c9ceda44dd31ee09dc02216451fcdd47 100644 (file)
@@ -107,6 +107,9 @@ module ApplicationHelper
             end
           end
         end
+        if link_name.nil? or link_name.empty?
+          link_name = attrvalue
+        end
         if opts[:with_class_name]
           link_name = "#{resource_class.to_s}: #{link_name}"
         end
@@ -133,9 +136,6 @@ module ApplicationHelper
       if opts[:no_link]
         raw(link_name)
       else
-        if link_name.nil? or link_name.empty?
-          link_name = "(unnamed)"
-        end
         (link_to raw(link_name), { controller: resource_class.to_s.tableize, action: 'show', id: ((opts[:name_link].andand.uuid) || link_uuid) }, style_opts) + raw(tags)
       end
     else
@@ -186,8 +186,6 @@ module ApplicationHelper
     @unique_id ||= (Time.now.to_f*1000000).to_i
     span_id = object.uuid.to_s + '-' + attr.to_s + '-' + (@unique_id += 1).to_s
 
-    puts "Span #{object.inspect} #{(object.andand.default_name || 'none')}"
-
     span_tag = content_tag 'span', attrvalue.to_s, {
       "data-emptytext" => ('(none)'),
       "data-placement" => "bottom",
index 8079eb44a6593563eb67705947acd784b4e0e594..036e619ce116edf2c17cb9cadd669fe1aad58c46 100644 (file)
@@ -1,3 +1,17 @@
+<% @collections.each do |object| %>
+    <div class="row filterable selectable" data-object-uuid="<%= object.uuid %>"
+         data-preview-href="<%= chooser_preview_url_for object %>"
+         style="margin-left: 1em; border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #DDDDDD">
+      <i class="fa fa-fw fa-archive"></i>
+      <%= object.name %>
+      <% links_for_object(object).each do |tag| %>
+        <% if tag.link_class == 'tag' %>
+          <span class="label label-info"><%= tag.name %></span>
+        <% end %>
+      <% end %>
+    </div>
+<% end %>
+
 <% @name_links.each do |name_link| %>
   <% if (object = get_object(name_link.head_uuid)) %>
     <div class="row filterable selectable" data-object-uuid="<%= name_link.uuid %>"
index 7479a3066ba64d216b2f1b4da1f675be3a1051bd..e3f29952ff29fe58c62bf173ab3a982f7ac2c904 100644 (file)
@@ -1,12 +1,3 @@
-<% if @object.uuid.match /[0-9a-f]{32}/ %>
-<p>Found in collections:<p>
-<p>
-<% cols = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]).each do |c| %>
-  <%= link_to_if_arvados_object c.owner_uuid, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %><br>
-<% end %>
-</p>
-<% end %>
-
 <% if not (@output_of.andand.any? or @log_of.andand.any?) %>
   <p><i>No source information available.</i></p>
 <% end %>
index ee809d60d38dd4bbfe804a3f103e176ab7b69210..98bfafb5fcbd333280583208fc07ceb4c62a8f1e 100644 (file)
@@ -3,17 +3,30 @@
     <div class="panel panel-info">
       <div class="panel-heading">
        <h3 class="panel-title">
-         <%= if @object.respond_to? :name
-                render_editable_attribute @object, :name
-              else
-                @name_link.andand.name || @object.uuid
-              end%>
+          <% if @object.uuid.match /[0-9a-f]{32}/ %>
+            Content hash <%= @object.portable_data_hash %>
+          <% else %>
+           <%= if @object.respond_to? :name
+                  render_editable_attribute @object, :name
+                else
+                  @name_link.andand.name || @object.uuid
+                end %>
+            <% end %>
        </h3>
       </div>
       <div class="panel-body">
         <img src="/favicon.ico" class="pull-right" alt="" style="opacity: 0.3"/>
-       <p><i>Content hash:</i><br />
-         <span class="arvados-uuid"><%= link_to @object.portable_data_hash, collection_path(@object.portable_data_hash) %></span></p>
+        <% if @object.uuid.match /[0-9a-f]{32}/ %>
+          <p>Found in collections:<p>
+          <p>
+            <% cols = Collection.filter([["portable_data_hash", "=", @object.portable_data_hash]]).each do |c| %>
+              <%= link_to_if_arvados_object c.owner_uuid, {:friendly_name => true} %> / <%= link_to_if_arvados_object c, {:friendly_name => true} %><br>
+            <% end %>
+          </p>
+        <% else %>
+         <p><i>Content hash:</i><br />
+           <span class="arvados-uuid"><%= link_to @object.portable_data_hash, collection_path(@object.portable_data_hash) %></span></p>
+        <% end %>
         <%= render partial: "show_source_summary" %>
       </div>
     </div>
index a1c8fe8207da95b95360c8fc1942a51c2b39e92d..c136187f1ddff15b5dc088d9124937238de270ac 100644 (file)
@@ -30,7 +30,7 @@
       <br>
       <span class="tags-span">
     <span class="removable-tag-container">
-    <% if @object_tags[object.uuid] %>
+    <% if @object_tags and @object_tags[object.uuid] %>
       <% @object_tags[object.uuid].each do |tag_link| %>
         <span class="label label-info" data-tag-link-uuid="<%= tag_link.uuid %>">
           <%= link_to tag_link.name, controller: "links", filters: [["link_class", "=", "tag"], ["name", "=", tag_link.name]].to_json %>