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 a0b7bc28e7343bf1c5002d5b3d0090951cd96e58 Author: Yannick Martel <martel@©odelutin.com> Date: Tue Feb 17 16:16:28 2015 +0100 manage notification for documents --- coselmar-ui/src/main/webapp/i18n/en.js | 3 + coselmar-ui/src/main/webapp/i18n/fr.js | 3 + .../src/main/webapp/js/coselmar-controllers.js | 68 ++++++++++++++++------ .../src/main/webapp/js/coselmar-services.js | 12 ++-- 4 files changed, 61 insertions(+), 25 deletions(-) diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index d391cda..8a6e6d1 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -110,6 +110,9 @@ var translateEN = { "document.message.requiredSummary" : "A summary is required.", "document.privacy.questionRestricted" : "Restricted to Project participants", "document.privacy.restricted.info" : "Restricted to selected experts and to projects using document", +"document.message.created" : "Document well created.", +"document.message.updated" : "Document well modified.", +"document.message.deleted" : "Document well deleted.", "document.button.download" : "Download", "document.button.openLink" : "Open link", diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index f16d7b5..bff7778 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -110,6 +110,9 @@ var translateFR = { "document.message.requiredSummary" : "Un résumé est requis.", "document.privacy.questionRestricted" : "Restreint aux participants de projet.", "document.privacy.restricted.info" : "Restreint aux experts indiqués et aux projets incluant le document", +"document.message.created" : "Document créé.", +"document.message.updated" : "Document modifié.", +"document.message.deleted" : "Document supprimé.", "document.button.download" : "Télécharger", "document.button.openLink" : "Ouvrir le lien", diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 58949cc..2188170 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -124,7 +124,8 @@ coselmarControllers.controller("homeConnectedCtrl", ['$scope', 'questionsService ///////////////////////////////////////////////// // Controller for All Documents View -coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routeParams', '$location', 'documentService', function($scope, $route, $routeParams, $location, documentService){ +coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routeParams', '$location', 'notify', 'documentService', 'errorService', + function($scope, $route, $routeParams, $location, notify, documentService, errorService){ //manage keywords if given $scope.searchKeywords = []; @@ -137,27 +138,32 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara documentService.getDocuments($scope.searchKeywords, function(documents) { $scope.documents = documents; - }); + }, errorService.defaultFailOnCall); $scope.deleteDocument = function(documentId){ // Call service to create a new document documentService.deleteDocument(documentId, $scope, function() { + // Notification + notify({ + message: "document.message.deleted", + classes: "alert-warning", + templateUrl: "views/notificationTemplate.html" + }); // Go back to documents list $route.reload(); - }); + }, errorService.defaultFailOnCall); }; $scope.searchDocuments = function(){ -// $route.current.params.keywords = $scope.searchKeywords; -// $route.reload(); $location.search('keywords', $scope.searchKeywords); - } + }; }]); // Controller for new document View -coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'documentService', function($scope, $location, documentService){ +coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'notify', 'documentService', 'errorService', + function($scope, $location, notify, documentService, errorService){ $scope.document = {'type' : 'PERIODICAL_PUBLICATION', 'privacy': 'PUBLIC', 'keywords': [], 'authorizedUsers' : []}; $scope.upload = {}; @@ -217,15 +223,24 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'docum if ($scope.upload.file) { var documentId = document.id; documentService.saveDocumentFile(documentId, $scope.upload.file, function() { + // Notification + notify({ + message: "document.message.created", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $location.path("/documents"); }); } else { + // Notification + notify({ + message: "document.message.created", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $location.path("/documents"); } - }, function(error) { - console.log("error occurs"); - } - ); + }, errorService.defaultFailOnCall); } @@ -253,8 +268,8 @@ coselmarControllers.controller("NewDocumentCtrl", ['$scope', '$location', 'docum // Controller for single document View coselmarControllers.controller("DocumentViewCtrl", - ['$scope', '$route', '$location', 'documentService', '$routeParams', 'coselmar-config', - function($scope, $route, $location, documentService, $routeParams, coselmarConfig) { + ['$scope', '$route', '$location', '$routeParams', 'coselmar-config', 'notify', 'documentService', 'errorService', + function($scope, $route, $location, $routeParams, coselmarConfig, notify, documentService, errorService) { $scope.container = {baseUrl : coselmarConfig.BASE_URL}; $scope.upload = {}; @@ -274,15 +289,21 @@ coselmarControllers.controller("DocumentViewCtrl", $scope.users = document.authorizedUsers; bindUsers($scope.document.authorizedUsers, $scope.usersIndex); } - }); + }, errorService.defaultFailOnCall); $scope.deleteDocument = function(documentId){ // Call service to create a new document documentService.deleteDocument(documentId, $scope, function() { + // Notification + notify({ + message: "document.message.deleted", + classes: "alert-warning", + templateUrl: "views/notificationTemplate.html" + }); // Go back to documents list $location.path("/documents"); - }); + }, errorService.defaultFailOnCall); }; @@ -341,15 +362,24 @@ coselmarControllers.controller("DocumentViewCtrl", if ($scope.upload.file) { var documentId = $scope.document.id; documentService.saveDocumentFile(documentId, $scope.upload.file, function() { + // Notification + notify({ + message: "document.message.updated", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $location.search(""); }); } else { + // Notification + notify({ + message: "document.message.updated", + classes: "alert-success", + templateUrl: "views/notificationTemplate.html" + }); $location.search(""); } - }, function(error) { - console.log("error occurs"); - } - ); + }, errorService.defaultFailOnCall); } else { $scope.hasErrors = true; diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 815cfc0..0dc895b 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -92,17 +92,17 @@ function Document(resource, config){ docResource.upload(null, formData, successFunction, failFunction); }; - this.getDocument = function(id, successFunction){ + this.getDocument = function(id, successFunction, failFunction){ // Load the document var docResource = resource(baseURL + '/:documentId', {documentId:'@documentId'}); - docResource.get({documentId:id}, successFunction); + docResource.get({documentId:id}, successFunction, failFunction); }; - this.deleteDocument = function(id, scope, successFunction){ + this.deleteDocument = function(id, scope, successFunction, failFunction){ // Load the document var docResource = resource(baseURL + '/:documentId', {documentId:'@id'}); - docResource.delete({documentId:id}, successFunction); + docResource.delete({documentId:id}, successFunction, failFunction); }; this.getDocumentFile = function(id, scope){ @@ -113,11 +113,11 @@ function Document(resource, config){ }); }; - this.getDocuments = function(searchKeywords, successFunction){ + this.getDocuments = function(searchKeywords, successFunction, failFunction){ // Load all documents var docResource = resource(baseURL, {searchKeywords : searchKeywords}); - docResource.query(successFunction); + docResource.query(successFunction, failFunction); }; this.findAllTypes = function(successFunction){ -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.