Retrospring/app/javascript/legacy/report.coffee

30 lines
993 B
CoffeeScript
Raw Normal View History

2015-04-21 19:59:10 -07:00
window.reportDialog = (type, target, callback) ->
swal
2015-06-08 11:35:16 -07:00
title: translate('frontend.report.confirm.title', {type: type})
text: translate('frontend.report.confirm.text')
2015-04-21 19:59:10 -07:00
type: "input"
showCancelButton: true
confirmButtonColor: "#DD6B55"
2015-06-08 11:35:16 -07:00
confirmButtonText: translate('views.actions.report')
cancelButtonText: translate('views.actions.cancel')
2015-04-21 19:59:10 -07:00
closeOnConfirm: true
2015-06-08 11:35:16 -07:00
inputPlaceholder: translate('frontend.report.confirm.input')
2015-04-21 19:59:10 -07:00
, (value) ->
if typeof value == "boolean" && value == false
return false
$.ajax
url: '/ajax/report'
type: 'POST'
data:
id: target
type: type
reason: value
success: (data, status, jqxhr) ->
showNotification data.message, data.success
error: (jqxhr, status, error) ->
console.log jqxhr, status, error
2015-06-08 11:35:16 -07:00
showNotification translate('frontend.error.message'), false
2015-04-21 19:59:10 -07:00
complete: (jqxhr, status) ->
callback type, target, jqxhr, status