01/01: add form for edit user
This is an automated email from the git hooks/post-receive script. New commit to branch devel in repository Pollen. See http://git.None/Pollen.git commit 968ff64a7febc268a5c8fbdfeb2aef18b1d07d7b Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed May 28 16:58:57 2014 +0200 add form for edit user --- pollen-rest-api/src/main/resources/mapping | 12 ++-- pollen-ui-angular/src/main/webapp/index.html | 2 +- pollen-ui-angular/src/main/webapp/js/app.js | 1 + .../src/main/webapp/js/controllers/userCtrl.js | 14 +++++ pollen-ui-angular/src/main/webapp/js/services.js | 4 +- .../src/main/webapp/partials/user-edit.html | 70 ++++++++++++++++++++++ .../src/main/webapp/partials/user-register.html | 7 ++- 7 files changed, 99 insertions(+), 11 deletions(-) diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index da2368c..fe48ec3 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -115,12 +115,12 @@ PUT /v1/polls/{pollId}/close PollApi.closePoll # PollenUserApi -GET /v1/users PollenUserApi.getUsers -GET /v1/users/{userId} PollenUserApi.getUser -POST /v1/users PollenUserApi.createUser -PUT /v1/users/{userId} PollenUserApi.editUser -DELETE /v1/users/{userId} PollenUserApi.deleteUser -PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail +GET /v1/users PollenUserApi.getUsers +GET /v1/users/{userId} PollenUserApi.getUser +POST /v1/users PollenUserApi.createUser +PUT,POST /v1/users/{userId} PollenUserApi.editUser +DELETE /v1/users/{userId} PollenUserApi.deleteUser +PUT /v1/users/{userId}?token={} PollenUserApi.validateUserEmail # VoteCountingApi diff --git a/pollen-ui-angular/src/main/webapp/index.html b/pollen-ui-angular/src/main/webapp/index.html index ce64f62..6778c75 100644 --- a/pollen-ui-angular/src/main/webapp/index.html +++ b/pollen-ui-angular/src/main/webapp/index.html @@ -88,7 +88,7 @@ <ul class="dropdown-menu" role="menu"> <li> - <a href="#/user/edit/{{currentUser.id}}">Profile</a> + <a href="#/user/edit">Profile</a> </li> <li class="divider"></li> diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index da816a1..1a252fa 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -68,6 +68,7 @@ angular.module('pollen', ['pollenServices', 'ngRoute', 'pollControllers', 'userC .when('/poll/list', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"}) .when('/poll/list/:cmd', {templateUrl: './partials/poll-list.html', controller :"PollListCtrl"}) .when('/user/register', {templateUrl: './partials/user-register.html', controller:"UserRegisterCtrl"}) + .when('/user/edit', {templateUrl: './partials/user-edit.html', controller:"UserEditCtrl"}) .otherwise({redirectTo: '/'}); }]) 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 8f4a71f..2340bcf 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -36,6 +36,20 @@ } }]) +.controller('UserEditCtrl', ['$scope', 'User', 'SessionStorage', function ($scope, User, SessionStorage) { + $scope.currentUser = SessionStorage.get().user; + $scope.currentUser.password = ''; + + $scope.editUser = function () { + User.update($scope.currentUser, function (data) { + SessionStorage.save({user:data}); + $scope.saved = true; + }, function (error) { + $scope.restError = error.data; + }); + } +}]) + .controller('UserLoginCtrl', ['$scope', 'UserLogin', 'UserLogout', 'User', 'SessionStorage', '$route', '$location', function ($scope, UserLogin, UserLogout, User, SessionStorage, $route, $location) { if (angular.isUndefined($scope.data)) { $scope.data = {user:{}}; diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index 785de6f..8171f52 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -79,7 +79,7 @@ angular.module('pollenServices', ['ngResource']) }, 'update' : { - method:'PUT', + method:'POST', transformRequest : function (data, headersGetter) { return transformParam(data); } @@ -126,7 +126,7 @@ angular.module('pollenServices', ['ngResource']) }, 'update' : { - method:'PUT', + method:'POST', transformRequest : function (data, headersGetter) { return transformParam(data); } diff --git a/pollen-ui-angular/src/main/webapp/partials/user-edit.html b/pollen-ui-angular/src/main/webapp/partials/user-edit.html new file mode 100644 index 0000000..5c29acf --- /dev/null +++ b/pollen-ui-angular/src/main/webapp/partials/user-edit.html @@ -0,0 +1,70 @@ +<!-- + #%L + Pollen :: UI (Angular) + %% + Copyright (C) 2009 - 2014 CodeLutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> +<alert type="success" class="alert-float" ng-show="saved" close="saved = false"> Modification effectuée..</alert> + +<h2> Modification du Profile </h2> + +<form class="horizontal-form" ng-submit="editUser()"> + <div class="control-group"> + <label for="formName" class="col-sm-3 text-right control-label"> + Nom + </label> + <div class="col-sm-8"> + <input type="text" id="formName" class="form-control" ng-model="currentUser.name"/> + </div> + <div class="col-sm-1"> + </div> + </div> + + <div class="control-group"> + + <label for="formEmail" class="col-sm-3 text-right control-label"> + Adresse E-Mail + </label> + + <div class="col-sm-8"> + <input type="email" id="formEmail" name="email" class="form-control" ng-model="currentUser.email"/> + </div> + <div class="col-sm-1"> + <info-error error="restError.email[0]" data="currentUser.email"></info-error> + </div> + </div> + + <div class="control-group"> + <label for="formPassword" class="col-sm-3 text-right control-label"> + Mot de passe Actuel + </label> + <div class="col-sm-8"> + <input type="password" id="formPassword" class="form-control" ng-model="currentUser.password"/> + </div> + <div class="col-sm-1"> + <info-error error="restError.password[0]" data="currentUser.password"></info-error> + </div> + </div> + + <div class="control-group"> + <div class="col-sm-3"></div> + <div class="col-sm-8"> + <button class="btn btn-primary" type="submit">Envoyer</button> + </div> + <div class="col-sm-1"></div> + </div> +</form> \ No newline at end of file diff --git a/pollen-ui-angular/src/main/webapp/partials/user-register.html b/pollen-ui-angular/src/main/webapp/partials/user-register.html index 81cf1c3..501edfd 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-register.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-register.html @@ -19,7 +19,6 @@ #L% --> <h2> Inscription sur Pollen</h2> - <br/><br/><br/> <form ng-submit="submit()" class="form-horizontal"> <div class="control-group"> <label for="formName" class="col-sm-3 text-right control-label"> @@ -69,6 +68,10 @@ <div class="form-group"> - <button class="btn btn-primary" type="submit">Envoyer</button> + <div class="col-sm-3"></div> + <div class="col-sm-8"> + <button class="btn btn-primary" type="submit">Envoyer</button> + </div> + <div class="col-sm-1"></div> </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