Merge branch '2257-inequality-conditions' into 2290-user-activity
[arvados.git] / apps / workbench / app / helpers / application_helper.rb
index 6aaa70f6892642509ede281d661dcd9f27e894f4..9066224b7e80e473328bf7fcda8da6ceece8209f 100644 (file)
@@ -59,11 +59,15 @@ module ApplicationHelper
         link_name = link_uuid
 
         if opts[:friendly_name]
-          begin
-            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
+          if attrvalue.respond_to? :friendly_link_name
+            link_name = attrvalue.friendly_link_name
+          else
+            begin
+              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
+            end
           end
         end
         if opts[:with_class_name]
@@ -137,8 +141,17 @@ module ApplicationHelper
       end
     end
 
-    return template if !object
-    return attrvalue if !object.attribute_editable? attr
+    rsc = template
+    if template.is_a? Hash
+      if template[:value]
+        rsc = template[:value]
+      elsif template[:default]
+        rsc = template[:default]
+      end
+    end
+
+    return link_to_if_arvados_object(rsc) if !object
+    return link_to_if_arvados_object(attrvalue) if !object.attribute_editable? attr
 
     if dataclass
       begin
@@ -146,15 +159,6 @@ module ApplicationHelper
       rescue NameError
       end
     else
-      rsc = template
-      if template.is_a? Hash
-        if template[:value]
-          rsc = template[:value]
-        elsif template[:default]
-          rsc = template[:default]
-        end
-      end
-
       dataclass = ArvadosBase.resource_class_for_uuid(rsc)
     end