1 module ApplicationHelper
3 controller.current_user
5 def human_readable_bytes_html(n)
6 return h(n) unless n.is_a? Fixnum
10 cooked = ',' + raw[-3..-1] + cooked
16 def link_to_if_arvados_object(attrvalue, opts={}, style_opts={})
17 if (resource_class = ArvadosBase::resource_class_for_uuid(attrvalue, opts))
18 link_uuid = attrvalue.is_a?(ArvadosBase) ? attrvalue.uuid : attrvalue
19 link_name = opts[:link_text]
22 if !opts[:with_prefixes]
23 link_name = link_name.sub /^.{5}-.{5}-/, ''
25 if opts[:with_class_name]
26 link_name = "#{resource_class.to_s} #{link_name}"
28 style_opts = style_opts.merge(style: 'font-family: monospace')
30 link_to link_name, { controller: resource_class.to_s.underscore.pluralize, action: 'show', id: link_uuid }, style_opts
36 def render_editable_attribute(object, attr)
37 attrvalue = object.send attr
38 return attrvalue if !object.attribute_editable? attr
39 link_to object.send(attr).to_s, '#', {
40 "data-type" => "text",
41 "data-resource" => object.class.to_s.underscore,
43 "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
44 "data-original-title" => "Update #{attr.gsub '_', ' '}",