Sha256: 059e4095846d3629cff7a9f8e5ec478531ceba5b97707d872caef63093b1fe04

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

$.fn.bulkRowEdit = function() {

  var applyAction = function() {
    $('[type=submit][data-bulk-row-edit]').prop('disabled', true);

    var ids = [];
    $('input[type=checkbox][data-bulk-row-edit]:checked').each(function() {
      ids[ids.length] = $(this).data('bulk-row-edit');
    });

    var action = $('select[data-bulk-row-edit]').val();

    if (ids.length == 0) {
      alert('No rows are selected to be modified!');
      $('[type=submit][data-bulk-row-edit]').prop('disabled', false);
      return false;
    }

    var number = ids.length;
    var questionnaires = number === 1 ? 'questionnaire' : 'questionnaires';
    var status = $('select[data-bulk-row-edit] option[value=' + action + ']').text();
    var message = 'Are you sure? This will set ' + number + ' ' + questionnaires + ' to "' + status + '".\n\nThis may trigger an automatic email to each applicant depending on your automated messages.';

    if (!confirm(message)) {
      $('[type=submit][data-bulk-row-edit]').prop('disabled', false);
      return false;
    }

    $.ajax({
      url: $('form[data-bulk-row-edit]').attr('action'),
      type: 'PATCH',
      data: {
        bulk_action: action,
        bulk_ids: ids
      }
    }).done(function() {
      window.questionnairesDataTable.draw(false);
    }).fail(function() {
      alert("Request failed, please refresh the page or try again later.");
    }).always(function() {
      $('[type=submit][data-bulk-row-edit]').prop('disabled', false);
    });

    return true;
  };

  $('[type=submit][data-bulk-row-edit]').on('click', function(e) {
    e.preventDefault();
    return applyAction();
  });

};

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hackathon_manager-0.14.1 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.14.0 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.12 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.11 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.10 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.9 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.8 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.7 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.6 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.5 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.4 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.3 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js
hackathon_manager-0.13.2 app/assets/javascripts/hackathon_manager/manage/lib/jquery.bulkRowedit.js