Sha256: 8610a3d763f83577028810d0ababad268605d251e28319f1443166b4363bd984

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

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

  #
  # 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').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")

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
activeadmin-1.0.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.0.0.pre5 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-orac-1.0.0.pre4 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-orac-1.0.0 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-orac-1.0.0.pre.orac app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.0.0.pre4 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
activeadmin-1.0.0.pre3 app/assets/javascripts/active_admin/lib/batch_actions.js.coffee