|
1 | 1 | $ -> |
2 | 2 |
|
3 | 3 | # |
4 | | - # Use Rails.js click handler to allow for Rails' confirm dialogs |
| 4 | + # Use ActiveAdmin.modal_dialog to prompt user if confirmation is required for current Batch Action |
5 | 5 | # |
| 6 | + $('#batch_actions_selector li a').click (e)-> |
| 7 | + e.stopPropagation() # prevent Rails UJS click event |
| 8 | + if message = $(@).data 'confirm' |
| 9 | + ActiveAdmin.modal_dialog message, $(@).data('inputs'), (inputs)=> |
| 10 | + $(@).trigger 'confirm:complete', inputs |
| 11 | + else |
| 12 | + $(@).trigger 'confirm:complete' |
| 13 | + |
| 14 | + $('#batch_actions_selector li a').on 'confirm:complete', (e, inputs)-> |
| 15 | + if val = JSON.stringify inputs |
| 16 | + $('#batch_action_inputs').val val |
| 17 | + else |
| 18 | + $('#batch_action_inputs').attr 'disabled', 'disabled' |
6 | 19 |
|
7 | | - $(document).delegate "#batch_actions_selector li a", "click.rails", -> |
8 | | - $("#batch_action").val $(@).attr("data-action") |
9 | | - $("#collection_selection").submit() |
| 20 | + $('#batch_action').val $(@).data 'action' |
| 21 | + $('#collection_selection').submit() |
10 | 22 |
|
11 | 23 | # |
12 | 24 | # Add checkbox selection to resource tables and lists if batch actions are enabled |
|
20 | 32 | $(".paginated_collection").checkboxToggler() |
21 | 33 |
|
22 | 34 | $(".paginated_collection :checkbox").change -> |
23 | | - if $(".paginated_collection :checkbox:checked").length > 0 |
| 35 | + if $(".paginated_collection :checkbox:checked").length |
24 | 36 | $("#batch_actions_selector").aaDropdownMenu("enable") |
25 | 37 | else |
26 | 38 | $("#batch_actions_selector").aaDropdownMenu("disable") |
0 commit comments