diff --git a/docs-web/src/main/webapp/js/controller/SettingsUserEdit.js b/docs-web/src/main/webapp/js/controller/SettingsUserEdit.js index 89782c19..528899e3 100644 --- a/docs-web/src/main/webapp/js/controller/SettingsUserEdit.js +++ b/docs-web/src/main/webapp/js/controller/SettingsUserEdit.js @@ -3,7 +3,7 @@ /** * Settings user edition page controller. */ -App.controller('SettingsUserEdit', function($scope, $state, $stateParams, Restangular) { +App.controller('SettingsUserEdit', function($scope, $dialog, $state, $stateParams, Restangular) { /** * Returns true if in edit mode (false in add mode). */ @@ -19,7 +19,10 @@ App.controller('SettingsUserEdit', function($scope, $state, $stateParams, Restan $scope.user = data; }); } - + + /** + * Update the current user. + */ $scope.edit = function() { var promise = null; @@ -38,4 +41,27 @@ App.controller('SettingsUserEdit', function($scope, $state, $stateParams, Restan $state.transitionTo('settings.user'); }); }; + + /** + * Delete the current user. + */ + $scope.remove = function () { + var title = 'Delete user'; + var msg = 'Do you really want to delete this user? All associated documents, files and tags will be deleted'; + var btns = [{result:'cancel', label: 'Cancel'}, {result:'ok', label: 'OK', cssClass: 'btn-primary'}]; + + $dialog.messageBox(title, msg, btns) + .open() + .then(function(result) { + if (result == 'ok') { + Restangular.one('user', $stateParams.username).remove().then(function() { + $scope.loadUsers(); + $state.transitionTo('settings.user'); + }, function () { + $state.transitionTo('settings.user'); + }); + } + }); + }; + }); \ No newline at end of file diff --git a/docs-web/src/main/webapp/partial/settings.user.edit.html b/docs-web/src/main/webapp/partial/settings.user.edit.html index eee71052..5e5c458a 100644 --- a/docs-web/src/main/webapp/partial/settings.user.edit.html +++ b/docs-web/src/main/webapp/partial/settings.user.edit.html @@ -1,11 +1,16 @@ -

Edit "{{ user.username }}"

-

Add user

+

Edit + "{{ user.username }}" +

+

Add + user +

+
+ ng-minlength="3" ng-maxlength="50" placeholder="Username" ng-model="user.username"/> Required Too short Too long @@ -13,9 +18,10 @@
+
+ ng-minlength="3" ng-maxlength="50" placeholder="E-mail" ng-model="user.email"/> Required Must be a valid e-mail Too short @@ -24,20 +30,23 @@
+
+ ng-minlength="8" ng-maxlength="50" placeholder="Password" ng-model="user.password"/> Required Too short Too long
-
+
+
+ ui-validate="'$value == user.password'" ui-validate-watch="'user.password'" + placeholder="Password (confirm)" ng-model="user.passwordconfirm"/> Password and password confirmation must match
@@ -45,6 +54,9 @@ +
{{ alert.msg }} \ No newline at end of file