[KEYCLOAK-5806] - Changing apply policy component and more tests

This commit is contained in:
pedroigor 2017-12-19 17:28:46 -02:00
parent 2ace312501
commit 3846cfdb4f
4 changed files with 65 additions and 50 deletions

View file

@ -1309,9 +1309,11 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
var policies = [];
if ($scope.selectedPolicies) {
for (i = 0; i < $scope.selectedPolicies.length; i++) {
policies.push($scope.selectedPolicies[i].id);
}
}
$scope.policy.policies = policies;
delete $scope.policy.config;
@ -1355,9 +1357,11 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
var policies = [];
if ($scope.selectedPolicies) {
for (i = 0; i < $scope.selectedPolicies.length; i++) {
policies.push($scope.selectedPolicies[i].id);
}
}
$scope.policy.policies = policies;
delete $scope.policy.config;

View file

@ -55,29 +55,33 @@
<div class="form-group clearfix">
<label class="col-md-2 control-label" for="policies">{{:: 'authz-policy-apply-policy' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." />
<p/>
<table class="table table-striped table-bordered" id="selected-policies">
<table class="table table-striped table-bordered" style="margin-top: 0px" id="selected-policies">
<thead>
<tr>
<th class="kc-table-actions" colspan="3">
<div class="form-inline">
<div class="form-group">
<th class="kc-table-actions" colspan="2">
<div class="form-inline col-md-12" style="width: 107%">
<div class="form-group" style="width: 100%">
<div class="input-group" style="width: 100%">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..."/>
</div>
<div class="pull-right">
</div>
</div>
</th>
<th class="kc-table-actions">
<div class="pull-right" style="width: 100%">
<select id="create-policy" class="form-control" ng-model="policyType"
ng-options="p.name for p in policyProviders track by p.type"
data-ng-change="addPolicy(policyType);">
data-ng-change="addPolicy(policyType);"
data-ng-hide="historyBackOnSaveOrCancel">
<option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
</select>
</div>
</div>
</th>
</tr>
<tr data-ng-hide="!selectedPolicies || selectedPolicies.length == 0">
<th>{{:: 'name' | translate}}</th>
<th>{{:: 'description' | translate}}</th>
<th>{{:: 'actions' | translate}}</th>
<th width="20%">{{:: 'actions' | translate}}</th>
</tr>
</thead>
<tbody>
@ -85,7 +89,7 @@
<td data-ng-hide="historyBackOnSaveOrCancel"><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
<td data-ng-show="historyBackOnSaveOrCancel">{{policy.name}}</td>
<td>{{policy.description}}</td>
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);" style="vertical-align: middle">
{{:: 'remove' | translate}}
</td>
</tr>

View file

@ -59,29 +59,33 @@
<div class="form-group clearfix">
<label class="col-md-2 control-label" for="policies">{{:: 'authz-policy-apply-policy' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." />
<p/>
<table class="table table-striped table-bordered" id="selected-policies">
<table class="table table-striped table-bordered" style="margin-top: 0px" id="selected-policies">
<thead>
<tr>
<th class="kc-table-actions" colspan="3">
<div class="form-inline">
<div class="form-group">
<th class="kc-table-actions" colspan="2">
<div class="form-inline col-md-12" style="width: 107%">
<div class="form-group" style="width: 100%">
<div class="input-group" style="width: 100%">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..."/>
</div>
<div class="pull-right">
</div>
</div>
</th>
<th class="kc-table-actions">
<div class="pull-right" style="width: 100%">
<select id="create-policy" class="form-control" ng-model="policyType"
ng-options="p.name for p in policyProviders track by p.type"
data-ng-change="addPolicy(policyType);">
data-ng-change="addPolicy(policyType);"
data-ng-hide="historyBackOnSaveOrCancel">
<option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
</select>
</div>
</div>
</th>
</tr>
<tr data-ng-hide="!selectedPolicies || selectedPolicies.length == 0">
<th>{{:: 'name' | translate}}</th>
<th>{{:: 'description' | translate}}</th>
<th>{{:: 'actions' | translate}}</th>
<th width="20%">{{:: 'actions' | translate}}</th>
</tr>
</thead>
<tbody>
@ -89,7 +93,7 @@
<td data-ng-hide="historyBackOnSaveOrCancel"><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
<td data-ng-show="historyBackOnSaveOrCancel">{{policy.name}}</td>
<td>{{policy.description}}</td>
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);" style="vertical-align: middle">
{{:: 'remove' | translate}}
</td>
</tr>

View file

@ -35,16 +35,20 @@
<div class="form-group clearfix">
<label class="col-md-2 control-label" for="policies">{{:: 'authz-policy-apply-policy' | translate}} <span class="required">*</span></label>
<div class="col-sm-6">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." data-ng-required="!selectedPolicies || selectedPolicies.length == 0"/>
<p/>
<table class="table table-striped table-bordered" id="selected-policies">
<table class="table table-striped table-bordered" style="margin-top: 0px" id="selected-policies">
<thead>
<tr>
<th class="kc-table-actions" colspan="3">
<div class="form-inline">
<div class="form-group">
<th class="kc-table-actions" colspan="2">
<div class="form-inline col-md-12" style="width: 107%">
<div class="form-group" style="width: 100%">
<div class="input-group" style="width: 100%">
<input type="hidden" ui-select2="policiesUiSelect" id="policies" data-ng-change="selectPolicy(selectedPolicy);" data-ng-model="selectedPolicy" data-placeholder="{{:: 'authz-select-a-policy' | translate}}..." data-ng-required="!selectedPolicies || selectedPolicies.length == 0"/>
</div>
<div class="pull-right">
</div>
</div>
</th>
<th class="kc-table-actions">
<div class="pull-right" style="width: 100%">
<select id="create-policy" class="form-control" ng-model="policyType"
ng-options="p.name for p in policyProviders track by p.type"
data-ng-change="addPolicy(policyType);"
@ -52,13 +56,12 @@
<option value="" disabled selected>{{:: 'authz-create-policy' | translate}}...</option>
</select>
</div>
</div>
</th>
</tr>
<tr data-ng-hide="!selectedPolicies || selectedPolicies.length == 0">
<th>{{:: 'name' | translate}}</th>
<th>{{:: 'description' | translate}}</th>
<th>{{:: 'actions' | translate}}</th>
<th width="20%">{{:: 'actions' | translate}}</th>
</tr>
</thead>
<tbody>
@ -66,7 +69,7 @@
<td data-ng-hide="historyBackOnSaveOrCancel"><a href="" data-ng-click="detailPolicy(policy)">{{policy.name}}</a></td>
<td data-ng-show="historyBackOnSaveOrCancel">{{policy.name}}</td>
<td>{{policy.description}}</td>
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);">
<td class="kc-action-cell" ng-click="removePolicy(selectedPolicies, policy);" style="vertical-align: middle">
{{:: 'remove' | translate}}
</td>
</tr>