Allow admins to set the username and displayName optionally on user creation

This commit is contained in:
Johannes Zellner
2016-06-02 13:32:45 +02:00
parent d06398dbfd
commit 9eac56578c
2 changed files with 28 additions and 1 deletions

View File

@@ -18,6 +18,25 @@
<input type="email" class="form-control" ng-model="useradd.email" name="email" id="inputUserAddEmail" required autofocus>
</div>
<div class="form-group" ng-class="{ 'has-error': (useradd_form.username.$dirty && useradd_form.username.$invalid) || (!useradd_form.username.$dirty && useradd.error.username) }">
<label class="control-label">Username (optional)</label>
<p>If not specified, the user can choose the username following the invite link.</p>
<div class="control-label" ng-show="(!useradd_form.username.$dirty && useradd.error.username) || (useradd_form.username.$dirty && useradd_form.username.$invalid) || (!useradd_form.username.$dirty && useradd.error.username)">
<small ng-show="useradd_form.username.$error.username">This is not a valid username</small>
<small ng-show="!useradd_form.username.$dirty && useradd.error.username">{{ useradd.error.username }}</small>
</div>
<input type="text" class="form-control" ng-model="useradd.username" name="username" id="inputUserAddUsername">
</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">Display Name (optional)</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.displayName">This is not a valid displayName</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" name="displayName" id="inputUserAddDisplayName">
</div>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="useradd.sendInvite" id="inputUserAddSendInvite"> Send invite

View File

@@ -23,6 +23,8 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
alreadyTaken: false,
error: {},
email: '',
username: '',
displayName: '',
sendInvite: true
};
@@ -166,6 +168,8 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.showUserAdd = function () {
$scope.useradd.error = {};
$scope.useradd.email = '';
$scope.useradd.username = '';
$scope.useradd.displayName = '';
$scope.useradd_form.$setUntouched();
$scope.useradd_form.$setPristine();
@@ -178,8 +182,10 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useradd.alreadyTaken = false;
$scope.useradd.error.email = null;
$scope.useradd.error.username = null;
$scope.useradd.error.displayName = null;
Client.createUser('' /* username */, $scope.useradd.email, '' /* displayName */, $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) {
@@ -203,6 +209,8 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useradd.error = {};
$scope.useradd.email = '';
$scope.useradd.username = '';
$scope.useradd.displayName = '';
$scope.useradd_form.$setUntouched();
$scope.useradd_form.$setPristine();