diff --git a/guacamole/src/main/webapp/app/form/directives/form.js b/guacamole/src/main/webapp/app/form/directives/form.js index f65989934..518db7dba 100644 --- a/guacamole/src/main/webapp/app/form/directives/form.js +++ b/guacamole/src/main/webapp/app/form/directives/form.js @@ -55,7 +55,16 @@ angular.module('form').directive('guacForm', [function form() { * * @type Object. */ - model : '=' + model : '=', + + /** + * Whether the contents of the form should be restricted to those + * fields/forms which match properties defined within the given + * model object. By default, all fields will be shown. + * + * @type Boolean + */ + modelOnly : '=' }, templateUrl: 'app/form/templates/form.html', @@ -163,6 +172,55 @@ angular.module('form').directive('guacForm', [function form() { }); + /** + * Returns whether the given field should be displayed to the + * current user. + * + * @param {Field} field + * The field to check. + * + * @returns {Boolean} + * true if the given field should be visible, false otherwise. + */ + $scope.isVisible = function isVisible(field) { + + // All fields are visible if contents are not restricted to + // model properties only + if (!$scope.modelOnly) + return true; + + // Otherwise, fields are only visible if they are present + // within the model + return field && (field.name in $scope.values); + + }; + + /** + * Returns whether at least one of the given fields should be + * displayed to the current user. + * + * @param {Field[]} fields + * The array of fields to check. + * + * @returns {Boolean} + * true if at least one field within the given array should be + * visible, false otherwise. + */ + $scope.containsVisible = function containsVisible(fields) { + + // If fields are defined, check whether at least one is visible + if (fields) { + for (var i = 0; i < fields.length; i++) { + if ($scope.isVisible(fields[i])) + return true; + } + } + + // Otherwise, there are no visible fields + return false; + + }; + }] // end controller }; diff --git a/guacamole/src/main/webapp/app/form/templates/form.html b/guacamole/src/main/webapp/app/form/templates/form.html index 6013543d6..e4564e895 100644 --- a/guacamole/src/main/webapp/app/form/templates/form.html +++ b/guacamole/src/main/webapp/app/form/templates/form.html @@ -1,5 +1,6 @@
-
+

{{getSectionHeader(form) | translate}}

@@ -7,6 +8,7 @@
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html index 9df51a0d8..80796a4c9 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manageConnection.html +++ b/guacamole/src/main/webapp/app/manage/templates/manageConnection.html @@ -40,7 +40,8 @@
- +
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html b/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html index 0b952518c..2d5ac5881 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html +++ b/guacamole/src/main/webapp/app/manage/templates/manageConnectionGroup.html @@ -40,7 +40,8 @@
- +
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageSharingProfile.html b/guacamole/src/main/webapp/app/manage/templates/manageSharingProfile.html index 4873b867d..a8e6438cf 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manageSharingProfile.html +++ b/guacamole/src/main/webapp/app/manage/templates/manageSharingProfile.html @@ -22,7 +22,7 @@
+ model="sharingProfile.attributes" model-only="true">
diff --git a/guacamole/src/main/webapp/app/manage/templates/manageUser.html b/guacamole/src/main/webapp/app/manage/templates/manageUser.html index e32d725ae..dc71d27ac 100644 --- a/guacamole/src/main/webapp/app/manage/templates/manageUser.html +++ b/guacamole/src/main/webapp/app/manage/templates/manageUser.html @@ -41,7 +41,8 @@
- +