mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-302: Allow guacForm and guacFormField directives to specify which field needs to be focused.
This commit is contained in:
@@ -72,7 +72,14 @@ angular.module('form').directive('guacForm', [function form() {
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
disabled : '='
|
||||
disabled : '=',
|
||||
|
||||
/**
|
||||
* The name of the field to be focused, if any.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
focused : '='
|
||||
|
||||
},
|
||||
templateUrl: 'app/form/templates/form.html',
|
||||
@@ -180,6 +187,10 @@ angular.module('form').directive('guacForm', [function form() {
|
||||
|
||||
});
|
||||
|
||||
$scope.isFocused = function isFocused(field) {
|
||||
return field && (field.name === $scope.focused);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether the given field should be displayed to the
|
||||
* current user.
|
||||
|
@@ -61,7 +61,14 @@ angular.module('form').directive('guacFormField', [function formField() {
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
disabled : '='
|
||||
disabled : '=',
|
||||
|
||||
/**
|
||||
* Whether this field should be focused.
|
||||
*
|
||||
* @type Boolean
|
||||
*/
|
||||
focused : '='
|
||||
|
||||
},
|
||||
templateUrl: 'app/form/templates/formField.html',
|
||||
|
@@ -10,7 +10,9 @@
|
||||
<guac-form-field ng-repeat="field in form.fields" namespace="namespace"
|
||||
ng-if="isVisible(field)"
|
||||
data-disabled="disabled"
|
||||
field="field" model="values[field.name]"></guac-form-field>
|
||||
focused="isFocused(field)"
|
||||
field="field"
|
||||
model="values[field.name]"></guac-form-field>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -151,7 +151,7 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
$scope.enteredValues[field.name] = '';
|
||||
});
|
||||
|
||||
console.log(mostRelevantField());
|
||||
$scope.relevantField = getRelevantField();
|
||||
|
||||
});
|
||||
|
||||
@@ -203,8 +203,6 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
delete $scope.enteredValues[field.name];
|
||||
|
||||
});
|
||||
|
||||
console.log(mostRelevantField());
|
||||
}
|
||||
|
||||
}));
|
||||
@@ -212,15 +210,14 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Returns the field most relevant 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() {
|
||||
var getRelevantField = function getRelevantField() {
|
||||
|
||||
for (var i = 0; i < $scope.remainingFields.length; i++) {
|
||||
var field = $scope.remainingFields[i];
|
||||
|
@@ -27,6 +27,7 @@
|
||||
namespace="'LOGIN'"
|
||||
content="remainingFields"
|
||||
model="enteredValues"
|
||||
focused="relevantField.name"
|
||||
data-disabled="submitted"></guac-form>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user