GUACAMOLE-302: Additions are made to the login directive so that the appropriate field that needs to be focussed is determined.

This commit is contained in:
m-khan-glyptodon
2018-12-03 09:28:49 -08:00
parent 5f1c70e737
commit 52d2fe1661

View File

@@ -102,6 +102,13 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
*/
$scope.submitted = false;
/**
* The field that is most relevant to the user.
*
* @type Field
*/
$scope.relevantField = null;
/**
* Returns whether a previous login attempt is continuing.
*
@@ -144,6 +151,8 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
$scope.enteredValues[field.name] = '';
});
console.log(mostRelevantField());
});
/**
@@ -194,12 +203,35 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
delete $scope.enteredValues[field.name];
});
console.log(mostRelevantField());
}
}));
};
/**
* Returns the field most relevant field to the user given the current
* state of the login process. This will normally be the first empty
* field.
*
* @return {Field}
* The field most relevant, null if there is no single most relevant
* field.
*/
var mostRelevantField = function findMostRelevantField() {
for (var i = 0; i < $scope.remainingFields.length; i++) {
var field = $scope.remainingFields[i];
if (!$scope.enteredValues[field.name])
return field;
}
return null;
};
// Reset state after authentication and routing have succeeded
$rootScope.$on('$routeChangeSuccess', function routeChanged() {
$scope.enteredValues = {};