GUACAMOLE-292: Allow restriction of form contents to defined values only.

This commit is contained in:
Michael Jumper
2017-02-22 01:23:14 -08:00
parent be3bc6cded
commit b2871e7da0

View File

@@ -64,7 +64,16 @@ angular.module('form').directive('guacForm', [function form() {
* *
* @type Boolean * @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', templateUrl: 'app/form/templates/form.html',
@@ -184,14 +193,18 @@ angular.module('form').directive('guacForm', [function form() {
*/ */
$scope.isVisible = function isVisible(field) { $scope.isVisible = function isVisible(field) {
// All fields are visible if contents are not restricted to // Forms with valuesOnly set should display only fields with
// model properties only // associated values in the model object
if (!$scope.modelOnly) if ($scope.valuesOnly)
return true; return field && $scope.values[field.name];
// Otherwise, fields are only visible if they are present // Forms with modelOnly set should display only fields with
// within the model // associated properties in the model object
return field && (field.name in $scope.values); if ($scope.modelOnly)
return field && (field.name in $scope.values);
// Otherwise, all fields are visible
return true;
}; };