1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-03 14:24:23 +01:00
fab-manager/app/assets/javascripts/controllers/admin/abuses.js

53 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-05-09 18:27:19 +02:00
/**
* Controller used in abuses management page
*/
2019-05-21 12:24:45 +02:00
Application.Controllers.controller('AbusesController', ['$scope', '$state', 'Abuse', 'abusesPromise', 'dialogs', 'growl', '_t',
function ($scope, $state, Abuse, abusesPromise, dialogs, growl, _t) {
2019-05-21 11:49:50 +02:00
/* PUBLIC SCOPE */
2019-05-09 18:27:19 +02:00
// List of all reported abuses
2019-05-21 11:49:50 +02:00
$scope.abuses = [];
2019-05-21 12:24:45 +02:00
/**
* Callback handling a click on the button: confirm before delete
*/
$scope.confirmProcess = function (abuseId) {
dialogs.confirm(
{
resolve: {
object () {
return {
2019-12-18 11:08:14 +01:00
title: _t('app.admin.manage_abuses.confirmation_required'),
msg: _t('app.admin.manage_abuses.report_will_be_destroyed')
2019-05-21 12:24:45 +02:00
};
}
}
},
function () { // cancel confirmed
Abuse.remove({ id: abuseId }, function () { // successfully canceled
2019-12-18 11:08:14 +01:00
growl.success(_t('app.admin.manage_abuses.report_removed'));
2019-05-21 12:24:45 +02:00
Abuse.query({}, function (abuses) {
$scope.abuses = abuses.abuses.filter(a => a.signaled_type === 'Project');
});
}
, function () { // error while canceling
2019-12-18 11:08:14 +01:00
growl.error(_t('app.admin.manage_abuses.failed_to_remove'));
2019-05-21 12:24:45 +02:00
});
}
);
};
2019-05-21 11:49:50 +02:00
/* PRIVATE SCOPE */
/**
* Kind of constructor: these actions will be realized first when the controller is loaded
*/
const initialize = function () {
// we display only abuses related to projects
$scope.abuses = abusesPromise.abuses.filter(a => a.signaled_type === 'Project');
};
// !!! MUST BE CALLED AT THE END of the controller
return initialize();
2019-05-09 18:27:19 +02:00
}
]);