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 47e45a86625c3048069e3baf59da74186e3f6001 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 24 15:57:48 2014 +0200 edit list of poll - select one or more poll - delete selected poll --- .../pollen/services/service/PollService.java | 2 - pollen-ui-angular/src/main/webapp/i18n/en.js | 9 ++- pollen-ui-angular/src/main/webapp/i18n/fr.js | 5 ++ .../src/main/webapp/js/controllers/pollCtrl.js | 71 +++++++++++++++++++++- .../src/main/webapp/partials/poll-list.html | 26 ++++++-- .../src/main/webapp/partials/poll-poll.html | 4 +- 6 files changed, 103 insertions(+), 14 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index 77baf7e..ed55a43 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -205,8 +205,6 @@ public class PollService extends PollenServiceSupport { getPollDao().delete(poll); - //TODO agarandel 18/07/14 : Check resource without choice - commit(); getNotificationService().onPollDeleted(poll); diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 8ba71b5..a2d676d 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -42,6 +42,7 @@ var translateEN = { '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', +'user.error.listEmpty' : 'No user found', 'poll.tab.vote' : 'Vote', 'poll.tab.comment' : 'Comment', @@ -75,8 +76,8 @@ var translateEN = { 'poll.result.choice' : 'Choice', 'poll.result.score' : 'Score', 'poll.result.title.zero' : 'No result', -'poll.result.title.one' : 'Result : One voter', -'poll.result.title.other' : 'Result : {{nbVoter}} Voters', +'poll.result.title.one' : 'Result : One voter', +'poll.result.title.other' : 'Result : {{nbVoter}} Voters', 'poll.config.title.poll' : 'Global config', 'poll.config.title.choice' : 'Choice config', 'poll.config.title.vote' : 'Vote config', @@ -131,6 +132,10 @@ var translateEN = { 'action.favoriteList.delete' : 'Delete the favorite list', 'action.favoriteList.addMember' : 'Add a member', 'action.favoriteList.deleteMember' : 'Delete the member', +'action.selectAll' : 'Select All', +'action.unselectAll' : 'Unselect All', +'action.toggleSelectAll' : 'Toggle the select', +'action.deleteSelected' : 'Delete the selected', 'action.message.confirmDelete' : 'Are you sure to delete it?', 'action.message.confirmClose' : 'Are you sure to close it?', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index fb3ff29..8336198 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -42,6 +42,7 @@ var translateFR = { 'user.error.login' : 'Erreur sur le nom d\'utilisateur ou le mot de passe', 'user.error.login.mandatory' : 'Accès refusé, vous devez êtes connecté(e)', 'user.error.logout.mandatory' : 'Accès refusé, vous êtes connecté(e)', +'user.error.listEmpty' : 'Aucun utilisateur trouvé', 'poll.tab.vote' : 'Voter', 'poll.tab.comment' : 'Commenter', @@ -131,6 +132,10 @@ var translateFR = { 'action.favoriteList.delete' : 'Supprimer la liste de diffusion', 'action.favoriteList.addMember' : 'Ajouter un membre', 'action.favoriteList.deleteMember' : 'Supprimer le membre', +'action.selectAll' : 'Sélectionner tous', +'action.unselectAll' : 'Déselectionner tous', +'action.toggleSelectAll' : 'Inverser la sélection', +'action.deleteSelected' : 'Supprimer la sélection', 'action.message.confirmDelete' : 'Êtes vous sûr de vouloir le supprimer?', 'action.message.confirmClose' : 'Êtes vous sûr de vouloir le fermer?', 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 8b66601..bd7ef2b 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -1386,9 +1386,59 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr }]) .controller('PollListCtrl', - ['$scope', '$rootScope', '$controller', '$routeParams', '$timeout', '$location', 'Poll', 'Page', - function ($scope, $rootScope, $controller, $routeParams, $timeout, $location, Poll, Page) { + ['$scope', '$rootScope', '$controller', '$routeParams', '$timeout', '$location', '$sce', '$q', 'Poll', 'Page', + function ($scope, $rootScope, $controller, $routeParams, $timeout, $location, $sce, $q, Poll, Page) { $scope.data = {}; + $scope.globalVariables = {}; + + $scope.toHTML = function (data) { + return $sce.trustAsHtml(data); + } + + $scope.toggleSelect = function (poll, event) { + if (angular.isUndefined(poll.selected)) { + poll.selected = true; + } + else { + poll.selected = !poll.selected; + } + + if (angular.isDefined(event)) { + event.stopPropagation(); + } + } + + $scope.selectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + poll.selected = true; + }) + }; + + $scope.unselectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + poll.selected = false; + }) + }; + + $scope.toggleSelectAll = function () { + angular.forEach($scope.data.polls, function (poll) { + $scope.toggleSelect(poll); + }) + }; + + $scope.deleteSelected = function () { + var deferred = []; + + angular.forEach($scope.data.polls, function (poll) { + if (poll.selected) { + deferred.push(Poll.remove({pollId: poll.id, permission:poll.permission}).$promise); + + $q.all(deferred).then(function () { + initPolls(); + }); + } + }) + } Page.setTitle('title.poll.list'); @@ -1413,6 +1463,23 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr Poll.get({paginationParameter:paginationParameter, cmd:$routeParams.cmd}, function (data) { $scope.data.polls = data.elements $scope.data.pollsPagination = data.pagination; + + // check if has elements + if (data.elements.length == 0 && data.pagination.currentPage > 0) { + data.pagination.currentPage--; + } + + // check the global right + $scope.globalVariables.hasAllRight = true; + for (var pollIndex in $scope.data.polls) { + var poll = $scope.data.polls[pollIndex]; + + if (angular.isUndefined(poll.permission)) { + $scope.globalVariables.hasAllRight = false; + break; + } + } + }, function (error) { $rootScope.$broadcast('newError', 'error.forbidden'); $location.url('/'); 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 6217c3c..7eb9ed2 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-list.html @@ -21,11 +21,27 @@ <div ng-if="!data.polls[0]"><h1>{{ 'poll.error.listEmpty' | translate }}</h1></div> -<div ng-repeat="poll in data.polls"> - <h2><a href="#/poll/vote/{{poll.id}}">{{poll.title}}</a></h2> - <p ng-bind-html="toHTML(poll.description)"></p> - <hr/> -</div> +<table class="table table-hover"> + <tr ng-repeat="poll in data.polls" ng-class="{'active':poll.selected}" ng-click="toggleSelect(poll, $event)"> + <td style="vertical-align:middle"> + <input type="checkbox" ng-model="poll.selected" ng-click="toggleSelect(poll, $event)"/> + </td> + <td> + <h2><a href="#/poll/vote/{{poll.id}}">{{poll.title}}</a></h2> + </td> + <td> + <div ng-bind-html="toHTML(poll.description)"></div> + </td> + </tr> + <tr ng-show="data.polls.length > 1"> + <td colspan="3"> + <button class="btn btn-default" ng-click="selectAll()"><span class="glyphicon glyphicon-check"></span> {{ 'action.selectAll' | translate }}</button> + <button class="btn btn-default" ng-click="unselectAll()"><span class="glyphicon glyphicon-unchecked"></span> {{ 'action.unselectAll' | translate }}</button> + <button class="btn btn-default" ng-click="toggleSelectAll()"><span class="glyphicon glyphicon-transfer"></span> {{ 'action.toggleSelectAll' | translate }}</button> + <button class="btn btn-danger" ng-click="deleteSelected()" ng-if="globalVariables.hasAllRight"><span class="glyphicon glyphicon-trash"></span> {{ 'action.deleteSelected' | translate }}</button> + </td> + </tr> +</table> <make-pagination current-page="data.pollsPagination.currentPage" last-page="data.pollsPagination.lastPage" diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-poll.html b/pollen-ui-angular/src/main/webapp/partials/poll-poll.html index a2c2558..cca1a46 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-poll.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-poll.html @@ -36,9 +36,7 @@ <div ng-show="showEditDesc" class="pollDesc"> <textarea id="descEditor" data-ck-editor ng-model="data.poll.description" focus-me="showEditDesc"></textarea> - <!-- fix me : no save in creation but save in edition --> - <button type="button" class="btn btn-primary" ng-click="showEditDesc = false;" ng-show="globalVariables.create">{{ 'action.return' | translate }}</button> - <button type="button" class="btn btn-primary" ng-click="showEditDesc = false; autoSavePoll()" ng-show="globalVariables.edit">{{ 'action.return' | translate }}</button> + <button type="button" class="btn btn-primary" ng-click="showEditDesc = false; autoSavePoll()">{{ 'action.return' | translate }}</button> </div> <div id="poll"> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.