01/03: create visual of the form of the list of voter
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 540fb06316f948de73871234ba44403dd0440bf3 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jun 5 15:36:58 2014 +0200 create visual of the form of the list of voter --- pollen-ui-angular/src/main/webapp/css/style.css | 16 ++- pollen-ui-angular/src/main/webapp/i18n/en.js | 4 + pollen-ui-angular/src/main/webapp/i18n/fr.js | 4 + pollen-ui-angular/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/controllers/pollCtrl.js | 110 +++++++++++++++------ pollen-ui-angular/src/main/webapp/js/services.js | 30 +++++- .../main/webapp/partials/poll-listParticipant.html | 44 +++++++++ .../src/main/webapp/partials/poll.html | 3 + 8 files changed, 182 insertions(+), 31 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/css/style.css b/pollen-ui-angular/src/main/webapp/css/style.css index dcdd462..ce7e00d 100644 --- a/pollen-ui-angular/src/main/webapp/css/style.css +++ b/pollen-ui-angular/src/main/webapp/css/style.css @@ -216,7 +216,7 @@ i.icon-collapse { border-collapse:collapse; } -#comments tr td{ +#comments tr td { border-bottom:1px solid #DDD; padding-top:5px; padding-bottom:15px; @@ -234,3 +234,17 @@ i.icon-collapse { margin-bottom:15px; vertical-align:center; } + +.voterList { + width:100%; + margin-bottom:15px; + border:3px solid #DDD; +} + +.voterList tr th, .voterList tr td { + padding-top:8px; + padding-bottom:8px; + padding-left:5px; + padding-right:5px; + border:1px solid #DDD; +} \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index af7e51c..408dfa4 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -37,6 +37,7 @@ var translateEN = { 'poll.tab.create' : 'Create', 'poll.tab.edit' : 'Edit', 'poll.tab.conf' : 'Configuration', +'poll.tab.participant' : 'Participants', 'poll.link.edit' : 'Edit Url:', 'poll.link.vote' : 'Vote Url:', @@ -44,6 +45,9 @@ 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.restricted.name' : 'Name', +'poll.restricted.mail' : 'E-mail', +'poll.restricted.weight' : 'Weight', 'vote.added' : 'Vote added.', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index 481260d..bf09c53 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -37,6 +37,7 @@ var translateFR = { 'poll.tab.create' : 'Créer', 'poll.tab.edit' : 'Éditer', 'poll.tab.conf' : 'Configuration', +'poll.tab.participant' : 'Participants', 'poll.link.edit' : 'Lien d\'édition :', 'poll.link.vote' : 'Lien de partage pour le vote :', @@ -44,6 +45,9 @@ 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.restricted.name' : 'Nom du votant', +'poll.restricted.mail' : 'Courriel du votant', +'poll.restricted.weight' : 'Poids du votant', 'vote.added' : 'Vote effectué', diff --git a/pollen-ui-angular/src/main/webapp/index.html b/pollen-ui-angular/src/main/webapp/index.html index 0b6eb28..0d0106a 100644 --- a/pollen-ui-angular/src/main/webapp/index.html +++ b/pollen-ui-angular/src/main/webapp/index.html @@ -22,7 +22,7 @@ <html lang="en" ng-app="pollen"> <head> <title>Pollen</title> - <meta chaset="utf-8" /> + <meta charset="utf-8" /> <link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/> <link rel="stylesheet" href="css/style.css"/> 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 5998a76..9edfc3f 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -146,6 +146,66 @@ angular.module('pollControllers', []) $scope.tab = $scope.setTab('edit'); + $scope.globalVariables.editMode = true; + $scope.globalVariables.voted = angular.isDefined($scope.data.votants); + $scope.globalVariables.lastType = 'TEXT'; + $scope.globalVariables.lastDate = new Date(); + $scope.restError = {}; + + //////////////////////////////// + //// VOTER LIST ///// + //////////////////////////////// + var newMember = function () { + return {name:'', email:'', weight:1.0}; + } + + var newGroup = function () { + var members = []; + for (var j = 0; j < 3; j++) { + members.push(newMember()); + } + return {group:{name:'', weight:1.0}, members:members} + } + + $scope.data.voterList = []; + for (var i = 0; i < 3; i++) { + $scope.data.voterList.push(newGroup()); + } + + $scope.$watch('data.poll.pollType', function (newVal, oldVal) { + if (newVal != oldVal && newVal == 'RESTRICTED') { + var listMember = []; + for (var i = 0; i < $scope.data.voterList.length; i++) { + for (var j = 0; j < $scope.data.voterList[i].members.length; j++) { + // check if not a empty line + if ($scope.data.voterList[i].members[j].email != '' || $scope.data.voterList[i].members[j].name != '') { + listMember.push($scope.data.voterList[i].members[j]); + } + } + } + + // get the first group + $scope.data.voterList = $scope.data.voterList.splice(0,1); + + // check if one voter is enter in one group + if (listMember.length > 0) { + $scope.data.voterList[0].members = listMember; + } + } + }); + + $scope.addVoter = function (index) { + $scope.data.voterList[index].members.push(newMember()); + } + + $scope.addGroup = function () { + $scope.data.voterList.push(newGroup()); + } + + //////////////////////////////// + //// CHOICE ///// + //////////////////////////////// + var initChoice = function () { return { name: '', @@ -154,12 +214,6 @@ angular.module('pollControllers', []) }; } - $scope.globalVariables.editMode = true; - $scope.globalVariables.voted = angular.isDefined($scope.data.votants); - $scope.globalVariables.lastType = 'TEXT'; - $scope.globalVariables.lastDate = new Date(); - $scope.restError = {}; - $scope.addChoice = function () { var index = $scope.data.choices.push(initChoice()); var choice = $scope.data.choices[index-1]; @@ -247,7 +301,7 @@ angular.module('pollControllers', []) $scope.globalVariables.create = true; var initPoll = function () { - Poll.get({cmd:'new'}, function (poll) { + Poll.skeletonNew(function (poll) { $scope.data.poll = poll; $scope.data.choices = []; $scope.data.vote = {}; @@ -280,7 +334,8 @@ angular.module('pollControllers', []) }]) -.controller('PollEditCtrl', ['$scope', '$q', '$controller', '$routeParams', '$location', '$timeout', 'Poll', 'PollChoice', 'PollVote', function ($scope, $q, $controller, $routeParams, $location, $timeout, Poll, PollChoice, PollVote) { +.controller('PollEditCtrl', ['$scope', '$controller', '$routeParams', '$location', '$timeout', 'Poll', 'PollChoice', 'PollVote', 'PollVoterList', 'PollVoterListMember', + function ( $scope, $controller, $routeParams, $location, $timeout, Poll, PollChoice, PollVote, PollVoterList, PollVoterListMember) { $controller('PollAdminCtrl', {$scope:$scope}); $scope.globalVariables.edit = true; @@ -316,21 +371,34 @@ angular.module('pollControllers', []) }); } + var initVoterList = function () { + PollVoterList.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (voterList) { + if (voterList.length > 0) { + $scope.data.voterList = []; + angular.forEach(voterList, function (list) { + PollVoterListMember.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, voterListId: list.id}, function (voterListMember) { + $scope.data.voterList.push({group:list, members:voterListMember}); + }) + }) + } + }) + }; + var initPoll = function () { - var pollPromise = Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (poll) { + Poll.get({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}, function (poll) { if (angular.isUndefined(poll.permission)) { $location.path('/'); } $scope.data.poll = poll; - }).$promise; + }); - var choicesPromise = PollChoice.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}).$promise.then(function (choices) { + PollChoice.query({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission}).$promise.then(function (choices) { $scope.data.choices = choices; $scope.data.vote = {}; $scope.data.vote.choice = $scope.data.choices; - }).$promise; + }); - var votesPromise = PollVote.query({pollId:$routeParams.pollId}, function (votes) { + PollVote.query({pollId:$routeParams.pollId}, function (votes) { $scope.data.votants = votes; angular.forEach($scope.data.votants, function (vote) { angular.forEach(vote.choice, function (choice) { @@ -342,23 +410,9 @@ angular.module('pollControllers', []) } }) }) - }).$promise; - - $q.all([choicesPromise, votesPromise]).then(function () { - Poll.get({pollId:$routeParams.pollId, cmd:'results'}, function (result) { - $scope.data.result = result; - angular.forEach(result.scores, function(value, key) { - for (var i = 0; i < $scope.data.choices.length; i++) { - if ($scope.data.choices[i].id == value.choiceId) { - value.choice = $scope.data.choices[i]; - i = $scope.data.choices.length; - } - } - }) - $scope.data.result.nbVotant = $scope.data.votants.length; - }); }); + initVoterList(); } initPoll(); diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index 20679cf..e78438f 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -21,7 +21,11 @@ angular.module('pollenServices', ['ngResource']) .factory('Poll', ['$resource', function ($resource) { - return $resource(conf.restURL+'/polls/:pollId/:cmd', {pollId:'@id'}, { + return $resource(conf.restURL+'/polls/:pollId', {pollId:'@id'}, { + 'skeletonNew' : { + method : 'GET', + url : conf.restURL+'/polls/new' + }, 'add' : { method : 'POST', transformRequest : function (data, headersGetter) { @@ -112,6 +116,30 @@ angular.module('pollenServices', ['ngResource']) ); }]) +.factory('PollVoterList', ['$resource', function ($resource) { + var transformParam = function (data) { + return 'voterList='+encodeURIComponent(JSON.stringify(data.group))+'&members='+encodeURIComponent(JSON.stringify(data.members)); + }; + + return $resource(conf.restURL+'/polls/:pollId/voterLists/:voterListId', {voterListId: '@group.id'}, + { + 'add' : { + method : 'POST', + transformRequest: function (data, headersGetter) { + return transformParam(data); + } + }, + }) +}]) + +.factory('PollVoterListMember', ['$resource', function ($resource) { + return $resource(conf.restURL+'/polls/:pollId/voterLists/:voterListId/members/:memberId', {voterListId: '@group.id'}, + { + + }) +}]) + + .factory('User', ['$resource', function ($resource) { var transformParam = function (data) { return 'user='+encodeURIComponent(JSON.stringify(data))+'&generatePassword=false'; diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html new file mode 100644 index 0000000..3dae6e4 --- /dev/null +++ b/pollen-ui-angular/src/main/webapp/partials/poll-listParticipant.html @@ -0,0 +1,44 @@ +<h2 xmlns="http://www.w3.org/1999/html">Participant</h2> +<form> + type : + <label for="formFree"> + <input type="radio" ng-model="data.poll.pollType" name="type" value="FREE" id="formFree"/> + Free + </label> + <label for="formRestricted"> + <input type="radio" ng-model="data.poll.pollType" name="type" value="RESTRICTED" id="formRestricted" /> + Restricted + </label> + <label for="formGroup"> + <input type="radio" ng-model="data.poll.pollType" name="type" value="GROUP" id="formGroup" /> + Group + </label> + + <hr/> + + <table ng-repeat="voterList in data.voterList" class="voterList" ng-hide="data.poll.pollType == 'FREE'"> + <tr ng-show="data.poll.pollType == 'GROUP'"> + <th colspan="2"> <input type="text" name="group" placeholder="name group" ng-model="voterList.group.name" class="form-control" /></th> + <th> <input type="number" ng-model="voterList.group.weight" select-on-click class="form-control" /> </th> + </tr> + + <tr> + <th> {{ 'poll.restricted.name' | translate }} </th> + <th> {{ 'poll.restricted.mail' | translate }} </th> + <th> {{ 'poll.restricted.weight' | translate }} </th> + </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> + </tr> + + <tr> + <th colspan="3"> <a ng-click="addVoter($index);"> Add Voter </a> </th> + </tr> + </table> + + <button class="btn btn-info" ng-show="data.poll.pollType == 'GROUP'" ng-click="addGroup()">Add group</button> + +</form> diff --git a/pollen-ui-angular/src/main/webapp/partials/poll.html b/pollen-ui-angular/src/main/webapp/partials/poll.html index 9f17f2e..6efa89a 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll.html @@ -32,6 +32,7 @@ <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> </ul> <div ng-include="'partials/poll-link.html'" ng-if="tab == 'home'"></div> @@ -83,4 +84,6 @@ <div ng-include="'./partials/poll-result.html'" ng-if="tab == 'result'"></div> + <div ng-include="'./partials/poll-listParticipant.html'" ng-if="tab == 'participant'"></div> + </form> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm