diff --git a/guacamole/src/main/webapp/app/form/directives/form.js b/guacamole/src/main/webapp/app/form/directives/form.js index be2f3b176..81f500fc9 100644 --- a/guacamole/src/main/webapp/app/form/directives/form.js +++ b/guacamole/src/main/webapp/app/form/directives/form.js @@ -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,19 @@ angular.module('form').directive('guacForm', [function form() { }); + /** + * Returns whether the given field should be focused or not. + * + * @param {Field} field + * The field to check. + * + * @returns {Boolean} + * true if the given field should be focused, false otherwise. + */ + $scope.isFocused = function isFocused(field) { + return field && (field.name === $scope.focused); + }; + /** * Returns whether the given field should be displayed to the * current user. diff --git a/guacamole/src/main/webapp/app/form/directives/formField.js b/guacamole/src/main/webapp/app/form/directives/formField.js index 15adc29e4..cf3efd027 100644 --- a/guacamole/src/main/webapp/app/form/directives/formField.js +++ b/guacamole/src/main/webapp/app/form/directives/formField.js @@ -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', diff --git a/guacamole/src/main/webapp/app/form/templates/checkboxField.html b/guacamole/src/main/webapp/app/form/templates/checkboxField.html index b76368afe..252441b1f 100644 --- a/guacamole/src/main/webapp/app/form/templates/checkboxField.html +++ b/guacamole/src/main/webapp/app/form/templates/checkboxField.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/dateField.html b/guacamole/src/main/webapp/app/form/templates/dateField.html index b6af5463c..6fd38dab8 100644 --- a/guacamole/src/main/webapp/app/form/templates/dateField.html +++ b/guacamole/src/main/webapp/app/form/templates/dateField.html @@ -4,6 +4,7 @@ ng-model="typedValue" ng-model-options="modelOptions" guac-lenient-date + guac-focus="focused" placeholder="{{'FORM.FIELD_PLACEHOLDER_DATE' | translate}}" autocorrect="off" autocapitalize="off"/> diff --git a/guacamole/src/main/webapp/app/form/templates/emailField.html b/guacamole/src/main/webapp/app/form/templates/emailField.html index 0e4354e91..3eb31e751 100644 --- a/guacamole/src/main/webapp/app/form/templates/emailField.html +++ b/guacamole/src/main/webapp/app/form/templates/emailField.html @@ -3,6 +3,7 @@ ng-disabled="disabled" ng-model="model" ng-hide="readOnly" + guac-focus="focused" autocorrect="off" autocapitalize="off"/> {{model}} diff --git a/guacamole/src/main/webapp/app/form/templates/form.html b/guacamole/src/main/webapp/app/form/templates/form.html index fe0c8903a..6b19bcce2 100644 --- a/guacamole/src/main/webapp/app/form/templates/form.html +++ b/guacamole/src/main/webapp/app/form/templates/form.html @@ -10,7 +10,9 @@ + focused="isFocused(field)" + field="field" + model="values[field.name]"> diff --git a/guacamole/src/main/webapp/app/form/templates/languageField.html b/guacamole/src/main/webapp/app/form/templates/languageField.html index 404f74e5e..5af4e75df 100644 --- a/guacamole/src/main/webapp/app/form/templates/languageField.html +++ b/guacamole/src/main/webapp/app/form/templates/languageField.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/guacamole/src/main/webapp/app/form/templates/numberField.html b/guacamole/src/main/webapp/app/form/templates/numberField.html index 007297365..9e4c28bfc 100644 --- a/guacamole/src/main/webapp/app/form/templates/numberField.html +++ b/guacamole/src/main/webapp/app/form/templates/numberField.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/passwordField.html b/guacamole/src/main/webapp/app/form/templates/passwordField.html index 56472ef4e..68d36f758 100644 --- a/guacamole/src/main/webapp/app/form/templates/passwordField.html +++ b/guacamole/src/main/webapp/app/form/templates/passwordField.html @@ -1,4 +1,4 @@
- +
\ No newline at end of file diff --git a/guacamole/src/main/webapp/app/form/templates/selectField.html b/guacamole/src/main/webapp/app/form/templates/selectField.html index 2f2b9d5ee..f173d5486 100644 --- a/guacamole/src/main/webapp/app/form/templates/selectField.html +++ b/guacamole/src/main/webapp/app/form/templates/selectField.html @@ -1,2 +1,2 @@ - \ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/textAreaField.html b/guacamole/src/main/webapp/app/form/templates/textAreaField.html index e049df60d..6614bfb2d 100644 --- a/guacamole/src/main/webapp/app/form/templates/textAreaField.html +++ b/guacamole/src/main/webapp/app/form/templates/textAreaField.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/guacamole/src/main/webapp/app/form/templates/textField.html b/guacamole/src/main/webapp/app/form/templates/textField.html index 819ae038a..6abd4f6c0 100644 --- a/guacamole/src/main/webapp/app/form/templates/textField.html +++ b/guacamole/src/main/webapp/app/form/templates/textField.html @@ -1,5 +1,5 @@
-