[ARVADOS] created: d66cd99b144e949dc7128e7299689ca567a761c8
git at public.curoverse.com
git at public.curoverse.com
Mon Apr 14 16:29:43 EDT 2014
at d66cd99b144e949dc7128e7299689ca567a761c8 (commit)
commit d66cd99b144e949dc7128e7299689ca567a761c8
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Apr 14 16:29:34 2014 -0400
Javascript to replace <span> tags used for labels to square brackets for
selection lists that can't handle HTML.
Some output sanitization in case a tag has HTML in it.
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index 9213b70..d70794d 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -91,7 +91,7 @@ jQuery(function($){
checkboxes[i].checked = false;
}
}
-
+
$('.remove-selection').on('click', remove_selection_click);
$('#clear_selections_button').on('click', clear_selections);
};
@@ -100,7 +100,7 @@ jQuery(function($){
on('change', '.persistent-selection:checkbox', function(e) {
//console.log($(this));
//console.log($(this).val());
-
+
var inc = 0;
if ($(this).is(":checked")) {
add_selection($(this).val(), $(this).attr('friendly_name'), $(this).attr('href'), $(this).attr('friendly_type'));
@@ -148,7 +148,10 @@ select_form_sources = null;
for (var i = 0; i < lst.length; i++) {
if (lst[i].type == type) {
- ret.push({text: lst[i].name, value: lst[i].uuid})
+ var n = lst[i].name;
+ n = n.replace(/<span[^>]*>/i, "[");
+ n = n.replace(/<\/span>/i, "]");
+ ret.push({text: n, value: lst[i].uuid})
}
}
}
@@ -169,4 +172,3 @@ select_form_sources = null;
return ret;
};
})();
-
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index b36d33d..26c3074 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -75,13 +75,13 @@ module ApplicationHelper
end
if !opts[:no_tags] and resource_class == Collection
Link.where(head_uuid: link_uuid, link_class: ["tag", "identifier"]).each do |tag|
- link_name += ' <span class="label label-info">' + tag.name + '</span>'
+ link_name += ' <span class="label label-info">' + html_escape(tag.name) + '</span>'
end
end
end
style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
if opts[:no_link]
- link_name
+ raw(link_name)
else
link_to raw(link_name), { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
end
@@ -197,10 +197,14 @@ module ApplicationHelper
attrvalue = attrvalue.strip
end
+ attrtext = attrvalue
if dataclass and dataclass.is_a? Class
items = []
if attrvalue and !attrvalue.empty?
- items.append({name: attrvalue, uuid: attrvalue, type: dataclass.to_s})
+ Link.where(head_uuid: attrvalue, link_class: ["tag", "identifier"]).each do |tag|
+ attrtext += " [#{tag.name}]"
+ end
+ items.append({name: attrtext, uuid: attrvalue, type: dataclass.to_s})
end
#dataclass.where(uuid: attrvalue).each do |item|
# items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
@@ -219,7 +223,7 @@ module ApplicationHelper
end
end
- lt = link_to attrvalue, '#', {
+ lt = link_to attrtext, '#', {
"data-emptytext" => "none",
"data-placement" => "bottom",
"data-type" => datatype,
diff --git a/apps/workbench/app/views/application/_selection_checkbox.html.erb b/apps/workbench/app/views/application/_selection_checkbox.html.erb
index 732c343..7af1175 100644
--- a/apps/workbench/app/views/application/_selection_checkbox.html.erb
+++ b/apps/workbench/app/views/application/_selection_checkbox.html.erb
@@ -1,9 +1,18 @@
<%if object %>
+ <% fn = if defined? friendly_name
+ friendly_name
+ else
+ link_to_if_arvados_object object, {no_link: true}
+ end
+ %>
+ <% # This 'fn' string may contain embedded HTML which is already marked html_safe.
+ # Since we are putting it into a tag attribute, we need to copy into an
+ # unsafe string so that rails will escape it for us.
+ fn = String.new fn %>
<%= check_box_tag 'uuids[]', object.uuid, false, {
:class => 'persistent-selection',
:friendly_type => object.class.name,
- :friendly_name => (if defined? friendly_name then friendly_name
- else link_to_if_arvados_object object, {:no_link => true} end),
+ :friendly_name => fn,
:href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }",
:title => "Click to add this item to your selection list"
} %>
commit 2a73947440a58ce3a63adac1b903421ea911c5cf
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Apr 14 14:48:09 2014 -0400
Removes spurious whitespace.
diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb
index 74e5831..e1e3541 100644
--- a/apps/workbench/app/controllers/actions_controller.rb
+++ b/apps/workbench/app/controllers/actions_controller.rb
@@ -78,7 +78,7 @@ class ActionsController < ApplicationController
l = Link.new({
tail_kind: "arvados#collection",
tail_uuid: k,
- head_kind: "arvados#collection",
+ head_kind: "arvados#collection",
head_uuid: newuuid,
link_class: "provenance",
name: "provided"
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index 01abbb4..28dad41 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -5,6 +5,7 @@ class CollectionsController < ApplicationController
def show_pane_list
%w(Files Attributes Metadata Provenance_graph Used_by JSON API)
end
+
def index
if params[:search].andand.length.andand > 0
tags = Link.where(any: ['contains', params[:search]])
@@ -112,17 +113,17 @@ class CollectionsController < ApplicationController
@sourcedata[collection.uuid][:collection] = collection
end
end
-
+
Collection.where(uuid: @object.uuid).each do |u|
puts request
- @prov_svg = ProvenanceHelper::create_provenance_graph(u.provenance, "provenance_svg",
+ @prov_svg = ProvenanceHelper::create_provenance_graph(u.provenance, "provenance_svg",
{:request => request,
- :direction => :bottom_up,
+ :direction => :bottom_up,
:combine_jobs => :script_only}) rescue nil
- @used_by_svg = ProvenanceHelper::create_provenance_graph(u.used_by, "used_by_svg",
+ @used_by_svg = ProvenanceHelper::create_provenance_graph(u.used_by, "used_by_svg",
{:request => request,
- :direction => :top_down,
- :combine_jobs => :script_only,
+ :direction => :top_down,
+ :combine_jobs => :script_only,
:pdata_only => true}) rescue nil
end
end
commit 6c76e5ce6520a465ff741e4510eafc757738e9ba
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Mon Apr 14 14:47:42 2014 -0400
Adds tags to link text for anything using #link_to_if_arvados_object for a collection
Changed breadcrumb at top of page to use #link_to_if_arvados_object
Adding a collection to selection list includes tags in item text
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 9066224..b36d33d 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -36,7 +36,7 @@ module ApplicationHelper
end
end
end
-
+
return h(n)
#raw = n.to_s
#cooked = ''
@@ -73,9 +73,18 @@ module ApplicationHelper
if opts[:with_class_name]
link_name = "#{resource_class.to_s}: #{link_name}"
end
+ if !opts[:no_tags] and resource_class == Collection
+ Link.where(head_uuid: link_uuid, link_class: ["tag", "identifier"]).each do |tag|
+ link_name += ' <span class="label label-info">' + tag.name + '</span>'
+ end
+ end
end
style_opts[:class] = (style_opts[:class] || '') + ' nowrap'
- link_to link_name, { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
+ if opts[:no_link]
+ link_name
+ else
+ link_to raw(link_name), { controller: resource_class.to_s.tableize, action: 'show', id: link_uuid }, style_opts
+ end
else
attrvalue
end
@@ -166,7 +175,7 @@ module ApplicationHelper
datatype = 'select'
elsif dataclass == 'number'
datatype = 'number'
- else
+1 else
if template.is_a? Array
# ?!?
elsif template.is_a? String
@@ -196,9 +205,18 @@ module ApplicationHelper
#dataclass.where(uuid: attrvalue).each do |item|
# items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
#end
+ itemuuids = []
dataclass.limit(10).each do |item|
+ itemuuids << item.uuid
items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
end
+ Link.where(head_uuid: itemuuids, link_class: ["tag", "identifier"]).each do |tag|
+ items.each do |item|
+ if item.uuid == tag.head_uuid
+ item.name += ' [' + tag.name + ']'
+ end
+ end
+ end
end
lt = link_to attrvalue, '#', {
@@ -216,7 +234,7 @@ module ApplicationHelper
}.merge(htmloptions)
lt += raw("\n<script>")
-
+
if items and items.length > 0
lt += raw("add_form_selection_sources(#{items.to_json});\n")
end
@@ -225,6 +243,6 @@ module ApplicationHelper
lt += raw("</script>")
- lt
+ lt
end
end
diff --git a/apps/workbench/app/models/arvados_base.rb b/apps/workbench/app/models/arvados_base.rb
index 3c224aa..d886d74 100644
--- a/apps/workbench/app/models/arvados_base.rb
+++ b/apps/workbench/app/models/arvados_base.rb
@@ -164,7 +164,7 @@ class ArvadosBase < ActiveRecord::Base
true
end
end
-
+
def links(*args)
o = {}
o.merge!(args.pop) if args[-1].is_a? Hash
diff --git a/apps/workbench/app/views/application/_selection_checkbox.html.erb b/apps/workbench/app/views/application/_selection_checkbox.html.erb
index 4d47d89..732c343 100644
--- a/apps/workbench/app/views/application/_selection_checkbox.html.erb
+++ b/apps/workbench/app/views/application/_selection_checkbox.html.erb
@@ -1,8 +1,10 @@
<%if object %>
<%= check_box_tag 'uuids[]', object.uuid, false, {
- :class => 'persistent-selection',
- :friendly_type => object.class.name,
- :friendly_name => object.selection_label,
- :href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }"
+ :class => 'persistent-selection',
+ :friendly_type => object.class.name,
+ :friendly_name => (if defined? friendly_name then friendly_name
+ else link_to_if_arvados_object object, {:no_link => true} end),
+ :href => "#{url_for controller: object.class.name.tableize, action: 'show', id: object.uuid }",
+ :title => "Click to add this item to your selection list"
} %>
<% end %>
diff --git a/apps/workbench/app/views/collections/_index_tbody.html.erb b/apps/workbench/app/views/collections/_index_tbody.html.erb
index 96b7397..7574537 100644
--- a/apps/workbench/app/views/collections/_index_tbody.html.erb
+++ b/apps/workbench/app/views/collections/_index_tbody.html.erb
@@ -2,10 +2,14 @@
<tr class="collection" data-object-uuid="<%= c.uuid %>">
<td>
- <%= render :partial => "selection_checkbox", :locals => {:object => c} %>
+ <% friendly_name = c.friendly_link_name %>
+ <% @collection_info[c.uuid][:tag_links].each do |tag_link| %>
+ <% friendly_name += raw(" <span class='label label-info'>#{tag_link.name}</span>") %>
+ <% end %>
+ <%= render :partial => "selection_checkbox", :locals => {:object => c, :friendly_name => friendly_name} %>
</td>
<td>
- <%= link_to_if_arvados_object c.uuid %>
+ <%= link_to_if_arvados_object c.uuid, {:no_tags => true } %>
</td>
<td>
<% i = 0 %>
diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 956958e..34d2441 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -24,10 +24,11 @@
<tr>
<td>
<%= check_box_tag 'uuids[]', @object.uuid+'/'+file_path, false, {
- :class => 'persistent-selection',
+ :class => 'persistent-selection',
:friendly_type => "File",
:friendly_name => "#{@object.uuid}/#{file_path}",
- :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}"
+ :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}",
+ :title => "Click to add this item to your selection list"
} %>
</td>
<td>
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index 724fa9b..1fa374c 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -85,7 +85,8 @@
<span class="glyphicon glyphicon-arrow-right"></span>
</li>
<li>
- <%= link_to controller.breadcrumb_page_name, request.fullpath %>
+ <!-- <%= link_to controller.breadcrumb_page_name, request.fullpath %> -->
+ <%= link_to_if_arvados_object @object %>
</li>
<li style="padding: 14px 0 14px">
<%= form_tag do |f| %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list