Use the supported discovery document instead of the old schema#show shim.
[arvados.git] / apps / workbench / app / helpers / application_helper.rb
index 0b788430efaef33ca97ee50d60444ae0733f8dd2..e608572f05f23495e4f15f886582f7adc637b8c8 100644 (file)
@@ -106,12 +106,14 @@ module ApplicationHelper
   end
 
   def render_editable_subattribute(object, attr, subattr, template, htmloptions={})
-    attrvalue = object.send(attr)
-    subattr.each do |k|
-      if attrvalue and attrvalue.is_a? Hash
-        attrvalue = attrvalue[k]
-      else
-        break
+    if object
+      attrvalue = object.send(attr)
+      subattr.each do |k|
+        if attrvalue and attrvalue.is_a? Hash
+          attrvalue = attrvalue[k]
+        else
+          break
+        end
       end
     end
 
@@ -135,7 +137,17 @@ module ApplicationHelper
       end
     end
 
-    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
@@ -143,15 +155,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