GUACAMOLE-292: Allow restriction of form contents to defined values only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/b2871e7d Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/b2871e7d Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/b2871e7d Branch: refs/heads/master Commit: b2871e7da0cba79e92b70582244c1b22ac09b4d6 Parents: be3bc6c Author: Michael Jumper <[email protected]> Authored: Wed Feb 22 01:23:14 2017 -0800 Committer: Michael Jumper <[email protected]> Committed: Sat May 27 11:28:13 2017 -0700 ---------------------------------------------------------------------- .../src/main/webapp/app/form/directives/form.js | 29 ++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/b2871e7d/guacamole/src/main/webapp/app/form/directives/form.js ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/form/directives/form.js b/guacamole/src/main/webapp/app/form/directives/form.js index 518db7d..a6d44f3 100644 --- a/guacamole/src/main/webapp/app/form/directives/form.js +++ b/guacamole/src/main/webapp/app/form/directives/form.js @@ -64,7 +64,16 @@ angular.module('form').directive('guacForm', [function form() { * * @type Boolean */ - modelOnly : '=' + modelOnly : '=', + + /** + * Whether the contents of the form should be restricted to those + * fields/forms which have associated values defined within the + * given model object. By default, all fields will be shown. + * + * @type Boolean + */ + valuesOnly : '=' }, templateUrl: 'app/form/templates/form.html', @@ -184,14 +193,18 @@ angular.module('form').directive('guacForm', [function form() { */ $scope.isVisible = function isVisible(field) { - // All fields are visible if contents are not restricted to - // model properties only - if (!$scope.modelOnly) - return true; + // Forms with valuesOnly set should display only fields with + // associated values in the model object + if ($scope.valuesOnly) + return field && $scope.values[field.name]; + + // Forms with modelOnly set should display only fields with + // associated properties in the model object + if ($scope.modelOnly) + return field && (field.name in $scope.values); - // Otherwise, fields are only visible if they are present - // within the model - return field && (field.name in $scope.values); + // Otherwise, all fields are visible + return true; };
