05/13: print form error, delete favoriteListMember, delete and edit favoriteList
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 a85b55808d7d9d5f4518b3eaadf8695e6ec4a718 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Jun 18 15:27:30 2014 +0200 print form error, delete favoriteListMember, delete and edit favoriteList --- .../main/webapp/js/controllers/favoriteListCtrl.js | 22 +++++++++++++++------- .../main/webapp/partials/favoriteList-edit.html | 18 +++++++++++------- .../main/webapp/partials/favoriteList-list.html | 1 + 3 files changed, 27 insertions(+), 14 deletions(-) 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 246d29a..e1a0f3e 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/favoriteListCtrl.js @@ -49,8 +49,8 @@ angular.module('favoriteListControllers', []) }]) -.controller('FavoriteListEditCtrl', ['$scope', 'FavoriteList', 'FavoriteListMember', '$translate', '$routeParams', '$timeout', '$q', - function ($scope, FavoriteList, FavoriteListMember, $translate, $routeParams, $timeout, $q) { +.controller('FavoriteListEditCtrl', ['$scope', 'FavoriteList', 'FavoriteListMember', '$translate', '$routeParams', '$timeout', '$q', '$location', '$route', + function ($scope, FavoriteList, FavoriteListMember, $translate, $routeParams, $timeout, $q, $location, $route) { $scope.data = {}; var paginationParameter = {pageSize: conf.favoriteListDefaultPageSize}; @@ -114,6 +114,7 @@ angular.module('favoriteListControllers', []) FavoriteListPromise = FavoriteList.add({name:$scope.data.favoriteList.name}, function (data) { $scope.data.favoriteList.id = data.id; delete $scope.data.favoriteList.restError; + $location.url('/favoriteList/'+data.id); }, function (error) { $scope.data.favoriteList.restError = error.data; }).$promise; @@ -148,17 +149,16 @@ angular.module('favoriteListControllers', []) } } - $scope.deleteVoterList = function (voterList) { - if (angular.isDefined(voterList) && angular.isDefined(voterList.group.id)) { + $scope.deleteFavoriteList = function () { + if (angular.isDefined($scope.data.favoriteList.id)) { var confirmMessage; $translate('action.message.confirmDelete').then(function (msg) { confirmMessage = msg; }).then( function () { var confirmDelete = confirm(confirmMessage); if (confirmDelete == true) { - PollVoterList.remove({pollId:$routeParams.pollId, permission:$scope.globalVariables.permission, voterListId:voterList.group.id}, function (data) { - var index = $scope.data.voterList.indexOf(voterList); - $scope.data.voterList.splice(index, 1); + FavoriteList.remove({favoriteListId:$scope.data.favoriteList.id}, function (data) { + $location.url('/favoriteList'); }); } }); @@ -181,4 +181,12 @@ angular.module('favoriteListControllers', []) }); } }; + + var lastRoute = $route.current; + $scope.$on('$locationChangeSuccess', function(event) { + if (lastRoute.$$route.controller == $route.current.$$route.controller) { + $route.current = lastRoute; + } + }); + }]) diff --git a/pollen-ui-angular/src/main/webapp/partials/favoriteList-edit.html b/pollen-ui-angular/src/main/webapp/partials/favoriteList-edit.html index 257b333..02aa7d0 100644 --- a/pollen-ui-angular/src/main/webapp/partials/favoriteList-edit.html +++ b/pollen-ui-angular/src/main/webapp/partials/favoriteList-edit.html @@ -3,13 +3,13 @@ <div> <table class="voterList"> <tr> - <th colspan="2" ng-class="{'has-success':data.favoriteList.id && !data.favoriteList.restError}"> + <th colspan="2" ng-class="{'has-success':data.favoriteList.id && !data.favoriteList.restError, 'has-error':data.favoriteList.restError.name}"> <input type="text" name="group" ng-model="data.favoriteList.name" placeholder="name group" class="form-control" - ng-class="{'has-error':data.favoriteList.restError.name}" + tooltip="{{data.favoriteList.restError.name[0]}}" auto-save="saveFavoriteList()" /> </th> <th class="action"> </th> @@ -22,9 +22,13 @@ </tr> <tr ng-repeat="member in data.favoriteList.members" ng-class="{'has-success':member.id && !member.restError}"> - <td> <div ng-class="{'has-error':member.restError.name}"><input type="text" ng-model="member.name" class="form-control" auto-save="saveMember(member)"/></div></td> - <td> <div ng-class="{'has-error':member.restError.email}"><input type="text" ng-model="member.email" class="form-control" auto-save="saveMember(member)" /></div></td> - <td class="action"> <div ng-show="member.id"><button class="btn btn-danger" ng-click="deleteMember(member);"><i class="glyphicon glyphicon-remove"></i></button></div></td> + <td ng-class="{'has-error':member.restError.name}"> + <input type="text" ng-model="member.name" class="form-control" auto-save="saveMember(member)" tooltip="{{member.restError.name[0]}}"/> + </td> + <td ng-class="{'has-error':member.restError.email}"> + <input type="text" ng-model="member.email" class="form-control" auto-save="saveMember(member)" tooltip="{{member.restError.email[0]}}" /> + </td> + <td class="action"> <div ng-show="member.id"><button class="btn btn-danger" ng-click="deleteMember(member);"><span class="glyphicon glyphicon-remove"></span></button></div></td> </tr> <tr> @@ -37,8 +41,8 @@ <tr> <th colspan="3"> - <button class="btn btn-info" ng-click="addMember();"> {{ 'action.favoriteList.addMember' | translate }} </button> - <button class="btn btn-danger" ng-click="deleteFavoriteList();" ng-show="favoriteList.id"> {{ 'action.favoriteList.delete' | translate }} </button> + <button class="btn btn-info" ng-click="addMember();"><span class="glyphicon glyphicon-plus"></span> {{ 'action.favoriteList.addMember' | translate }} </button> + <button class="btn btn-danger" ng-click="deleteFavoriteList();" ng-show="data.favoriteList.id"><span class="glyphicon glyphicon-trash"></span> {{ 'action.favoriteList.delete' | translate }} </button> </th> </tr> </table> diff --git a/pollen-ui-angular/src/main/webapp/partials/favoriteList-list.html b/pollen-ui-angular/src/main/webapp/partials/favoriteList-list.html index 840685a..8d87f3d 100644 --- a/pollen-ui-angular/src/main/webapp/partials/favoriteList-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/favoriteList-list.html @@ -1,6 +1,7 @@ <h1> {{ 'user.favoriteList' | translate }} </h1> <div> + <a href="#/favoriteList/new"><button class="btn btn-info"><span class="glyphicon glyphicon-plus"></span> {{ 'action.favoriteList.add' | translate }}</button></a> <div ng-repeat="favList in data.favoriteList"> <h2> <a href="#/favoriteList/{{favList.id}}">{{ favList.name }}</a></h2> <hr/> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm