X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/bd86112ffba029e0f2c29c7d12ae6192e4097e18..1491cdd65b8a3ef75f66516004bc0680651da201:/apps/workbench/app/assets/javascripts/select_modal.js diff --git a/apps/workbench/app/assets/javascripts/select_modal.js b/apps/workbench/app/assets/javascripts/select_modal.js index ba106d1110..d84037763c 100644 --- a/apps/workbench/app/assets/javascripts/select_modal.js +++ b/apps/workbench/app/assets/javascripts/select_modal.js @@ -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 = []; @@ -40,10 +56,20 @@ $(document).on('click', '.selectable', function() { var action_data_from_params = $(this).data('action-data-from-params'); var selection_param = action_data.selection_param; $modal.find('.modal-error').removeClass('hide').hide(); - $modal.find('.selectable.active[data-object-uuid]').each(function() { + + $checked_selections = $modal.find('.persistent-selection:checked'); + if ($checked_selections) { + $checked_selections.each(function() { + data.push({name: selection_param, value: $(this).attr('value')}); + }); + } + + if (data.length == 0) { // no checked persistent selection + $modal.find('.selectable.active[data-object-uuid]').each(function() { var val = $(this).attr('data-object-uuid'); data.push({name: selection_param, value: val}); - }); + }); + } $.each($.extend({}, action_data, action_data_from_params), function(key, value) { if (value instanceof Array && key[-1] != ']') {