02/03: No reload controller if change page go to the same controller. Send voterList when create poll in pollType != 'FREE' Change URL tab for config and voterList
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 0fd39bd676c54444888f6774f32a4ec4d6bff20c Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Fri Jun 6 10:09:50 2014 +0200 No reload controller if change page go to the same controller. Send voterList when create poll in pollType != 'FREE' Change URL tab for config and voterList --- pollen-ui-angular/src/main/webapp/i18n/en.js | 5 ++ pollen-ui-angular/src/main/webapp/i18n/fr.js | 5 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 82 ++++++++++++++++------ .../main/webapp/partials/poll-listParticipant.html | 23 +++--- .../src/main/webapp/partials/poll.html | 8 +-- 5 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 408dfa4..39d30a4 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -48,6 +48,10 @@ var translateEN = { 'poll.restricted.name' : 'Name', 'poll.restricted.mail' : 'E-mail', 'poll.restricted.weight' : 'Weight', +'poll.restricted.free' : 'Free', +'poll.restricted.restricted' : 'Restricted', +'poll.restricted.group' : 'Group', +'poll.restricted.pollType' : 'Who can vote ?', 'vote.added' : 'Vote added.', @@ -61,6 +65,7 @@ var translateEN = { 'action.recovered' : 'Recovered', 'action.send' : 'Send', 'action.return' : 'Return', +'action.cancel' : 'Cancel', 'action.save' : 'Save', 'action.delete' : 'Delete', 'action.vote' : 'Vote', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index bf09c53..7dc335c 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -48,6 +48,10 @@ var translateFR = { 'poll.restricted.name' : 'Nom du votant', 'poll.restricted.mail' : 'Courriel du votant', 'poll.restricted.weight' : 'Poids du votant', +'poll.restricted.free' : 'Libre', +'poll.restricted.restricted' : 'Restreint', +'poll.restricted.group' : 'Groupe', +'poll.restricted.pollType' : 'Qui peut voter ?', 'vote.added' : 'Vote effectué', @@ -60,6 +64,7 @@ var translateFR = { 'action.recovered' : 'Récupéré', 'action.send' : 'Envoyé', 'action.return' : 'Retour', +'action.cancel' : 'Annuler', 'action.save' : 'Sauvegarder', 'action.delete' : 'Supprimer', 'action.vote' : 'Voter', 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 9edfc3f..ef63980 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -104,8 +104,14 @@ angular.module('pollControllers', []) $scope.globalVariables.linkResult += '#/poll/result/'+$routeParams.pollId; if (angular.isDefined($scope.globalVariables.permission)) { - $scope.globalVariables.linkEdit += '?token='+$scope.globalVariables.permission; - $scope.globalVariables.linkResult += '?token='+$scope.globalVariables.permission; + $scope.globalVariables.linkEdit += 'token='+$scope.globalVariables.permission; + $scope.globalVariables.linkResult += 'token='+$scope.globalVariables.permission; + $scope.globalVariables.linkConf = '#/poll/edit/'+$routeParams.pollId+'&tab=conf'; + $scope.globalVariables.linkParticipant = '#/poll/edit/'+$routeParams.pollId+'&tab=participant'; + } + else { + $scope.globalVariables.linkConf = '#/poll/edit/'+$routeParams.pollId+'?tab=conf'; + $scope.globalVariables.linkParticipant = '#/poll/edit/'+$routeParams.pollId+'?tab=participant'; } } @@ -141,7 +147,7 @@ angular.module('pollControllers', []) }]) -.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$timeout', '$routeParams', function ($scope, $controller, $modal, $timeout, $routeParams) { +.controller('PollAdminCtrl', ['$scope', '$controller', '$modal', '$timeout', '$routeParams', '$route', function ($scope, $controller, $modal, $timeout, $routeParams, $route) { $controller('PollCtrl', {$scope:$scope}); $scope.tab = $scope.setTab('edit'); @@ -152,9 +158,18 @@ angular.module('pollControllers', []) $scope.globalVariables.lastDate = new Date(); $scope.restError = {}; + + var lastRoute = $route.current; + $scope.$on('$locationChangeSuccess', function(event) { + if (lastRoute.$$route.controller == $route.current.$$route.controller) { + $route.current = lastRoute; + } + }); + //////////////////////////////// //// VOTER LIST ///// //////////////////////////////// + var newMember = function () { return {name:'', email:'', weight:1.0}; } @@ -168,9 +183,7 @@ angular.module('pollControllers', []) } $scope.data.voterList = []; - for (var i = 0; i < 3; i++) { - $scope.data.voterList.push(newGroup()); - } + $scope.data.voterList.push(newGroup()); $scope.$watch('data.poll.pollType', function (newVal, oldVal) { if (newVal != oldVal && newVal == 'RESTRICTED') { @@ -192,6 +205,9 @@ angular.module('pollControllers', []) $scope.data.voterList[0].members = listMember; } } + else if (newVal != oldVal && newVal == 'GROUP') { + $scope.addGroup(); + } }); $scope.addVoter = function (index) { @@ -295,7 +311,8 @@ angular.module('pollControllers', []) } }]) -.controller('PollCreateCtrl', ['$scope', '$controller', '$location', 'Poll', 'SessionStorage', function ($scope, $controller, $location, Poll, SessionStorage) { +.controller('PollCreateCtrl', ['$scope', '$controller', '$location', 'Poll', 'SessionStorage', 'PollVoterList', + function ( $scope, $controller, $location, Poll, SessionStorage, PollVoterList) { $controller('PollAdminCtrl', {$scope:$scope}); $scope.globalVariables.create = true; @@ -316,7 +333,14 @@ angular.module('pollControllers', []) poll.choice = angular.copy($scope.data.choices); Poll.add(poll, function (data) { SessionStorage.save({saved: true}); - $location.url('/poll/edit/'+data.id+'?token='+data.permission); + if ($scope.data.poll.pollType != 'FREE') { + PollVoterList.add({pollId:data.id, permission:data.permission}, $scope.data.voterList[0], function (dataVoterList) { + $location.url('/poll/edit/'+data.id+'?token='+data.permission); + }) + } + else { + $location.url('/poll/edit/'+data.id+'?token='+data.permission); + } }, function (error) { $scope.globalVariables.restError = true; $scope.restError = error.data; @@ -340,10 +364,14 @@ angular.module('pollControllers', []) $scope.globalVariables.edit = true; + //////////////////////////////// + //// CHOICE ///// + //////////////////////////////// + $scope.callBackAddChoice = function (choice) { PollChoice.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, choice, function (data) { delete choice.restError; - choice.topiaId = data.topiaId; + choice.id = data.id; $scope.globalVariables.saved = true; }, function (error) { choice.restError = error.data; @@ -369,8 +397,23 @@ angular.module('pollControllers', []) }, function (error) { angular.extend($scope.restError, error.data); }); + }; + + $scope.saveChoice = function (choice) { + if (angular.isDefined(choice)) { + if (angular.isDefined(choice.id) && choice.id != null) { + $scope.callBackEditChoice(choice); + } + else { + $scope.callBackAddChoice(choice); + } + } } + //////////////////////////////// + //// VOTER LIST ///// + //////////////////////////////// + var initVoterList = function () { PollVoterList.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (voterList) { if (voterList.length > 0) { @@ -384,6 +427,14 @@ angular.module('pollControllers', []) }) }; + $scope.saveVoterList = function (member) { + console.log(member); + } + + //////////////////////////////// + //// INIT POLL ///// + //////////////////////////////// + var initPoll = function () { Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (poll) { if (angular.isUndefined(poll.permission)) { @@ -411,7 +462,6 @@ angular.module('pollControllers', []) }) }) }); - initVoterList(); } initPoll(); @@ -424,17 +474,6 @@ angular.module('pollControllers', []) }); } - $scope.saveChoice = function (choice) { - if (angular.isDefined(choice)) { - if (angular.isDefined(choice.topiaId) && choice.topiaId != null) { - $scope.callBackEditChoice(choice); - } - else { - $scope.callBackAddChoice(choice); - } - } - } - $scope.deletePoll = function () { $scope.data.poll.$remove({permission:$scope.globalVariables.permission}, function() { $location.path('/'); @@ -545,7 +584,6 @@ angular.module('pollControllers', []) var initComments = function () { if (angular.isUndefined(paginationParameter.pageNumber) || paginationParameter.pageNumber != $scope.data.commentsPagination.pageNumber) { - console.log(paginationParameter); PollComment.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, paginationParameter:paginationParameter}, function (data) { $scope.data.comments = data.elements; $scope.data.commentsPagination = data.pagination; 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 3dae6e4..81185c7 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html @@ -1,17 +1,18 @@ -<h2 xmlns="http://www.w3.org/1999/html">Participant</h2> +{{ data.voterList }} + +<h2>{{ 'poll.restricted.pollType' | translate }}</h2> <form> - type : <label for="formFree"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="FREE" id="formFree"/> - Free + <input type="radio" ng-model="data.poll.pollType" name="type" value="FREE" id="formFree" auto-save="savePoll()"/> + {{ 'poll.restricted.free' | translate }} </label> <label for="formRestricted"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="RESTRICTED" id="formRestricted" /> - Restricted + <input type="radio" ng-model="data.poll.pollType" name="type" value="RESTRICTED" id="formRestricted" auto-save="savePoll()"/> + {{ 'poll.restricted.restricted' | translate }} </label> <label for="formGroup"> - <input type="radio" ng-model="data.poll.pollType" name="type" value="GROUP" id="formGroup" /> - Group + <input type="radio" ng-model="data.poll.pollType" name="type" value="GROUP" id="formGroup" auto-save="savePoll()"/> + {{ 'poll.restricted.group' | translate }} </label> <hr/> @@ -29,9 +30,9 @@ </tr> <tr ng-repeat="member in voterList.members"> - <td> <div ng-class="{'has-error':member.name == ''}"><input type="text" ng-model="member.name" class="form-control" /></div></td> - <td> <div ng-class="{'has-error':member.email == ''}"><input type="text" ng-model="member.email" class="form-control" /></div></td> - <td> <input type="number" ng-model="member.weight" select-on-click class="form-control"/></td> + <td> <div ng-class="{'has-error':member.name == ''}"><input type="text" ng-model="member.name" class="form-control" auto-save="saveVoterList(member)"/></div></td> + <td> <div ng-class="{'has-error':member.email == ''}"><input type="text" ng-model="member.email" class="form-control" auto-save="saveVoterList(member)" /></div></td> + <td> <input type="number" ng-model="member.weight" select-on-click class="form-control" auto-save="saveVoterList(member)"/></td> </tr> <tr> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 6efa89a..047c09b 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -29,10 +29,10 @@ <li ng-class="{active: tab == 'vote'}" ng-show="data.poll.id"><a href="{{globalVariables.linkVote}}">{{ 'poll.tab.vote' | translate }}</a></li> <li ng-class="{active: tab == 'comment'}" ng-show="data.poll.id"><a href="{{globalVariables.linkComment}}">{{ 'poll.tab.comment' | translate }}</a></li> <li ng-class="{active: tab == 'result'}" ng-show="!globalVariables.create"><a href="{{globalVariables.linkResult}}">{{ 'poll.tab.result' | translate }}</a></li> - <li ng-class="{active: tab == 'edit'}" ng-show="globalVariables.create"><a href="#/poll/create">{{ 'poll.tab.create' | translate }}</a></li> - <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}">{{ 'poll.tab.edit' | translate }}</a></li> - <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{urlTab}}tab=conf">{{ 'poll.tab.conf' | translate }}</a></li> - <li ng-class="{active: tab == 'participant'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{urlTab}}tab=participant">{{ 'poll.tab.participant' | translate }}</a></li> + <li ng-class="{active: tab == 'edit'}" ng-show="globalVariables.create"><a href="#/poll/create" ng-click="tab = 'edit'">{{ 'poll.tab.create' | translate }}</a></li> + <li ng-class="{active: tab == 'edit'}" ng-show="data.poll.permission"><a href="{{globalVariables.linkEdit}}" ng-click="tab = 'edit'">{{ 'poll.tab.edit' | translate }}</a></li> + <li ng-class="{active: tab == 'conf'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{globalVariables.linkConf || '#/poll/create?tab=conf'}}" ng-click="tab = 'conf'">{{ 'poll.tab.conf' | translate }}</a></li> + <li ng-class="{active: tab == 'participant'}" ng-show="data.poll.permission || globalVariables.create"><a href="{{globalVariables.linkParticipant || '#/poll/create?tab=participant'}}" ng-click="tab = 'participant'">{{ 'poll.tab.participant' | translate }}</a></li> </ul> <div ng-include="'partials/poll-link.html'" ng-if="tab == 'home'"></div> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm