GUACAMOLE-630: Preserve raw contents of color scheme if manually edited.

This commit is contained in:
Michael Jumper
2019-08-07 11:01:37 -07:00
parent 588cdcd97a
commit 3ce2adbae6
2 changed files with 4 additions and 6 deletions

View File

@@ -77,14 +77,12 @@ angular.module('form').controller('terminalColorSchemeFieldController', ['$scope
// Keep selected color scheme and custom color scheme in sync with changes
// to model
$scope.$watch('model', function modelChanged(model) {
if (!model)
$scope.selectedColorScheme = '';
else if (_.includes($scope.field.options, model))
$scope.selectedColorScheme = model;
else {
if ($scope.selectedColorScheme === CUSTOM_COLOR_SCHEME || (model && !_.includes($scope.field.options, model))) {
$scope.customColorScheme = ColorScheme.fromString(model);
$scope.selectedColorScheme = CUSTOM_COLOR_SCHEME;
}
else
$scope.selectedColorScheme = model || '';
});
// Keep model in sync with changes to selected color scheme

View File

@@ -242,7 +242,7 @@ angular.module('form').factory('ColorScheme', [function defineColorScheme() {
ColorScheme.toString = function toString(scheme) {
// Use originally-provided string if it equates to the exact same color scheme
if (scheme._originalString && ColorScheme.equals(scheme, ColorScheme.fromString(scheme._originalString)))
if (!_.isUndefined(scheme._originalString) && ColorScheme.equals(scheme, ColorScheme.fromString(scheme._originalString)))
return scheme._originalString;
// Add background and foreground