Sha256: f6a1d3f3f896b1d6ae5c4c26a1e7ec68abab6e426b077d198471144486708165

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

//= require ./lib/dialog_mass_fields_update

$(document).ready(() =>

  $(document).on('click', '.scoped_collection_action_button', function(e) {
    e.preventDefault();
    const fields = JSON.parse( $(this).attr('data') );

    return ActiveAdmin.dialogMassFieldsUpdate(fields['confirm'], fields['inputs'],
      inputs=> {
        const url = window.location.pathname + '/batch_action' + window.location.search;
        const form_data = {
          changes: inputs,
          collection_selection: [],
          authenticity_token: fields['auth_token'],
          batch_action: fields['batch_action']
        };
        $('.paginated_collection').find('input.collection_selection:checked').each((i, el) => form_data["collection_selection"].push($(el).val()));

        return $.post(url, form_data).always(function(data, textStatus, jqXHR) {
          if (jqXHR.getResponseHeader('Location')) {
            return window.location.assign(jqXHR.getResponseHeader('Location'));
          } else {
            return window.location.reload();
          }
        });
    });
  })
);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_admin_scoped_collection_actions-1.0.1 vendor/assets/javascripts/active_admin_scoped_collection_actions.js
active_admin_scoped_collection_actions-0.4.1 vendor/assets/javascripts/active_admin_scoped_collection_actions.js
active_admin_scoped_collection_actions-0.4.0 vendor/assets/javascripts/active_admin_scoped_collection_actions.js