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 @@