X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/86f994bb5d039e62bfc4383ed9f510b77b71ecad..db8213fdb447e701467787f631beba495d0c7fbb:/apps/workbench/app/helpers/application_helper.rb diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb index bc828c4f38..5e6d574a4c 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -1,6 +1,4 @@ module ApplicationHelper - include VersionHelper - def current_user controller.current_user end @@ -190,6 +188,9 @@ module ApplicationHelper @unique_id ||= (Time.now.to_f*1000000).to_i span_id = object.uuid.to_s + '-' + attr.to_s + '-' + (@unique_id += 1).to_s + if attr == 'description' + input_type = 'textarea' + end span_tag = content_tag 'span', rendervalue, { "data-emptytext" => '(none)', "data-placement" => "bottom", @@ -309,64 +310,17 @@ module ApplicationHelper end end - if dataclass.andand.is_a?(Class) - datatype = 'select' - elsif dataclass == 'number' - datatype = 'number' - elsif attrvalue.is_a? Array - # TODO: find a way to edit arrays with x-editable - return attrvalue - elsif attrvalue.is_a? Fixnum or attrvalue.is_a? Float + if dataclass == 'number' or attrvalue.is_a? Fixnum or attrvalue.is_a? Float datatype = 'number' elsif attrvalue.is_a? String datatype = 'text' + elsif attrvalue.is_a?(Array) or dataclass.andand.is_a?(Class) + # TODO: find a way to edit with x-editable + return attrvalue end - # preload data - preload_uuids = [] - items = [] - selectables = [] - - attrtext = attrvalue - if dataclass.is_a? Class and dataclass < ArvadosBase - objects = get_n_objects_of_class dataclass, 10 - objects.each do |item| - items << item - preload_uuids << item.uuid - end - if attrvalue and !attrvalue.empty? - preload_uuids << attrvalue - end - preload_links_for_objects preload_uuids - - if attrvalue and !attrvalue.empty? - links_for_object(attrvalue).each do |link| - if link.link_class.in? ["tag", "identifier"] - attrtext += " [#{link.name}]" - end - end - selectables.append({name: attrtext, uuid: attrvalue, type: dataclass.to_s}) - end - itemuuids = [] - items.each do |item| - itemuuids << item.uuid - selectables.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s}) - end - - itemuuids.each do |itemuuid| - links_for_object(itemuuid).each do |link| - if link.link_class.in? ["tag", "identifier"] - selectables.each do |selectable| - if selectable['uuid'] == link.head_uuid - selectable['name'] += ' [' + link.name + ']' - end - end - end - end - end - end - - lt = link_to attrtext, '#', { + # When datatype is a String or Fixnum, link_to the attrvalue + lt = link_to attrvalue, '#', { "data-emptytext" => "none", "data-placement" => "bottom", "data-type" => datatype, @@ -381,16 +335,6 @@ module ApplicationHelper :id => id }.merge(htmloptions) - lt += raw("\n") - lt end