3826: Merge branch 'master' into 3826-crunchstat-netstats
[arvados.git] / apps / workbench / app / helpers / application_helper.rb
index 030c365b0039f234800498e2599e239d0d35c135..66b7ed662abd86416f13e4b45a10faa5a786d8e0 100644 (file)
@@ -93,7 +93,7 @@ module ApplicationHelper
 
         if opts[:friendly_name]
           if attrvalue.respond_to? :friendly_link_name
-            link_name = attrvalue.friendly_link_name
+            link_name = attrvalue.friendly_link_name opts[:lookup]
           else
             begin
               if resource_class.name == 'Collection'
@@ -150,9 +150,7 @@ module ApplicationHelper
 
   def render_editable_attribute(object, attr, attrvalue=nil, htmloptions={})
     attrvalue = object.send(attr) if attrvalue.nil?
-    if !object.attribute_editable?(attr, :ever) or
-        (!object.editable? and
-         !object.owner_uuid.in?(my_projects.collect(&:uuid)))
+    if not object.attribute_editable?(attr)
       if attrvalue && attrvalue.length > 0
         return render_attribute_as_textile( object, attr, attrvalue, false )
       else
@@ -241,10 +239,7 @@ module ApplicationHelper
       preconfigured_search_str = value_info[:search_for]
     end
 
-    if !object or
-        !object.attribute_editable?(attr, :ever) or
-        (!object.editable? and
-         !object.owner_uuid.in?(my_projects.collect(&:uuid)))
+    if not object.andand.attribute_editable?(attr)
       return link_to_if_arvados_object attrvalue
     end
 
@@ -470,49 +465,8 @@ module ApplicationHelper
     end
   end
 
-  def move_or_copy_items action, uuids_to_add, target_uuid
-    uuids_to_add = [ uuids_to_add ] unless uuids_to_add.is_a? Array
-    uuids_to_add.
-      collect { |x| ArvadosBase::resource_class_for_uuid(x) }.
-      uniq.
-      each do |resource_class|
-      resource_class.filter([['uuid','in',uuids_to_add]]).each do |src|
-        if resource_class == Collection and not Collection.attribute_info.include?(:name)
-          dst = Link.new(owner_uuid: target_uuid,
-                         tail_uuid: target_uuid,
-                         head_uuid: src.uuid,
-                         link_class: 'name',
-                         name: src.uuid)
-        else
-          case action
-          when :copy
-            dst = src.dup
-            if dst.respond_to? :'name='
-              if dst.name
-                dst.name = "Copy of #{dst.name}"
-              else
-                dst.name = "Copy of unnamed #{dst.class_for_display.downcase}"
-              end
-            end
-            if resource_class == Collection
-              dst.manifest_text = Collection.select([:manifest_text]).where(uuid: src.uuid).first.manifest_text
-            end
-          when :move
-            dst = src
-          else
-            raise ArgumentError.new "Unsupported action #{action}"
-          end
-          dst.owner_uuid = target_uuid
-          dst.tail_uuid = target_uuid if dst.class == Link
-        end
-        begin
-          dst.save!
-        rescue
-          dst.name += " (#{Time.now.localtime})" if dst.respond_to? :name=
-          dst.save!
-        end
-      end
-    end
+  def render_localized_date(date, opts="")
+    raw("<span class='utc-date' data-utc-date='#{date}' data-utc-date-opts='noseconds'>#{date}</span>")
   end
 
 private