Last active
December 10, 2015 20:08
-
-
Save seanlinsley/4485846 to your computer and use it in GitHub Desktop.
WIP for github.com/gregbell/active_admin/issues/1815
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ -> | |
confirmBox = (message, inputs, callback) -> | |
html = """<div id="dialog_confirm" title="Confirmation"><p>#{message}</p>""" + | |
inputs.map((a)-> """<label>#{a}</label><input name="#{a}"></input>""").join("\n") + | |
"</div>" | |
$(html).appendTo('body').dialog | |
modal: true | |
buttons: | |
OK: -> | |
callback $(@).find('input').serializeArray() | |
$(@).dialog('close') | |
Cancel: -> | |
$(@).dialog('close').remove() | |
$('#batch_actions_selector li a').click (event)-> | |
if message = $(@).data 'confirm' | |
confirmBox message, $(@).data('inputs'), (inputs)=> | |
$(@).trigger 'confirm:complete', inputs | |
else | |
$(@).trigger 'confirm:complete' | |
event.stopPropagation() # prevent Rails UJS click event | |
$('#batch_actions_selector li a').on 'confirm:complete', (event, inputs)-> | |
$('#batch_action_inputs').val JSON.stringify inputs | |
$('#batch_action').val $(@).data('action') | |
$("#collection_selection").submit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment