1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-15 18:56:18 +00:00

Users administration (client)

This commit is contained in:
jendib
2013-08-09 00:21:11 +02:00
parent 990884137b
commit c48eb7a0fe
14 changed files with 153 additions and 32 deletions

View File

@@ -3,6 +3,39 @@
/**
* Settings user edition page controller.
*/
App.controller('SettingsUserEdit', function($scope, $stateParams, Restangular) {
$scope.user = Restangular.one('user', $stateParams.username).get();
App.controller('SettingsUserEdit', function($scope, $state, $stateParams, Restangular) {
/**
* Returns true if in edit mode (false in add mode).
*/
$scope.isEdit = function() {
return $stateParams.username;
};
/**
* In edit mode, load the current user.
*/
if ($scope.isEdit()) {
Restangular.one('user', $stateParams.username).get().then(function(data) {
$scope.user = data;
});
}
$scope.edit = function() {
var promise = null;
if ($scope.isEdit()) {
promise = Restangular
.one('user', $stateParams.username)
.post('', $scope.user);
} else {
promise = Restangular
.one('user')
.put($scope.user);
}
promise.then(function() {
$scope.loadUsers();
$state.transitionTo('settings.user');
});
};
});