X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/add9525f2f196e2490a6876fed590d1e139ea659..efa119244cd38090933fbd0ba29f3604889e9aa9:/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 147e5a60bb..09adfef160 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -177,21 +177,38 @@ module ApplicationHelper end end - def link_to_arvados_object_if_readable(attrvalue, link_text, link_text_if_not_readable, use_friendly_name=false, resource_class=nil) - resource_class = resource_class_for_uuid(attrvalue) if !resource_class + def link_to_arvados_object_if_readable(attrvalue, link_text_if_not_readable, opts={}) + resource_class = resource_class_for_uuid(attrvalue) if !resource_class - return link_text_if_not_readable + return link_to_if_arvados_object attrvalue, opts end - readable = resource_class.find?(attrvalue) + readable = object_readable attrvalue, resource_class if readable - if use_friendly_name - link_to_if_arvados_object attrvalue, friendly_name: true + link_to_if_arvados_object attrvalue, opts + elsif opts[:required] + raw('
') + else + link_text_if_not_readable + end + end + + def object_readable attrvalue, resource_class=nil + # if it is a collection filename, check readable for the locator + attrvalue = attrvalue.split('/')[0] if attrvalue + + resource_class = resource_class_for_uuid(attrvalue) + return if resource_class.nil? + + if resource_class.to_s == 'Collection' + if CollectionsHelper.match(attrvalue) + collection_for_pdh(attrvalue).any? else - link_to_if_arvados_object attrvalue, link_text: link_text + collections_for_object(attrvalue).any? end else - link_text_if_not_readable + object_for_dataclass(resource_class, attrvalue) end end @@ -289,7 +306,7 @@ module ApplicationHelper end if not object.andand.attribute_editable?(attr) - return link_to_if_arvados_object attrvalue + return link_to_arvados_object_if_readable(attrvalue, attrvalue, {friendly_name: true, required: required}) end if dataclass @@ -341,10 +358,11 @@ module ApplicationHelper success: 'page-refresh' }.to_json, }) + is_readable_input = object_readable attrvalue unless attrvalue.andand.empty? return content_tag('div', :class => 'input-group') do html = text_field_tag(dn, display_value, :class => - "form-control #{'required' if required}") + "form-control #{'required' if required} #{'unreadable-input' if !attrvalue.andand.empty? and !is_readable_input}") html + content_tag('span', :class => 'input-group-btn') do link_to('Choose', modal_path,