Merge branch '2376-show-collection-tags-everywhere'
authorPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 16 Apr 2014 18:11:44 +0000 (14:11 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Wed, 16 Apr 2014 18:11:44 +0000 (14:11 -0400)
Conflicts:
apps/workbench/app/controllers/actions_controller.rb

apps/workbench/app/assets/javascripts/selection.js
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/views/application/_selection_checkbox.html.erb
apps/workbench/app/views/collections/_index_tbody.html.erb
apps/workbench/app/views/collections/_show_files.html.erb
apps/workbench/app/views/layouts/application.html.erb

index 9213b70a712754ebbb4911519b873334ea474c33..d70794dc0a58f41ea71b59b2258934766a824cab 100644 (file)
@@ -91,7 +91,7 @@ jQuery(function($){
                 checkboxes[i].checked = false;
             }
         }
-        
+
         $('.remove-selection').on('click', remove_selection_click);
         $('#clear_selections_button').on('click', clear_selections);
     };
@@ -100,7 +100,7 @@ jQuery(function($){
         on('change', '.persistent-selection:checkbox', function(e) {
             //console.log($(this));
             //console.log($(this).val());
-            
+
             var inc = 0;
             if ($(this).is(":checked")) {
                 add_selection($(this).val(), $(this).attr('friendly_name'), $(this).attr('href'), $(this).attr('friendly_type'));
@@ -148,7 +148,10 @@ select_form_sources  = null;
 
                 for (var i = 0; i < lst.length; i++) {
                     if (lst[i].type == type) {
-                        ret.push({text: lst[i].name, value: lst[i].uuid})
+                        var n = lst[i].name;
+                        n = n.replace(/<span[^>]*>/i, "[");
+                        n = n.replace(/<\/span>/i, "]");
+                        ret.push({text: n, value: lst[i].uuid})
                     }
                 }
             }
@@ -169,4 +172,3 @@ select_form_sources  = null;
         return ret;
     };
 })();
-
index f24a77ad1fd126b94e2851bebf9aab292a14db6a..a5ac21595e36e5943a007b64f12b0c156eae54ed 100644 (file)
@@ -5,6 +5,7 @@ class CollectionsController < ApplicationController
   def show_pane_list
     %w(Files Attributes Metadata Provenance_graph Used_by JSON API)
   end
+
   def index
     if params[:search].andand.length.andand > 0
       tags = Link.where(any: ['contains', params[:search]])
index 9066224b7e80e473328bf7fcda8da6ceece8209f..c3409bd24e4f08073ac1201712912f83c7c30800 100644 (file)
@@ -36,7 +36,7 @@ module ApplicationHelper
         end
       end
     end
-    
+
     return h(n)
       #raw = n.to_s
     #cooked = ''
@@ -73,9 +73,18 @@ module ApplicationHelper
         if opts[:with_class_name]
           link_name = "#{resource_class.to_s}: #{link_name}"
         end
+        if !opts[:no_tags] and resource_class == Collection
+          Link.where(head_uuid: link_uuid, link_class: ["tag", "identifier"]).each do |tag|
+            link_name += ' <span class="label label-info">' + html_escape(tag.name) + '</span>'
+          end
+        end
       end
       style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
-      link_to link_name, { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
+      if opts[:no_link]
+        raw(link_name)
+      else
+        link_to raw(link_name), { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
+      end
     else
       attrvalue
     end
@@ -188,20 +197,33 @@ module ApplicationHelper
       attrvalue = attrvalue.strip
     end
 
+    attrtext = attrvalue
     if dataclass and dataclass.is_a? Class
       items = []
       if attrvalue and !attrvalue.empty?
-        items.append({name: attrvalue, uuid: attrvalue, type: dataclass.to_s})
+        Link.where(head_uuid: attrvalue, link_class: ["tag", "identifier"]).each do |tag|
+          attrtext += " [#{tag.name}]"
+        end
+        items.append({name: attrtext, uuid: attrvalue, type: dataclass.to_s})
       end
       #dataclass.where(uuid: attrvalue).each do |item|
       #  items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
       #end
+      itemuuids = []
       dataclass.limit(10).each do |item|
+        itemuuids << item.uuid
         items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
       end
+      Link.where(head_uuid: itemuuids, link_class: ["tag", "identifier"]).each do |tag|
+        items.each do |item|
+          if item.uuid == tag.head_uuid
+            item.name += ' [' + tag.name + ']'
+          end
+        end
+      end
     end
 
-    lt = link_to attrvalue, '#', {
+    lt = link_to attrtext, '#', {
       "data-emptytext" => "none",
       "data-placement" => "bottom",
       "data-type" => datatype,
@@ -216,7 +238,7 @@ module ApplicationHelper
     }.merge(htmloptions)
 
     lt += raw("\n<script>")
-    
+
     if items and items.length > 0
       lt += raw("add_form_selection_sources(#{items.to_json});\n")
     end
@@ -225,6 +247,6 @@ module ApplicationHelper
 
     lt += raw("</script>")
 
-    lt 
+    lt
   end
 end
index 4d47d892c56817386982489119855e25146c99bb..7af11752c8e2540e439c0fdc1d7ce4d906b78080 100644 (file)
@@ -1,8 +1,19 @@
 <%if object %>
+  <% fn = if defined? friendly_name
+            friendly_name
+          else
+            link_to_if_arvados_object object, {no_link: true}
+          end
+     %>
+  <% # This 'fn' string may contain embedded HTML which is already marked html_safe.
+     # Since we are putting it into a tag attribute, we need to copy into an
+     # unsafe string so that rails will escape it for us.
+     fn = String.new fn %>
 <%= check_box_tag 'uuids[]', object.uuid, false, {
-  :class => 'persistent-selection', 
-  :friendly_type => object.class.name,
-  :friendly_name => object.selection_label,
-  :href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }" 
+      :class => 'persistent-selection',
+      :friendly_type => object.class.name,
+      :friendly_name => fn,
+      :href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }",
+      :title => "Click to add this item to your selection list"
 } %>
 <% end %>
index 96b73979eb60a645b69a9be0d67c4fa91d553617..75745376c0bb5c560dda892a016fd4c917594a66 100644 (file)
@@ -2,10 +2,14 @@
 
 <tr class="collection" data-object-uuid="<%= c.uuid %>">
   <td>
-    <%= render :partial => "selection_checkbox", :locals => {:object => c} %>
+    <% friendly_name = c.friendly_link_name  %>
+    <% @collection_info[c.uuid][:tag_links].each do |tag_link| %>
+      <% friendly_name += raw(" <span class='label label-info'>#{tag_link.name}</span>") %>
+    <% end %>
+    <%= render :partial => "selection_checkbox", :locals => {:object => c, :friendly_name => friendly_name} %>
   </td>
   <td>
-    <%= link_to_if_arvados_object c.uuid %>
+    <%= link_to_if_arvados_object c.uuid, {:no_tags => true } %>
   </td>
   <td>
     <% i = 0 %>
index 956958eddb9fe0785946eb7a36bd0f866e00996e..34d24411f6d3ee218f98345177bd5c0a0db96908 100644 (file)
       <tr>
         <td>
           <%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
-                :class => 'persistent-selection', 
+                :class => 'persistent-selection',
                 :friendly_type => "File",
                 :friendly_name => "#{@object.uuid}/#{file_path}",
-                :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" 
+                :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}",
+                :title => "Click to add this item to your selection list"
               } %>
         </td>
         <td>
index 724fa9bd9ffb52a0d71a961041fdf1181eaea353..e23265adb45acff3979ccccf11ee586e0ba88694 100644 (file)
@@ -85,7 +85,7 @@
               <span class="glyphicon glyphicon-arrow-right"></span>
             </li>
             <li>
-              <%= link_to controller.breadcrumb_page_name, request.fullpath %>
+              <%= link_to_if_arvados_object @object %>
             </li>
             <li style="padding: 14px 0 14px">
               <%= form_tag do |f| %>