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, attrvalue=nil, htmloptions={})
37 attrvalue = object.send(attr) if attrvalue.nil?
38 return attrvalue if !object.attribute_editable? attr
39 link_to attrvalue.to_s, '#', {
40 "data-emptytext" => "none",
41 "data-placement" => "bottom",
42 "data-type" => (object.class.attribute_info[attr.to_sym][:type] == "text" ? "textarea" : "text"),
43 "data-resource" => object.class.to_s.underscore,
45 "data-value" => object.send(attr),
46 "data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
47 "data-original-title" => "Update #{attr.gsub '_', ' '}",