webadmin: display name for users
This commit is contained in:
@@ -541,10 +541,11 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
|
||||
}).error(defaultErrorHandler(callback));
|
||||
};
|
||||
|
||||
Client.prototype.createUser = function (username, email, sendInvite, callback) {
|
||||
Client.prototype.createUser = function (username, email, displayName, sendInvite, callback) {
|
||||
var data = {
|
||||
username: username,
|
||||
email: email,
|
||||
displayName: displayName,
|
||||
invite: !!sendInvite
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,17 @@
|
||||
</div>
|
||||
<input type="email" class="form-control" ng-model="useradd.email" id="inputUserAddEmail" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-error': (useradd_form.displayName.$dirty && useradd_form.displayName.$invalid) || (!useradd_form.displayName.$dirty && useradd.error.displayName) }">
|
||||
<label class="control-label" for="inputUserAddDisplayName">Full Name</label>
|
||||
<div class="control-label" ng-show="(!useradd_form.displayName.$dirty && useradd.error.displayName) || (useradd_form.displayname.$dirty && useradd_form.displayName.$invalid) || (!useradd_form.displayName.$dirty && useradd.error.displayName)">
|
||||
<small ng-show="useradd_form.displayName.$error.required">A Name is required</small>
|
||||
<small ng-show="useradd_form.displayName.$error.displayName">This is not a valid Name</small>
|
||||
<small ng-show="!useradd_form.displayName.$dirty && useradd.error.displayName">{{ useradd.error.displayName }}</small>
|
||||
</div>
|
||||
<input type="text" class="form-control" ng-model="useradd.displayName" id="inputUserAddDisplayName" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="useradd.sendInvite" id="inputUserAddSendInvite"> Send invite
|
||||
@@ -138,4 +149,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,6 +21,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
error: {},
|
||||
username: '',
|
||||
email: '',
|
||||
displayName: '',
|
||||
sendInvite: true
|
||||
};
|
||||
|
||||
@@ -54,14 +55,16 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$scope.useradd.alreadyTaken = false;
|
||||
$scope.useradd.error.username = null;
|
||||
$scope.useradd.error.email = null;
|
||||
$scope.useradd.error.displayName = null;
|
||||
|
||||
Client.createUser($scope.useradd.username, $scope.useradd.email, $scope.useradd.sendInvite, function (error) {
|
||||
Client.createUser($scope.useradd.username, $scope.useradd.email, $scope.useradd.displayName, $scope.useradd.sendInvite, function (error) {
|
||||
$scope.useradd.busy = false;
|
||||
|
||||
if (error && error.statusCode === 409) {
|
||||
$scope.useradd.error.username = 'Username or Email already taken';
|
||||
$scope.useradd_form.username.$setPristine();
|
||||
$scope.useradd_form.email.$setPristine();
|
||||
$scope.useradd_form.displayName.$setPristine();
|
||||
$('#inputUserAddUsername').focus();
|
||||
return;
|
||||
}
|
||||
@@ -76,6 +79,12 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$scope.useradd.error.usernameAttempted = $scope.useradd.username;
|
||||
$scope.useradd_form.username.$setPristine();
|
||||
$('#inputUserAddUsername').focus();
|
||||
} else if (error.message.indexOf('displayName') !== -1) {
|
||||
$scope.useradd.error.displayName = 'Invalid Name';
|
||||
$scope.useradd.error.displayNameAttempted = $scope.useradd.displayName;
|
||||
$scope.useradd_form.displayName.$setPristine();
|
||||
$('#inputUserAddDisplayName').focus();
|
||||
|
||||
} else {
|
||||
console.error('Unable to create user.', error.statusCode, error.message);
|
||||
}
|
||||
@@ -86,6 +95,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
|
||||
$scope.useradd.error = {};
|
||||
$scope.useradd.username = '';
|
||||
$scope.useradd.email = '';
|
||||
$scope.useradd.displayName = '';
|
||||
|
||||
$scope.useradd_form.$setUntouched();
|
||||
$scope.useradd_form.$setPristine();
|
||||
|
||||
Reference in New Issue
Block a user