Retrospring/app/assets/javascripts/answerbox/report.coffee

26 lines
890 B
CoffeeScript
Raw Normal View History

2014-12-28 10:56:37 -08:00
$(document).on "click", "a[data-action=ab-report]", (ev) ->
ev.preventDefault()
2015-01-03 10:49:47 -08:00
btn = $(this)
aid = btn[0].dataset.aId
2015-01-03 08:36:55 -08:00
swal
title: "Really report?"
2015-01-03 10:45:14 -08:00
text: "A moderator will review this answer and decide what happens."
2015-01-03 08:36:55 -08:00
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Report"
2015-01-03 10:49:47 -08:00
closeOnConfirm: true
2015-01-03 08:36:55 -08:00
, ->
2014-12-28 10:56:37 -08:00
$.ajax
url: '/ajax/report' # TODO: find a way to use rake routes instead of hardcoding them here
type: 'POST'
data:
id: aid
type: 'answer'
success: (data, status, jqxhr) ->
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) ->
btn.button "reset"