mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
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:
@@ -102,6 +102,13 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
|||||||
*/
|
*/
|
||||||
$scope.submitted = false;
|
$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.
|
* Returns whether a previous login attempt is continuing.
|
||||||
*
|
*
|
||||||
@@ -144,6 +151,8 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
|||||||
$scope.enteredValues[field.name] = '';
|
$scope.enteredValues[field.name] = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(mostRelevantField());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,12 +203,35 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
|||||||
delete $scope.enteredValues[field.name];
|
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
|
// Reset state after authentication and routing have succeeded
|
||||||
$rootScope.$on('$routeChangeSuccess', function routeChanged() {
|
$rootScope.$on('$routeChangeSuccess', function routeChanged() {
|
||||||
$scope.enteredValues = {};
|
$scope.enteredValues = {};
|
||||||
|
Reference in New Issue
Block a user