FlagsReportController.js
835 Bytes
import showErrors from '../showErrors';
angular.module('footyroom')
.controller('FlagsReportController', ['$scope', '$element', '$http', '$window', function ($scope, $element, $http, $window) {
var ctrl = this;
ctrl.clear = clear;
ctrl.$onInit = init();
function init() {
ctrl.commentId = $element.data('commentId');
}
function clear() {
// Reset comment errors.
$element.find('.comment-action-errors').html('').hide();
$http.post('/flags/clear', {
commentId: ctrl.commentId,
})
.then(function (response) {
$element.remove();
$window.location.reload();
})
.catch(function (response) {
showErrors(response.data.errors, '.comment-action-errors', '#comment' + ctrl.commentId);
});
}
}]);