Handle all errors and set focus correctly

Fixes #485
This commit is contained in:
Girish Ramakrishnan
2017-11-14 18:21:01 -08:00
parent c58b2677b6
commit 24875ba292
2 changed files with 11 additions and 6 deletions

View File

@@ -40,7 +40,7 @@
<div class="form-group" ng-class="{ 'has-error': testEmail.error.key }">
<label class="control-label" for="inputTestEmailKey">Email to</label>
<input type="text" class="form-control" ng-model="testEmail.mailTo" id="inputTestMailTo" name="mailTo" ng-disabled="testEmail.busy" placeholder="Email address">
<input type="text" class="form-control" ng-model="testEmail.mailTo" id="inputTestMailTo" name="mailTo" ng-disabled="testEmail.busy" placeholder="Email address" autofocus>
</div>
<input class="ng-hide" type="submit" ng-disabled="testEmailForm.$invalid"/>

View File

@@ -191,11 +191,9 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
$scope.testEmail.busy = false;
if (error) {
if (error.statusCode === 402) {
$scope.testEmail.error.generic = error.message;
} else {
console.error(error);
}
$scope.testEmail.error.generic = error.message;
console.error(error);
$('#inputTestMailTo').focus();
return;
}
@@ -324,5 +322,12 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
$scope.email.refresh();
});
// setup all the dialog focus handling
['testEmailModal'].forEach(function (id) {
$('#' + id).on('shown.bs.modal', function () {
$(this).find("[autofocus]:first").focus();
});
});
$('.modal-backdrop').remove();
}]);