GUACAMOLE-220: Do not display "X" for removing an identifier if the identifier cannot actually be edited.

This commit is contained in:
Michael Jumper
2018-08-07 13:05:09 -07:00
parent 0059121716
commit ca1db7831b
2 changed files with 21 additions and 1 deletions

View File

@@ -117,6 +117,15 @@ angular.module('manage').directive('identifierSetEditor', ['$injector',
*/
$scope.identifierFlags = {};
/**
* Map of identifiers to boolean flags indicating whether that
* identifier is editable. If an identifier is not editable, it will be
* absent from this map.
*
* @type Object.<String, Boolean>
*/
$scope.isEditable = {};
/**
* Adds the given identifier to the given sorted array of identifiers,
* preserving the sorted order of the array. If the identifier is
@@ -194,6 +203,16 @@ angular.module('manage').directive('identifierSetEditor', ['$injector',
});
// An identifier is editable iff it is available to be added or removed
// from the identifier set being edited (iff it is within the
// identifiersAvailable array)
$scope.$watch('identifiersAvailable', function availableIdentifiersChanged(identifiers) {
$scope.isEditable = {};
angular.forEach(identifiers, function storeEditableIdentifier(identifier) {
$scope.isEditable[identifier] = true;
});
});
/**
* Notifies the controller that a change has been made to the flag
* denoting presence/absence of a particular identifier within the

View File

@@ -18,7 +18,8 @@
<ul>
<li ng-repeat="identifier in identifiers | filter: filterString">
<label><img src="images/x-red.png" alt="Remove" class="remove"
ng-click="removeIdentifier(identifier)"/><span class="identifier">{{ identifier }}</span>
ng-click="removeIdentifier(identifier)"
ng-show="isEditable[identifier]"/><span class="identifier">{{ identifier }}</span>
</label>
</li>
</ul>