mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-292: Restrict attributes on object management pages to those explicitly present on the object.
This commit is contained in:
@@ -55,7 +55,16 @@ angular.module('form').directive('guacForm', [function form() {
|
||||
*
|
||||
* @type Object.<String, String>
|
||||
*/
|
||||
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
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
<div class="form-group">
|
||||
<div ng-repeat="form in forms" class="form">
|
||||
<div ng-repeat="form in forms" class="form"
|
||||
ng-show="containsVisible(form.fields)">
|
||||
|
||||
<!-- Form name -->
|
||||
<h3 ng-show="form.name">{{getSectionHeader(form) | translate}}</h3>
|
||||
@@ -7,6 +8,7 @@
|
||||
<!-- All fields in form -->
|
||||
<div class="fields">
|
||||
<guac-form-field ng-repeat="field in form.fields" namespace="namespace"
|
||||
ng-show="isVisible(field)"
|
||||
field="field" model="values[field.name]"></guac-form-field>
|
||||
</div>
|
||||
|
||||
|
@@ -40,7 +40,8 @@
|
||||
|
||||
<!-- Connection attributes section -->
|
||||
<div class="attributes">
|
||||
<guac-form namespace="'CONNECTION_ATTRIBUTES'" content="attributes" model="connection.attributes"></guac-form>
|
||||
<guac-form namespace="'CONNECTION_ATTRIBUTES'" content="attributes"
|
||||
model="connection.attributes" model-only="true"></guac-form>
|
||||
</div>
|
||||
|
||||
<!-- Connection parameters -->
|
||||
|
@@ -40,7 +40,8 @@
|
||||
|
||||
<!-- Connection group attributes section -->
|
||||
<div class="attributes">
|
||||
<guac-form namespace="'CONNECTION_GROUP_ATTRIBUTES'" content="attributes" model="connectionGroup.attributes"></guac-form>
|
||||
<guac-form namespace="'CONNECTION_GROUP_ATTRIBUTES'" content="attributes"
|
||||
model="connectionGroup.attributes" model-only="true"></guac-form>
|
||||
</div>
|
||||
|
||||
<!-- Form action buttons -->
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<!-- Sharing profile attributes section -->
|
||||
<div class="attributes">
|
||||
<guac-form namespace="'SHARING_PROFILE_ATTRIBUTES'" content="attributes"
|
||||
model="sharingProfile.attributes"></guac-form>
|
||||
model="sharingProfile.attributes" model-only="true"></guac-form>
|
||||
</div>
|
||||
|
||||
<!-- Sharing profile parameters -->
|
||||
|
@@ -41,7 +41,8 @@
|
||||
|
||||
<!-- User attributes section -->
|
||||
<div class="attributes" ng-show="canChangeAttributes()">
|
||||
<guac-form namespace="'USER_ATTRIBUTES'" content="attributes" model="user.attributes"></guac-form>
|
||||
<guac-form namespace="'USER_ATTRIBUTES'" content="attributes"
|
||||
model="user.attributes" model-only="true"></guac-form>
|
||||
</div>
|
||||
|
||||
<!-- System permissions section -->
|
||||
|
Reference in New Issue
Block a user