mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17: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
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
disabled : '='
|
disabled : '=',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the field to be focused, if any.
|
||||||
|
*
|
||||||
|
* @type String
|
||||||
|
*/
|
||||||
|
focused : '='
|
||||||
|
|
||||||
},
|
},
|
||||||
templateUrl: 'app/form/templates/form.html',
|
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
|
* Returns whether the given field should be displayed to the
|
||||||
* current user.
|
* current user.
|
||||||
|
@@ -61,7 +61,14 @@ angular.module('form').directive('guacFormField', [function formField() {
|
|||||||
*
|
*
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
disabled : '='
|
disabled : '=',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this field should be focused.
|
||||||
|
*
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
focused : '='
|
||||||
|
|
||||||
},
|
},
|
||||||
templateUrl: 'app/form/templates/formField.html',
|
templateUrl: 'app/form/templates/formField.html',
|
||||||
|
@@ -10,7 +10,9 @@
|
|||||||
<guac-form-field ng-repeat="field in form.fields" namespace="namespace"
|
<guac-form-field ng-repeat="field in form.fields" namespace="namespace"
|
||||||
ng-if="isVisible(field)"
|
ng-if="isVisible(field)"
|
||||||
data-disabled="disabled"
|
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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -151,7 +151,7 @@ angular.module('login').directive('guacLogin', [function guacLogin() {
|
|||||||
$scope.enteredValues[field.name] = '';
|
$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];
|
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
|
* Returns the field most relevant to the user given the current state
|
||||||
* state of the login process. This will normally be the first empty
|
* of the login process. This will normally be the first empty field.
|
||||||
* field.
|
|
||||||
*
|
*
|
||||||
* @return {Field}
|
* @return {Field}
|
||||||
* The field most relevant, null if there is no single most relevant
|
* The field most relevant, null if there is no single most relevant
|
||||||
* field.
|
* field.
|
||||||
*/
|
*/
|
||||||
var mostRelevantField = function findMostRelevantField() {
|
var getRelevantField = function getRelevantField() {
|
||||||
|
|
||||||
for (var i = 0; i < $scope.remainingFields.length; i++) {
|
for (var i = 0; i < $scope.remainingFields.length; i++) {
|
||||||
var field = $scope.remainingFields[i];
|
var field = $scope.remainingFields[i];
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
namespace="'LOGIN'"
|
namespace="'LOGIN'"
|
||||||
content="remainingFields"
|
content="remainingFields"
|
||||||
model="enteredValues"
|
model="enteredValues"
|
||||||
|
focused="relevantField.name"
|
||||||
data-disabled="submitted"></guac-form>
|
data-disabled="submitted"></guac-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user