Sha256: 4c1c9f518e501437ee39e2212ddf8b847ee807a8f2d0b8e7428f11992dadc5e2

Contents?: true

Size: 1.49 KB

Versions: 14

Compression:

Stored size: 1.49 KB

Contents

onDOMReady = ->
  #
  # Use ActiveAdmin.modal_dialog to prompt user if confirmation is required for current Batch Action
  #
  $('.batch_actions_selector li a').click (e)->
    e.stopPropagation() # prevent Rails UJS click event
    e.preventDefault()
    if message = $(@).data 'confirm'
      ActiveAdmin.modal_dialog message, $(@).data('inputs'), (inputs)=>
        $(@).trigger 'confirm:complete', inputs
    else
      $(@).trigger 'confirm:complete'

  $('.batch_actions_selector li a').on 'confirm:complete', (e, inputs)->
    if val = JSON.stringify inputs
      $('#batch_action_inputs').removeAttr('disabled').val val
    else
      $('#batch_action_inputs').attr 'disabled', 'disabled'

    $('#batch_action').val $(@).data 'action'
    $('#collection_selection').submit()

  #
  # Add checkbox selection to resource tables and lists if batch actions are enabled
  #

  if $(".batch_actions_selector").length && $(":checkbox.toggle_all").length

    if $(".paginated_collection table.index_table").length
      $(".paginated_collection table.index_table").tableCheckboxToggler()
    else
      $(".paginated_collection").checkboxToggler()

    $(document).on 'change', '.paginated_collection :checkbox', ->
      if $(".paginated_collection :checkbox:checked").length
        $(".batch_actions_selector").each -> $(@).aaDropdownMenu("enable")
      else
        $(".batch_actions_selector").each -> $(@).aaDropdownMenu("disable")

$(document).
  ready(onDOMReady).
  on 'page:load turbolinks:load', onDOMReady

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
activeadmin-rb-1.6.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-rb-1.5.2 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-rb-1.5.1 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-rb-1.5.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-rb-1.4.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.4.3 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.4.2 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.4.1 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.4.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.3.1 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.3.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.2.1 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.2.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.1.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee