[ARVADOS] updated: 931035f064b020f125daf5b905e87f994528020e

git at public.curoverse.com git at public.curoverse.com
Wed Dec 3 13:00:56 EST 2014


Summary of changes:
 .../app/assets/javascripts/selection.js.erb        | 171 ++-------------------
 apps/workbench/app/assets/javascripts/tab_panes.js |   1 +
 apps/workbench/app/helpers/application_helper.rb   |   7 -
 .../app/views/collections/_show_files.html.erb     |  15 +-
 4 files changed, 13 insertions(+), 181 deletions(-)

       via  931035f064b020f125daf5b905e87f994528020e (commit)
      from  994fa4569b8da43486719ce0da770ab1887b24b9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 931035f064b020f125daf5b905e87f994528020e
Author: radhika <radhika at curoverse.com>
Date:   Wed Dec 3 13:00:35 2014 -0500

    4525: remove stale clippy code

diff --git a/apps/workbench/app/assets/javascripts/selection.js.erb b/apps/workbench/app/assets/javascripts/selection.js.erb
index 40724bb..34a5d7a 100644
--- a/apps/workbench/app/assets/javascripts/selection.js.erb
+++ b/apps/workbench/app/assets/javascripts/selection.js.erb
@@ -1,176 +1,19 @@
 //= require jquery
 //= require jquery_ujs
 
-/** Javascript for local persistent selection. */
-
-get_selection_list = null;
-form_selection_sources = {};
+/** Javascript for selection. */
 
 jQuery(function($){
-    var storage = localStorage; // sessionStorage
-
-    get_selection_list = function() {
-        if (!storage.persistentSelection) {
-            storage.persistentSelection = JSON.stringify([]);
-        }
-        return JSON.parse(storage.persistentSelection);
-    }
-
-    var put_storage = function(lst) {
-        storage.persistentSelection = JSON.stringify(lst);
-    }
-
-    var add_selection = function(uuid, name, href, type) {
-        var lst = get_selection_list();
-        lst.push({"uuid": uuid, "name": name, "href": href, "type": type});
-        put_storage(lst);
-        update_count();
-    };
-
-    var remove_selection = function(uuid) {
-        var lst = get_selection_list();
-        for (var i = 0; i < lst.length; i++) {
-            if (lst[i].uuid == uuid) {
-                lst.splice(i, 1);
-                i--;
-            }
-        }
-        put_storage(lst);
-        update_count();
-    };
-
-    var remove_selection_click = function(e) {
-        remove_selection($(this).val());
-    };
-
-    var clear_selections = function() {
-        put_storage([]);
-        update_count();
-    }
-
-    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) {
-            html = '<li><a href="#" class="btn btn-xs btn-info" id="clear_selections_button"><i class="fa fa-fw fa-ban"></i> Clear selections</a></li>';
-            $('#selection-form-content').html(html);
-
-            for (var i = 0; i < lst.length; i++) {
-                $('#selection-form-content > li > table').append("<tr>"
-                                                       + "<td>"
-                                                       + "<input class='remove-selection' name='selection[]' type='checkbox' value='" + lst[i].uuid + "' checked='true' data-stoppropagation='true' />"
-                                                       + "</td>"
-
-                                                       + "<td>"
-                                                       + "<div style='padding-left: 1em'><a href=\"" + lst[i].href + "\">" + lst[i].name + "</a></div>"
-                                                       + "</td>"
-
-                                                       + "<td style=\"vertical-align: top\">"
-                                                       + "<span style=\"padding-right: 1em\">" + lst[i].type + "</span>"
-                                                       + "</td>"
-
-                                                       + "</tr>");
-            }
-        } else {
-            $('#selection-form-content').html("<li class='notification empty'>No selections.</li>");
-        }
-
-        var checkboxes = $('.persistent-selection:checkbox');
-        for (i = 0; i < checkboxes.length; i++) {
-            for (var j = 0; j < lst.length; j++) {
-                if (lst[j].uuid == $(checkboxes[i]).val()) {
-                    checkboxes[i].checked = true;
-                    break;
-                }
-            }
-            if (j == lst.length) {
-                checkboxes[i].checked = false;
-            }
-        }
-
-        $('.remove-selection').on('click', remove_selection_click);
-        $('#clear_selections_button').on('click', clear_selections);
-        $(document).trigger('selections-updated', [lst]);
-    };
-
     $(document).
         on('change', '.persistent-selection:checkbox', function(e) {
-            var inc = 0;
-            if ($(this).is(":checked")) {
-                add_selection($(this).val(), $(this).attr('friendly_name'), $(this).attr('href'), $(this).attr('friendly_type'));
-            }
-            else {
-                remove_selection($(this).val());
-            }
+            $(document).trigger('selections-updated');
         });
 
-    $(window).on('load', clear_selections);
-    $(window).on('storage', update_count);
-
     $('#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(/<span[^>]*>/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;
-    };
-})();
-
 function dispatch_selection_action() {
     // Build a new "href" attribute for this link by starting with the
     // "data-href" attribute and appending ?foo[]=bar&foo[]=baz (or
@@ -180,7 +23,7 @@ function dispatch_selection_action() {
     var param_name = $(this).attr('data-selection-param-name');
     var href = $(this).attr('data-href');
     if ($(this).closest('.disabled').length > 0) {
-	return false;
+        return false;
     }
     $(this).
         closest('.selection-action-container').
@@ -199,7 +42,7 @@ function dispatch_selection_action() {
 
 function enable_disable_selection_actions() {
     var $container = $(this).closest('.selection-action-container');
-    var $checked = $('.persistent-selection:checkbox:checked', $container);
+    var $checked = $('.persistent-selection:checkbox:checked:visible', $container);
     $('[data-selection-action]').
         closest('div.btn-group-sm').
         find('ul li').
@@ -223,6 +66,12 @@ function enable_disable_selection_actions() {
                     ($checked.length != $checked.filter('[value*=-4zz18-]').length));
 }
 
+function update_selection_actions() {
+    var $btn = $('[data-selection-action]');
+    $btn.click(dispatch_selection_action);
+    enable_disable_selection_actions.call($btn);
+}
+
 $(document).
     on('selections-updated ready ajax:complete', function() {
         var $btn = $('[data-selection-action]');
diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
index 07e46fe..11990b0 100644
--- a/apps/workbench/app/assets/javascripts/tab_panes.js
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -2,6 +2,7 @@
 
 // Fire when a tab is selected/clicked.
 $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(event) {
+    update_selection_actions();
     // reload the pane (unless it's already loaded)
     $($(event.target).attr('href')).
         not('.pane-loaded').
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index c8c4ccc..ff7c80f 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -380,13 +380,6 @@ module ApplicationHelper
     }.merge(htmloptions)
 
     lt += raw("\n<script>")
-
-    if selectables.any?
-      lt += raw("add_form_selection_sources(#{selectables.to_json});\n")
-    end
-
-    lt += raw("$('[data-name=\"#{dn}\"]').editable({source: function() { return select_form_sources('#{dataclass}'); } });\n")
-
     lt += raw("</script>")
 
     lt
diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index 397e22a..603dc34 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -1,21 +1,10 @@
 <script>
-// The "each" loop in select_all_files() and unselect_all_files()
-// is needed because .trigger("change") does not play well with clippy.
-// Once clippy has been retired, we should be able to compress this
-// into .filter(":visible").prop("checked", true).trigger("change").
-//
 function select_all_files() {
-  $("#collection_files :checkbox").filter(":visible").each(
-    function() {
-      $(this).prop("checked", true).trigger("change");
-    });
+  $("#collection_files :checkbox").filter(":visible").prop("checked", true).trigger("change");
 }
 
 function unselect_all_files() {
-  $("#collection_files :checkbox").filter(":visible").each(
-    function() {
-      $(this).prop("checked", false).trigger("change");
-    });
+  $("#collection_files :checkbox").filter(":visible").prop("checked", false).trigger("change");
 }
 </script>
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list