Merge branch 'master' into 3177-collection-choose-files
[arvados.git] / apps / workbench / app / assets / javascripts / select_modal.js
index 596cb702294bf79796a8b80b6be21fea9e48ea86..d84037763c77b8a33e0478511c0e92c4f8e84170 100644 (file)
@@ -8,8 +8,11 @@ $(document).on('click', '.selectable', function() {
             removeClass('active');
     }
     $this.toggleClass('active');
-    any = ($container.
+
+    if (!$this.hasClass('use-checkbox-selection')) {
+      any = ($container.
            find('.selectable.active').length > 0)
+    }
     $this.
         closest('.modal').
         find('[data-enable-if-selection]').
@@ -31,7 +34,20 @@ $(document).on('click', '.selectable', function() {
                 $(".modal-dialog-preview-pane").html(no_preview_available);
             });
     }
+}).on('click', '.persistent-selection', function() {
+    var checked_status = this.checked;
+    var $modal = $(this).closest('.modal');
+    $checked_selections = $modal.find('.persistent-selection:checked');
+
+    if (checked_status && ($checked_selections.length > 1)) {
+      $(this).prop('checked', false);
+    }
 
+    any = ($checked_selections.length > 0);
+    $(this).
+        closest('.modal').
+        find('[data-enable-if-selection]').
+        prop('disabled', !any);
 }).on('click', '.modal button[data-action-href]', function() {
     var selection = [];
     var data = [];