mirror of
https://github.com/sismics/docs.git
synced 2024-11-10 16:53:23 +01:00
Delete user (client)
This commit is contained in:
parent
c48eb7a0fe
commit
ac424b60cc
@ -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).
|
||||
*/
|
||||
@ -20,6 +20,9 @@ App.controller('SettingsUserEdit', function($scope, $state, $stateParams, Restan
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
@ -1,8 +1,13 @@
|
||||
<h2 ng-show="isEdit()">Edit <small>"{{ user.username }}"</small></h2>
|
||||
<h2 ng-show="!isEdit()">Add <small>user</small></h2>
|
||||
<h2 ng-show="isEdit()">Edit
|
||||
<small>"{{ user.username }}"</small>
|
||||
</h2>
|
||||
<h2 ng-show="!isEdit()">Add
|
||||
<small>user</small>
|
||||
</h2>
|
||||
<form class="form-horizontal" name="editUserForm" novalidate>
|
||||
<div class="control-group" ng-class="{ error: !editUserForm.username.$valid, success: editUserForm.username.$valid }">
|
||||
<label class="control-label" for="inputUsername">Username</label>
|
||||
|
||||
<div class="controls">
|
||||
<input name="username" type="text" id="inputUsername" required ng-disabled="isEdit()"
|
||||
ng-minlength="3" ng-maxlength="50" placeholder="Username" ng-model="user.username"/>
|
||||
@ -13,6 +18,7 @@
|
||||
</div>
|
||||
<div class="control-group" ng-class="{ error: !editUserForm.email.$valid, success: editUserForm.email.$valid }">
|
||||
<label class="control-label" for="inputEmail">E-mail</label>
|
||||
|
||||
<div class="controls">
|
||||
<input name="email" type="email" id="inputEmail" required
|
||||
ng-minlength="3" ng-maxlength="50" placeholder="E-mail" ng-model="user.email"/>
|
||||
@ -24,6 +30,7 @@
|
||||
</div>
|
||||
<div class="control-group" ng-class="{ error: !editUserForm.password.$valid, success: editUserForm.password.$valid }">
|
||||
<label class="control-label" for="inputPassword">Password</label>
|
||||
|
||||
<div class="controls">
|
||||
<input name="password" type="password" id="inputPassword" ng-required="!isEdit()"
|
||||
ng-minlength="8" ng-maxlength="50" placeholder="Password" ng-model="user.password"/>
|
||||
@ -32,8 +39,10 @@
|
||||
<span class="help-inline" ng-show="editUserForm.password.$error.maxlength">Too long</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group" ng-class="{ error: !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
|
||||
<div class="control-group"
|
||||
ng-class="{ error: !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
|
||||
<label class="control-label" for="inputPasswordConfirm">Password (confirm)</label>
|
||||
|
||||
<div class="controls">
|
||||
<input name="passwordconfirm" type="password" id="inputPasswordConfirm" ng-required="!isEdit()"
|
||||
ui-validate="'$value == user.password'" ui-validate-watch="'user.password'"
|
||||
@ -45,6 +54,9 @@
|
||||
<button type="submit" class="btn btn-primary" ng-click="edit()" ng-disabled="!editUserForm.$valid">
|
||||
<span class="icon-pencil icon-white"></span> {{ isEdit() ? 'Edit' : 'Add' }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="remove()">
|
||||
<span class="icon-trash icon-white"></span> Delete
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
|
Loading…
Reference in New Issue
Block a user