Merge branch 'master' into 4036-combine-collections-in-project-issue
[arvados.git] / apps / workbench / app / assets / javascripts / select_modal.js
index 1fec3dcb95e394405cebe8bc799d5491ef7e2d4e..ba106d111046309b83453210301ec2dfde736676 100644 (file)
@@ -37,20 +37,28 @@ $(document).on('click', '.selectable', function() {
     var data = [];
     var $modal = $(this).closest('.modal');
     var action_data = $(this).data('action-data');
+    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() {
         var val = $(this).attr('data-object-uuid');
         data.push({name: selection_param, value: val});
     });
-    $.each(action_data, function(key, value) {
-        data.push({name: key, value: value});
-    });
+    $.each($.extend({}, action_data, action_data_from_params),
+           function(key, value) {
+               if (value instanceof Array && key[-1] != ']') {
+                   for (var i in value) {
+                       data.push({name: key + '[]', value: value[i]});
+                   }
+               } else {
+                   data.push({name: key, value: value});
+               }
+           });
     $.ajax($(this).attr('data-action-href'),
            {dataType: 'json',
             type: $(this).attr('data-method'),
             data: data,
-            traditional: true,
+            traditional: false,
             context: {modal: $modal, action_data: action_data}}).
         fail(function(jqxhr, status, error) {
             if (jqxhr.readyState == 0 || jqxhr.status == 0) {
@@ -75,10 +83,10 @@ $(document).on('click', '.selectable', function() {
     var project_uuid = $(this).attr('data-project-uuid');
     $(this).attr('href', '#');  // Skip normal click handler
     if (project_uuid) {
-        params = {'filters[]': JSON.stringify(['owner_uuid',
-                                               '=',
-                                               project_uuid]),
-                  project_uuid: project_uuid
+        params = {'filters': [['owner_uuid',
+                               '=',
+                               project_uuid]],
+                  'project_uuid': project_uuid
                  };
     }
     // Use current selection as dropdown button label
@@ -88,7 +96,7 @@ $(document).on('click', '.selectable', function() {
         html($(this).text() + ' <span class="caret"></span>');
     // Set (or unset) filter params and refresh filterable rows
     $($(this).closest('[data-filterable-target]').attr('data-filterable-target')).
-        data('infinite-content-params', params).
+        data('infinite-content-params-from-project-dropdown', params).
         trigger('refresh-content');
 }).on('ready', function() {
     $('form[data-search-modal] a').on('click', function() {