3177: look for checked persistent selections on submit.
authorradhika <radhika@curoverse.com>
Wed, 5 Nov 2014 18:57:14 +0000 (13:57 -0500)
committerradhika <radhika@curoverse.com>
Wed, 5 Nov 2014 18:57:14 +0000 (13:57 -0500)
apps/workbench/app/assets/javascripts/select_modal.js
apps/workbench/app/helpers/application_helper.rb
apps/workbench/app/views/collections/_show_files.html.erb

index ba106d111046309b83453210301ec2dfde736676..596cb702294bf79796a8b80b6be21fea9e48ea86 100644 (file)
@@ -40,10 +40,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] != ']') {
index cfe7f19187a064bb19759950778fd72a890854ae..165f0628a7258277190c1307fd1c893c1680ae76 100644 (file)
@@ -261,7 +261,7 @@ module ApplicationHelper
       dn += '[value]'
     end
 
-    if dataclass == Collection
+    if (dataclass == Collection) or (dataclass == File)
       selection_param = object.class.to_s.underscore + dn
       display_value = attrvalue
       if value_info.is_a?(Hash)
@@ -274,9 +274,9 @@ module ApplicationHelper
         end
       end
       if (attr == :components) and (subattr.size > 2)
-        chooser_title = "Choose a dataset for #{object.component_input_title(subattr[0], subattr[2])}:"
+        chooser_title = "Choose a #{dataclass == Collection ? 'dataset' : 'file'} for #{object.component_input_title(subattr[0], subattr[2])}:"
       else
-        chooser_title = "Choose a dataset:"
+        chooser_title = "Choose a #{dataclass == Collection ? 'dataset' : 'file'}:"
       end
       modal_path = choose_collections_path \
       ({ title: chooser_title,
index 9cd77b02e1a51a21c05291a5907699fb88aa24fd..adbf48071aa1198af0fcbf83c377eb929fa246be 100644 (file)
@@ -86,7 +86,7 @@
         </div>
 
         <div class="collection_files_name">
-          <% if !defined? no_checkboxes or !no_checkboxes %>
+          <%# if !defined? no_checkboxes or !no_checkboxes %>
           <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, {
                 :class => 'persistent-selection',
                 :friendly_type => "File",
@@ -96,7 +96,7 @@
                 :title => "Include #{file_path} in your selections",
               } %>
           <span>&nbsp;</span>
-          <% end %>
+          <%# end %>
       <% if CollectionsHelper::is_image(filename) %>
           <i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
        </div>