Semaphore/public/js/controllers/projects/edit.js
2017-03-10 10:12:55 +10:00

31 lines
983 B
JavaScript

define(function () {
app.registerController('ProjectEditCtrl', ['$scope', '$http', 'Project', '$state', function ($scope, $http, Project, $state) {
$scope.projectName = Project.name;
$scope.alert = Project.alert;
$scope.save = function (name, alert) {
$http.put(Project.getURL(), { name: name, alert: alert }).success(function () {
swal('Saved', 'Project settings saved.', 'success');
}).error(function () {
swal('Error', 'Project settings were not saved', 'error');
});
}
$scope.deleteProject = function () {
swal({
title: 'Delete Project?',
text: 'All data related to this project will be deleted.',
type: 'warning',
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: 'Yes, DELETE'
}, function () {
$http.delete(Project.getURL()).success(function () {
$state.go('dashboard');
}).error(function () {
swal('error', 'could not delete project!', 'error');
});
});
}
}]);
});