X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/52838f7dfc576e8a11411fd9f1710a758573a6e7..16413f6ebe1bba3a070cdff3d7436ad508db8514:/apps/workbench/app/assets/javascripts/selection.js
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index 29c52d6e42..1e32c63564 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -4,8 +4,9 @@
/** Javascript for local persistent selection. */
get_selection_list = null;
+form_selection_sources = {};
-(function($){
+jQuery(function($){
var storage = localStorage; // sessionStorage
get_selection_list = function() {
@@ -39,7 +40,6 @@ get_selection_list = null;
};
var remove_selection_click = function(e) {
- //remove_selection($(this).attr('name'));
remove_selection($(this).val());
};
@@ -49,22 +49,30 @@ get_selection_list = null;
}
var update_count = function(e) {
+ var html;
+ var this_object_uuid = $('#selection-form-content').
+ closest('form').
+ find('input[name=uuid]').val();
var lst = get_selection_list();
$("#persistent-selection-count").text(lst.length);
-
if (lst.length > 0) {
- $('#persistent-selection-list').html('
Clear selections'
- +'');
+ html = ' Clear selections';
+ if (this_object_uuid.match('-j7d0g-'))
+ html += '';
+ html += ''
+ + '';
+ $('#selection-form-content').html(html);
+
for (var i = 0; i < lst.length; i++) {
- $('#persistent-selection-list > li > table').append(""
+ $('#selection-form-content > li > table').append("
"
+ ""
- + ""
+ + ""
+ " | "
+ ""
- + "" + lst[i].name + ""
+ + ""
+ " | "
+ ""
@@ -74,7 +82,7 @@ get_selection_list = null;
+ " |
");
}
} else {
- $('#persistent-selection-list').html("No selections.");
+ $('#selection-form-content').html("No selections.");
}
var checkboxes = $('.persistent-selection:checkbox');
@@ -89,7 +97,7 @@ get_selection_list = null;
checkboxes[i].checked = false;
}
}
-
+
$('.remove-selection').on('click', remove_selection_click);
$('#clear_selections_button').on('click', clear_selections);
};
@@ -98,7 +106,7 @@ get_selection_list = null;
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'));
@@ -110,4 +118,63 @@ get_selection_list = null;
$(window).on('load storage', update_count);
-})(jQuery);
\ No newline at end of file
+
+ $('#selection-form-content').on("click", function(e) {
+ e.stopPropagation();
+ });
+});
+
+add_form_selection_sources = null;
+select_form_sources = null;
+
+(function() {
+ var form_selection_sources = {};
+ add_form_selection_sources = function (src) {
+ for (var i = 0; i < src.length; i++) {
+ var t = form_selection_sources[src[i].type];
+ if (!t) {
+ t = form_selection_sources[src[i].type] = {};
+ }
+ if (!t[src[i].uuid]) {
+ t[src[i].uuid] = src[i];
+ }
+ }
+ };
+
+ select_form_sources = function(type) {
+ var ret = [];
+
+ if (get_selection_list) {
+ var lst = get_selection_list();
+ if (lst.length > 0) {
+ var text = "― Selections ―";
+ var span = document.createElement('span');
+ span.innerHTML = text;
+ ret.push({text: span.innerHTML, value: "***invalid***"});
+
+ for (var i = 0; i < lst.length; i++) {
+ if (lst[i].type == type) {
+ var n = lst[i].name;
+ n = n.replace(/]*>/i, "[");
+ n = n.replace(/<\/span>/i, "]");
+ ret.push({text: n, value: lst[i].uuid})
+ }
+ }
+ }
+ }
+
+ var text = "― Recent ―";
+ var span = document.createElement('span');
+ span.innerHTML = text;
+ ret.push({text: span.innerHTML, value: "***invalid***"});
+
+ var t = form_selection_sources[type];
+ for (var key in t) {
+ if (t.hasOwnProperty(key)) {
+ var obj = t[key];
+ ret.push({text: obj.name, value: obj.uuid})
+ }
+ }
+ return ret;
+ };
+})();