This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 65748fbaa00eda5785b57e171aac7e871c8ea9e5 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Dec 19 15:15:39 2014 +0100 fixes #6301 add a dialog to confirm delete --- .../src/main/webapp/js/coselmar-controllers.js | 50 +++++++++++++++++++++- .../src/main/webapp/views/documents/document.html | 4 +- .../src/main/webapp/views/documents/documents.html | 4 +- .../src/main/webapp/views/questions/question.html | 4 +- .../src/main/webapp/views/questions/questions.html | 4 +- coselmar-ui/src/main/webapp/views/users/user.html | 5 ++- coselmar-ui/src/main/webapp/views/users/users.html | 4 +- 7 files changed, 68 insertions(+), 7 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 404a858..b8a6d63 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -266,7 +266,7 @@ coselmarControllers.controller("UserViewCtrl", $scope.deleteUser = function(userId){ - documentService.deleteUser(documentId, $scope, function() { + userService.deleteUser(userId, $scope, function() { // Go back to users list $location.path("/users"); }); @@ -860,3 +860,51 @@ coselmarControllers.filter('propsFilter', function() { return out; }; }); + + +/** + * A generic confirmation for risky actions. + * Usage: Add attributes: ng-really-message="Are you sure"? ng-really-click="takeAction()" function + */ +coselmarControllers.directive('ngConfirmClick', ['$modal', function($modal) { + + var ModalInstanceCtrl = function($scope, $modalInstance) { + $scope.ok = function() { + $modalInstance.close(); + }; + + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + + return { + restrict: 'A', + scope:{ + onConfirm : "&ngConfirmClick", + }, + + link: function(scope, element, attrs) { + element.bind('click', function() { + var message = attrs.ngConfirmMessage || "Are you sure ?"; + + var modalHtml = '<div class="modal-title"><h2>Confirm Delete</h2></div>'; + modalHtml += '<div class="modal-body">' + message + '</div>'; + modalHtml += '<div class="modal-footer"><button class="btn btn-primary" ng-click="ok()">OK</button><button class="btn btn-warning" ng-click="cancel()">Cancel</button></div>'; + + var modalInstance = $modal.open({ + template: modalHtml, + controller: ModalInstanceCtrl + }); + + modalInstance.result.then(function() { + scope.onConfirm(); + }, function() { + //Modal dismissed + }); + + }); + + } + } +}]); \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/documents/document.html b/coselmar-ui/src/main/webapp/views/documents/document.html index 1ee46da..959087c 100644 --- a/coselmar-ui/src/main/webapp/views/documents/document.html +++ b/coselmar-ui/src/main/webapp/views/documents/document.html @@ -91,7 +91,9 @@ <div class="float-right"> <a href="{{container.baseUrl}}/documents/{{document.id}}/file" class="btn btn-primary" ng-if="document.withFile">Download</a> <a href="{{document.externalUrl}}" target="_blank" class="btn btn-primary" ng-if="document.externalUrl">Open Link</a> - <a class="btn btn-danger" ng-click="deleteDocument(document.id)">Delete</a> + <a class="btn btn-danger" + ng-confirm-message="Do you really want to delete this document ?" + ng-confirm-click="deleteDocument(document.id)">Delete</a> </div> </div> </div> \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/documents/documents.html b/coselmar-ui/src/main/webapp/views/documents/documents.html index d1a656b..5fcd62a 100644 --- a/coselmar-ui/src/main/webapp/views/documents/documents.html +++ b/coselmar-ui/src/main/webapp/views/documents/documents.html @@ -61,7 +61,9 @@ <td><span ng-repeat="keyword in document.keywords">{{keyword}} ,</span></td> <td>{{document.depositDate | date:'mediumDate'}}</td> <td>N/A</td> - <td><a class="btn btn-action btn-disable" ng-click="deleteDocument(document.id)"> + <td><a class="btn btn-action btn-disable" + ng-confirm-message="Do you really want to delete this document ?" + ng-confirm-click="deleteDocument(document.id)"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>Delete</a> </td> </tr> diff --git a/coselmar-ui/src/main/webapp/views/questions/question.html b/coselmar-ui/src/main/webapp/views/questions/question.html index 7af86ef..0cf8ad8 100644 --- a/coselmar-ui/src/main/webapp/views/questions/question.html +++ b/coselmar-ui/src/main/webapp/views/questions/question.html @@ -74,7 +74,9 @@ <span class="fa fa-edit" aria-hidden="true"></span>Adjourn </a> - - <a class="btn btn-action btn-disable" ng-click="deleteQuestion()"> + <a class="btn btn-action btn-disable" + ng-confirm-message="Do you really want to delete this question ?" + ng-confirm-click="deleteQuestion()"> <span class="fa fa-remove" aria-hidden="true"></span>Delete </a> </div> diff --git a/coselmar-ui/src/main/webapp/views/questions/questions.html b/coselmar-ui/src/main/webapp/views/questions/questions.html index faec1db..484dfac 100644 --- a/coselmar-ui/src/main/webapp/views/questions/questions.html +++ b/coselmar-ui/src/main/webapp/views/questions/questions.html @@ -83,7 +83,9 @@ <!--<a class="btn btn-action btn-disable" ng-click="closeQuestion(question.id)"--> <!--ng-if="currentUser.role == 'SUPERVISOR'">--> <!--<span class="fa fa-close" aria-hidden="true"></span>Close</a>--> - <a class="btn btn-action btn-disable" ng-click="deleteQuestion(question.id)" + <a class="btn btn-action btn-disable" + ng-confirm-message="Do you really want to delete this question ?" + ng-confirm-click="deleteQuestion(question.id)" ng-if="currentUser.role == 'SUPERVISOR' || currentUser.role == 'ADMIN'"> <span class="fa fa-close" aria-hidden="true"></span>Delete</a> </td> diff --git a/coselmar-ui/src/main/webapp/views/users/user.html b/coselmar-ui/src/main/webapp/views/users/user.html index eaa17f9..09d245d 100644 --- a/coselmar-ui/src/main/webapp/views/users/user.html +++ b/coselmar-ui/src/main/webapp/views/users/user.html @@ -57,7 +57,10 @@ </table> <div class="float-right"> <a class="btn btn-warning" ng-click="modifyUser()" ng-if="user.active">Modify</a> - <a class="btn btn-danger" ng-click="deleteUser(user.id)" ng-if="currentUser.role == 'ADMIN' && user.active">Delete</a> + <a class="btn btn-danger" + ng-confirm-message="Do you really want to disable this user ?" + ng-confirm-click="deleteUser(user.id)" + ng-if="currentUser.role == 'ADMIN' && user.active">Disable</a> </div> </div> diff --git a/coselmar-ui/src/main/webapp/views/users/users.html b/coselmar-ui/src/main/webapp/views/users/users.html index 1109e7d..ef909cd 100644 --- a/coselmar-ui/src/main/webapp/views/users/users.html +++ b/coselmar-ui/src/main/webapp/views/users/users.html @@ -71,7 +71,9 @@ <a class="btn btn-action btn-edit" href="#/users/{{user.id}}?edit"> <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>Modify </a> - <a class="btn btn-action btn-disable" ng-if="user.active" ng-click="deleteUser(user.id)"> + <a class="btn btn-action btn-disable" ng-if="user.active" + ng-confirm-message="Do you really want to disable this user ?" + ng-confirm-click="deleteUser(user.id)"> <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>Disable </a> <!--<a class="btn btn-primary" ng-if="!user.active" ng-click="enableUser(user.id)">Enable</a>--> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.