Skip to content

Commit

Permalink
UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vmuzikar authored and mposolda committed May 31, 2021
1 parent 73a3899 commit 20b29f7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3206,6 +3206,11 @@ module.controller('ClientPoliciesProfilesEditExecutorCtrl', function($scope, rea
} else {
var exec = getExecutorByIndex($scope.editedProfile, updatedExecutorIndex);
if (exec) {
// a failsafe in case the configuration was deleted entirely (or set to null) in the JSON view
if (!exec.configuration) {
exec.configuration = {}
}

$scope.executor = {
config: exec.configuration
};
Expand All @@ -3219,31 +3224,33 @@ module.controller('ClientPoliciesProfilesEditExecutorCtrl', function($scope, rea
}
}

// Convert boolean properties from the configuration to strings as expected by the kc-provider-config directive
for (var j=0 ; j < $scope.executorType.properties.length ; j++) {
// Convert boolean properties from the configuration to strings as expected by the kc-provider-config directive
var currentProperty = $scope.executorType.properties[j];
if (currentProperty.type === 'boolean') {
$scope.executor.config[currentProperty.name] = ($scope.executor.config[currentProperty.name]) ? "true" : "false";
}

// a workaround for select2 to prevent displaying empty boxes
var configProperty = $scope.executor.config[$scope.executorType.properties[j].name];
if (Array.isArray(configProperty) && configProperty.length === 0) {
$scope.executor.config[$scope.executorType.properties[j].name] = null
}

}
}

}

function toDefaultValue(configProperty) {
if (configProperty.type === 'MultivaluedString' || configProperty.type === 'MultivaluedList') {
if (configProperty.defaultValue) {
return configProperty.defaultValue;
} else {
return [];
}
}

if (configProperty.type === 'boolean') {
return (configProperty.defaultValue) ? "true" : "false";
}

if (configProperty.defaultValue !== undefined) {
if ((configProperty.type === 'MultivaluedString' || configProperty.type === 'MultivaluedList') && !Array.isArray(configProperty.defaultValue)) {
return [configProperty.defaultValue]
}
return configProperty.defaultValue;
} else {
return null;
Expand Down Expand Up @@ -3588,6 +3595,11 @@ module.controller('ClientPoliciesEditConditionCtrl', function($scope, realm, ser
} else {
var cond = getConditionByIndex($scope.editedPolicy, updatedConditionIndex);
if (cond) {
// a failsafe in case the configuration was deleted entirely (or set to null) in the JSON view
if (!cond.configuration) {
cond.configuration = {}
}

$scope.condition = {
config: cond.configuration
};
Expand All @@ -3601,31 +3613,33 @@ module.controller('ClientPoliciesEditConditionCtrl', function($scope, realm, ser
}
}

// Convert boolean properties from the configuration to strings as expected by the kc-provider-config directive
for (var j=0 ; j < $scope.conditionType.properties.length ; j++) {
// Convert boolean properties from the configuration to strings as expected by the kc-provider-config directive
var currentProperty = $scope.conditionType.properties[j];
if (currentProperty.type === 'boolean') {
$scope.condition.config[currentProperty.name] = ($scope.condition.config[currentProperty.name]) ? "true" : "false";
}

// a workaround for select2 to prevent displaying empty boxes
var configProperty = $scope.condition.config[$scope.conditionType.properties[j].name];
if (Array.isArray(configProperty) && configProperty.length === 0) {
$scope.condition.config[$scope.conditionType.properties[j].name] = null
}

}
}

}

function toDefaultValue(configProperty) {
if (configProperty.type === 'MultivaluedString' || configProperty.type === 'MultivaluedList') {
if (configProperty.defaultValue) {
return configProperty.defaultValue;
} else {
return [];
}
}

if (configProperty.type === 'boolean') {
return (configProperty.defaultValue) ? "true" : "false";
}

if (configProperty.defaultValue !== undefined) {
if ((configProperty.type === 'MultivaluedString' || configProperty.type === 'MultivaluedList') && !Array.isArray(configProperty.defaultValue)) {
return [configProperty.defaultValue]
}
return configProperty.defaultValue;
} else {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<li data-ng-hide="createNew">{{editedProfile.name}}</li>
</ol>

<h1 data-ng-show="createNew">{{:: 'create-client-policies-profile' | translate}}</h1>
<h1 data-ng-show="createNew">{{:: 'create-client-profile' | translate}}</h1>
<h1 data-ng-hide="createNew">{{editedProfile.name|capitalize}}</h1>

<form class="form-horizontal" name="realmForm" novalidate kc-read-only="isReadOnly()">
Expand Down

0 comments on commit 20b29f7

Please sign in to comment.