Retrospring/app/assets/javascripts/moderation/destroy.coffee

25 lines
824 B
CoffeeScript
Raw Normal View History

2014-12-28 15:21:06 -08:00
$(document).on "click", "button[name=mod-delete-report]", ->
2015-01-03 10:49:47 -08:00
btn = $(this)
id = btn[0].dataset.id
2015-01-03 08:36:55 -08:00
swal
title: "Really delete?"
text: "You will not be able to recover this report."
2015-01-03 08:36:55 -08:00
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
2015-01-03 10:49:47 -08:00
closeOnConfirm: true
2015-01-03 08:36:55 -08:00
, ->
2014-12-28 15:21:06 -08:00
$.ajax
url: '/ajax/mod/destroy_report'
type: 'POST'
data:
id: id
success: (data, status, jqxhr) ->
if data.success
$("div.moderationbox[data-id=#{id}]").slideUp()
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
showNotification "An error occurred, a developer should check the console for details", false
complete: (jqxhr, status) ->