Merge branch '4525-remove-stale-clippy-code-TC' into 4525-remove-stale-clippy-code
[arvados.git] / apps / workbench / app / assets / javascripts / select_modal.js
index 36c145fc02e48fa95d7b6ab3523a97f8ca956485..bd68bc8a2facf92e0769b3ccec9dc9cd384e8aba 100644 (file)
@@ -9,16 +9,18 @@ $(document).on('click', '.selectable', function() {
     }
     $this.toggleClass('active');
 
-    if (!$this.hasClass('use-checkbox-selection')) {
+    if (!$this.hasClass('use-preview-selection')) {
       any = ($container.
            find('.selectable.active').length > 0)
     }
-    $this.
+
+    if (!$container.hasClass('preview-selectable-container')) {
+      $this.
         closest('.modal').
         find('[data-enable-if-selection]').
         prop('disabled', !any);
 
-    if ($this.hasClass('active')) {
+      if ($this.hasClass('active')) {
         var no_preview_available = '<div class="spinner-h-center spinner-v-center"><center>(No preview available)</center></div>';
         if (!$this.attr('data-preview-href')) {
             $(".modal-dialog-preview-pane").html(no_preview_available);
@@ -33,15 +35,16 @@ $(document).on('click', '.selectable', function() {
             fail(function(data, status, jqxhr) {
                 $(".modal-dialog-preview-pane").html(no_preview_available);
             });
+      }
+    } else {
+      any = ($container.
+           find('.preview-selectable.active').length > 0)
+      $(this).
+          closest('.modal').
+          find('[data-enable-if-selection]').
+          prop('disabled', !any);
     }
-}).on('click', '.persistent-selection', function() {
-    var $modal = $(this).closest('.modal');
-    $checked_selections = $modal.find('.persistent-selection:checked');
-    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 = [];
@@ -51,14 +54,12 @@ $(document).on('click', '.selectable', function() {
     var selection_param = action_data.selection_param;
     $modal.find('.modal-error').removeClass('hide').hide();
 
-    $checked_selections = $modal.find('.persistent-selection:checked');
-    if ($checked_selections) {
-      $checked_selections.each(function() {
-          data.push({name: selection_param, value: $(this).attr('value')});
-      });
+    var $preview_selections = $modal.find('.preview-selectable.active');
+    if ($preview_selections.length > 0) {
+      data.push({name: selection_param, value: $preview_selections.first().attr('href')});
     }
 
-    if (data.length == 0) {   // no checked persistent selection
+    if (data.length == 0) {   // not using preview selection option
       $modal.find('.selectable.active[data-object-uuid]').each(function() {
         var val = $(this).attr('data-object-uuid');
         data.push({name: selection_param, value: val});