Fix return_to on generic "Create" button.
[arvados.git] / apps / workbench / app / helpers / application_helper.rb
index 049326b26ff2be45d2c12ff9ec2a0e8340f68571..c67b314cb82e72edbe4b338337bbe63fdd5b741e 100644 (file)
@@ -3,6 +3,10 @@ module ApplicationHelper
     controller.current_user
   end
 
+  def current_api_host
+    Rails.configuration.arvados_v1_base.gsub /https?:\/\/|\/arvados\/v1/,''
+  end
+
   def render_content_from_database(markup)
     raw RedCloth.new(markup).to_html
   end
@@ -18,8 +22,12 @@ module ApplicationHelper
     cooked = raw + cooked
   end
 
+  def resource_class_for_uuid(attrvalue, opts={})
+    ArvadosBase::resource_class_for_uuid(attrvalue, opts)
+  end
+
   def link_to_if_arvados_object(attrvalue, opts={}, style_opts={})
-    if (resource_class = ArvadosBase::resource_class_for_uuid(attrvalue, opts))
+    if (resource_class = resource_class_for_uuid(attrvalue, opts))
       link_uuid = attrvalue.is_a?(ArvadosBase) ? attrvalue.uuid : attrvalue
       link_name = opts[:link_text]
       if !link_name
@@ -27,7 +35,6 @@ module ApplicationHelper
         if opts[:with_class_name]
           link_name = "#{resource_class.to_s} #{link_name}"
         end
-        style_opts = style_opts.merge(style: 'font-family: monospace')
       end
       link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
     else
@@ -40,7 +47,7 @@ module ApplicationHelper
     return attrvalue if !object.attribute_editable? attr
 
     input_type = 'text'
-    case object.class.attribute_info[attr.to_sym][:type]
+    case object.class.attribute_info[attr.to_sym].andand[:type]
     when 'text'
       input_type = 'textarea'
     when 'datetime'
@@ -49,7 +56,7 @@ module ApplicationHelper
       input_type = 'text'
     end
 
-    attrvalue = attrvalue.to_json if attrvalue.is_a? Hash
+    attrvalue = attrvalue.to_json if attrvalue.is_a? Hash or attrvalue.is_a? Array
 
     link_to attrvalue.to_s, '#', {
       "data-emptytext" => "none",