Merge "Tasks may now be un-assigned."

This commit is contained in:
Jenkins 2015-04-14 09:51:08 +00:00 committed by Gerrit Code Review
commit c015296a60
2 changed files with 38 additions and 2 deletions

View File

@ -44,7 +44,13 @@ angular.module('sb.util').directive('userTypeahead',
/**
* Toggle the display of the form.
*/
$scope.toggleForm = function () {
$scope.toggleForm = function (evt) {
// If we blur while the input is empty, try to set that
// value.
if (evt && !evt.target.value) {
$scope.updateViewValue(null);
}
if (!!$scope.asInline) {
if ($scope.showForm) {
$timeout(function () {
@ -100,6 +106,34 @@ angular.module('sb.util').directive('userTypeahead',
}
};
/**
* Blur on escape.
*/
$scope.handleEscapeKey = function (evt) {
// Escape key
if (evt.keyCode === 27) {
evt.target.blur();
}
};
/**
* Save and blur on enter.
*/
$scope.handleEnterKey = function (evt) {
// The enter key
if (evt.keyCode === 13) {
// If the field is empty, try to set the view value (if
// there's something in it, we have to trust
// that the field renderer knows what it's doing).
if (evt && !evt.target.value) {
$scope.updateViewValue(null);
}
evt.target.blur();
}
};
/**
* Formats the user name.
*/

View File

@ -41,7 +41,9 @@
type="text"
class="form-control"
focus="autoFocus"
ng-blur="toggleForm()"
ng-blur="toggleForm($event)"
ng-keydown="handleEscapeKey($event)"
ng-keypress="handleEnterKey($event)"
typeahead-editable="false"
typeahead-wait-ms="200"
typeahead="user as user.full_name for user in searchUsers($viewValue)"