01/01: no reload all voterList when import, fix pagination number in favoriteListMember, Add field defaultAlertTimeSuccess and defaultAlertTimeError in conf.js fix default conf for pagination number => not mandatory in conf.js
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit c455900f6d3bc9b30081d6aa0268b38c3dd335f0 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Jun 24 14:47:25 2014 +0200 no reload all voterList when import, fix pagination number in favoriteListMember, Add field defaultAlertTimeSuccess and defaultAlertTimeError in conf.js fix default conf for pagination number => not mandatory in conf.js --- pollen-ui-angular/src/main/webapp/i18n/en.js | 5 ++ pollen-ui-angular/src/main/webapp/i18n/fr.js | 3 + .../src/main/webapp/js/conf.js.exemple | 8 +++ .../src/main/webapp/js/controllers/alertCtrl.js | 14 ++++- .../main/webapp/js/controllers/favoriteListCtrl.js | 8 ++- .../src/main/webapp/js/controllers/pollCtrl.js | 73 ++++++++++++++-------- .../src/main/webapp/js/controllers/userCtrl.js | 8 +-- .../src/main/webapp/partials/poll-list.html | 2 - .../main/webapp/partials/poll-listParticipant.html | 2 +- 9 files changed, 86 insertions(+), 37 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 164d011..a6264ca 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -33,6 +33,8 @@ var translateEN = { 'user.error.mail.notFound' : 'E-mail not found', 'user.error.mail.empty' : 'E-mail can not be empty', 'user.error.login' : 'Error in e-mail or password', +'user.error.login.mandatory' : 'You must be connected', +'user.error.logout.mandatory' : 'You must be disconnected', 'poll.tab.vote' : 'Vote', 'poll.tab.comment' : 'Comment', @@ -48,6 +50,7 @@ var translateEN = { 'poll.edit' : 'Click to edit', 'poll.desc' : 'Description is optional. This message will not visible in vote page.', 'poll.saved' : 'Poll saved.', +'poll.deleted' : 'Poll deleted', 'poll.restricted.name' : 'Name', 'poll.restricted.mail' : 'E-mail', 'poll.restricted.weight' : 'Weight', @@ -88,5 +91,7 @@ var translateEN = { 'dateFormat' : 'MM-dd-yy', +'error.forbidden' : 'Access forbidden', + } diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index e624020..e0ffabb 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -50,6 +50,7 @@ var translateFR = { 'poll.edit' : 'Clique pour éditer', 'poll.desc' : 'Description (Facultatif). Ce cadre disparait si aucune description n\'est mise', 'poll.saved' : 'Sondage sauvegardé', +'poll.deleted' : 'Sondage supprimé', 'poll.restricted.name' : 'Nom du votant', 'poll.restricted.mail' : 'Courriel du votant', 'poll.restricted.weight' : 'Poids', @@ -91,5 +92,7 @@ var translateFR = { 'dateFormat' : 'dd/MM/yyyy', +'error.forbidden' : 'Accès interdit', + } diff --git a/pollen-ui-angular/src/main/webapp/js/conf.js.exemple b/pollen-ui-angular/src/main/webapp/js/conf.js.exemple index 4602e9a..6fa3b5e 100644 --- a/pollen-ui-angular/src/main/webapp/js/conf.js.exemple +++ b/pollen-ui-angular/src/main/webapp/js/conf.js.exemple @@ -16,4 +16,12 @@ var conf = { // Default Language for i18n : 'en' or 'fr' defaultLanguage: 'en', + + // Time in ms to print alert success + // -1 for infinite time, click or reload for close alert + defaultAlertTimeSuccess: 2000, // 2s + + // Time in ms to print alert error + // -1 for infinite time, click or reload for close alert + defaultAlertTimeError: -1, // infinite } \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/alertCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/alertCtrl.js index 7d798c0..f2be73d 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/alertCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/alertCtrl.js @@ -30,17 +30,25 @@ angular.module('alertControllers', []) $scope.$on('newError', function (event, error, timeout) { var alert = {msg:error, type:'danger'}; - addAlert(alert, timeout); + if (angular.isDefined(timeout)) { + addAlert(alert, timeout); + } else { + addAlert(alert, conf.defaultAlertTimeError); + } }); $scope.$on('newSuccess', function (event, success, timeout) { var alert = {msg:success, type:'success'}; - addAlert(alert, timeout); + if (angular.isDefined(timeout)) { + addAlert(alert, timeout); + } else { + addAlert(alert, conf.defaultAlertTimeSuccess); + } }); var addAlert = function (alert, timeout) { $scope.data.alerts.push(alert); - if (angular.isDefined(timeout)) { + if (angular.isDefined(timeout) && timeout >= 0) { $timeout(function () { $scope.hideAlert(alert) }, timeout); diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js index 655996f..b531a7a 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js @@ -24,6 +24,9 @@ angular.module('favoriteListControllers', []) $scope.data = {}; var paginationParameter = {pageSize: conf.favoriteListDefaultPageSize}; + if (angular.isUndefined(paginationParameter.pageSize)) { + paginationParameter.pageSize = -1; + } if (angular.isDefined($routeParams.page)) { if (angular.isDefined($routeParams.pageSize)) { paginationParameter = {pageSize:$routeParams.pageSize}; @@ -53,7 +56,10 @@ angular.module('favoriteListControllers', []) function ($scope, FavoriteList, FavoriteListMember, $translate, $routeParams, $timeout, $q, $location, $route) { $scope.data = {}; - var paginationParameter = {pageSize: conf.favoriteListDefaultPageSize}; + var paginationParameter = {pageSize: conf.favoriteListMemberDefaultPageSize}; + if (angular.isUndefined(paginationParameter.pageSize)) { + paginationParameter.pageSize = -1; + } if (angular.isDefined($routeParams.page)) { if (angular.isDefined($routeParams.pageSize)) { paginationParameter = {pageSize:$routeParams.pageSize}; diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index ba0865e..b2e399e 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -349,7 +349,7 @@ angular.module('pollControllers', []) } Poll.add(poll, function (data) { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); if ($scope.data.poll.pollType != 'FREE') { SessionStorage.save({'voterList':$scope.data.voterList}) $location.url('/poll/edit/'+data.id+'?token='+data.permission); @@ -392,7 +392,7 @@ angular.module('pollControllers', []) PollChoice.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, choice, function (data) { delete choice.restError; choice.id = data.id; - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); }, function (error) { choice.restError = error.data; }); @@ -401,7 +401,7 @@ angular.module('pollControllers', []) $scope.callBackEditChoice = function (choice) { PollChoice.update({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, choice, function() { delete choice.restError; - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); }, function (error) { choice.restError = error.data; }); @@ -409,7 +409,7 @@ angular.module('pollControllers', []) $scope.deleteChoice = function (choice) { PollChoice.remove({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, choiceId: choice.id}, function () { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); var index = $scope.data.choices.indexOf(choice); if (index > -1) { $scope.data.choices.splice(index,1); @@ -483,24 +483,33 @@ angular.module('pollControllers', []) } }; initFavoriteList(); - $scope.importFavoriteList = function (voterListId) { - if (angular.isDefined(voterListId)) { - PollVoterList.importInGroup({pollId:$routeParams.pollId, voterListId:voterListId, favoriteListId:$scope.data.favoriteListImport}, null, function (data) { - $scope.data.favoriteListImport = null; - initVoterList(); - }); + $scope.importFavoriteList = function (voterList) { + var pollVoterListPromise; + if (angular.isDefined(voterList.group.id)) { + pollVoterListPromise = PollVoterList.importInGroup({pollId:$routeParams.pollId, voterListId:voterList.group.id, favoriteListId:$scope.data.favoriteListImport}, null).$promise; } else { - PollVoterList.importAddGroup({pollId:$routeParams.pollId, favoriteListId:$scope.data.favoriteListImport}, null, function (data) { - $scope.data.favoriteListImport = null; - initVoterList(); - }) + pollVoterListPromise = PollVoterList.importAddGroup({pollId:$routeParams.pollId, favoriteListId:$scope.data.favoriteListImport}, null).$promise; } + + pollVoterListPromise.then(function (data) { + $scope.data.favoriteListImport = null; + PollVoterList.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, voterListId: data.id}, + function (vl) { + voterList.group = vl; + PollVoterListMember.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, voterListId: vl.id}, + function(members) { + voterList.members = members; + } + ); + } + ); + }); }; $scope.saveVoterList = function (voterList) { if (angular.isDefined(voterList.group.id)) { PollVoterList.update({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, voterListId:voterList.group.id}, voterList.group, function (data) { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); delete voterList.group.restError; }, function (error) { voterList.group.restError = error.data; @@ -519,7 +528,7 @@ angular.module('pollControllers', []) }); if (vl.members.length > 0) { PollVoterList.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, vl, function (data) { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); voterList.group.id = data.id; delete voterList.group.restError; @@ -577,7 +586,7 @@ angular.module('pollControllers', []) } vlMemberPromise.then(function (data) { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); member.id = data.id; delete member.restError; }, function (error) { @@ -694,7 +703,7 @@ angular.module('pollControllers', []) } $scope.data.poll.$update({permission:$scope.globalVariables.permission}, function (data) { - $rootScope.$broadcast('newSuccess', 'poll.saved', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'poll.saved'); }, function (error) { angular.extend($scope.restError, error.data); }); @@ -708,6 +717,7 @@ angular.module('pollControllers', []) var confirmDelete = confirm(confirmMessage); if (confirmDelete == true) { $scope.data.poll.$remove({permission:$scope.globalVariables.permission}, function() { + $rootScope.$broadcast('newSuccess', 'poll.deleted'); $location.path('/'); }); } @@ -778,7 +788,7 @@ angular.module('pollControllers', []) if (angular.isDefined($scope.data.vote.id)) { // edit vote PollVote.update({pollId:$routeParams.pollId}, sendVote, function (data) { - $rootScope.$broadcast('newSuccess', 'vote.added', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'vote.added'); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; }) @@ -790,7 +800,7 @@ angular.module('pollControllers', []) $scope.data.vote.permission = returnRequest.permission; $scope.data.votants.push(angular.copy($scope.data.vote)); - $rootScope.$broadcast('newSuccess', 'vote.added', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'vote.added'); initVote(); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; @@ -846,7 +856,12 @@ angular.module('pollControllers', []) } }; initAuthor(); - $scope.pageSize = conf.commentDefaultPageSize; + if (angular.isDefined(conf.pollDefaultPageSize)) { + $scope.pageSize = conf.pollDefaultPageSize; + } + else { + $scope.pageSize = -1; + } $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); var paginationParameter = {pageSize:$scope.pageSize, order:'postDate', desc:true}; @@ -912,7 +927,7 @@ angular.module('pollControllers', []) } commentPromise.then(function () { - $rootScope.$broadcast('newSuccess', 'comment.added', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'comment.added'); //clean form $scope.comment.text = ''; delete $scope.comment.postDate; @@ -1013,11 +1028,16 @@ angular.module('pollControllers', []) }]) .controller('PollListCtrl', - ['$scope', '$controller', '$routeParams', 'Poll', - function ($scope, $controller, $routeParams, Poll) { + ['$scope', '$rootScope', '$controller', '$routeParams', '$location', 'Poll', + function ($scope, $rootScope, $controller, $routeParams, $location, Poll) { $controller('PollCtrl', {$scope:$scope}); - $scope.pageSize = conf.pollDefaultPageSize; + if (angular.isDefined(conf.pollDefaultPageSize)) { + $scope.pageSize = conf.pollDefaultPageSize; + } + else { + $scope.pageSize = -1; + } $scope.urlPagination = $scope.setUrl(['page', 'pageSize']); var paginationParameter = {pageSize:$scope.pageSize}; @@ -1035,7 +1055,8 @@ angular.module('pollControllers', []) $scope.data.polls = data.elements $scope.data.pollsPagination = data.pagination; }, function (error) { - $scope.restError = {forbidden:true}; + $rootScope.$broadcast('newError', 'error.forbidden'); + $location.url('/'); }); }; initPolls(); diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js index cb4104e..20b38da 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -35,7 +35,7 @@ $scope.submit = function () { if ($scope.data.user.password == $scope.data.user.password2) { User.add({}, $scope.data.user, function (data) { - $rootScope.$broadcast('newSuccess', 'user.register.success', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'user.register.success'); $scope.data.user = {email:'', password:'', password2:''}; }, function (error) { $scope.restError = error.data; @@ -55,7 +55,7 @@ $scope.submit = function () { if ($scope.email != '') { UserLostPassword.send({login:$scope.email}, function (data) { - $rootScope.$broadcast('newSuccess', 'user.forgotPassword.success', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'user.forgotPassword.success'); $scope.email = ''; }, function (error) { $translate('user.error.mail.notFound').then(function (error) { @@ -86,7 +86,7 @@ $scope.editUser = function () { User.update($scope.currentUser, function (data) { SessionStorage.save({user:data}); - $rootScope.$broadcast('newSuccess', 'user.edit.success', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'user.edit.success'); }, function (error) { $scope.restError = error.data; }); @@ -96,7 +96,7 @@ if ($scope.currentUser.newPassword == $scope.currentUser.newPassword2) { User.editPassword($scope.currentUser, function (data) { SessionStorage.save({user:data}); - $rootScope.$broadcast('newSuccess', 'user.edit.success', conf.defaultTimeSuccessSave); + $rootScope.$broadcast('newSuccess', 'user.edit.success'); }, function (error) { $scope.restError = error.data; }); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-list.html b/pollen-ui-angular/src/main/webapp/partials/poll-list.html index 0d9c69c..e036126 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-list.html @@ -1,6 +1,4 @@ -<alert type="danger" ng-if="restError.forbidden">Accès interdit</alert> - <div ng-repeat="poll in data.polls"> <h2><a href="#/poll/vote/{{poll.id}}">{{poll.title}}</a> <a href="#/poll/edit/{{poll.id}}"><i class="glyphicon glyphicon-pencil"></i></a></h2> <p ng-bind-html="toHTML(poll.description)"></p> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html index a60cb46..8007aa3 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html @@ -91,7 +91,7 @@ <th colspan="4"> <button class="btn btn-info" ng-click="addVoter($index);"> <span class="glyphicon glyphicon-plus"></span> {{ 'action.restricted.addVoter' | translate }} </button> <button class="btn btn-danger" ng-click="deleteVoterList(voterList);"> <span class="glyphicon glyphicon-trash"></span> {{ 'action.restricted.deleteGroup' | translate }} </button> - <button class="btn btn-info" ng-click="importFavoriteList(voterList.group.id)" ng-if="data.favoriteList"><span class="glyphicon glyphicon-plus"></span> {{ 'action.favoriteList.import.inGroup' | translate }}</button> + <button class="btn btn-info" ng-click="importFavoriteList(voterList)" ng-if="data.favoriteList"><span class="glyphicon glyphicon-plus"></span> {{ 'action.favoriteList.import.inGroup' | translate }}</button> </th> </tr> </table> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm