[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,8 +1309,10 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
var policies = []; var policies = [];
for (i = 0; i < $scope.selectedPolicies.length; i++) { if ($scope.selectedPolicies) {
policies.push($scope.selectedPolicies[i].id); for (i = 0; i < $scope.selectedPolicies.length; i++) {
policies.push($scope.selectedPolicies[i].id);
}
} }
$scope.policy.policies = policies; $scope.policy.policies = policies;
@ -1355,8 +1357,10 @@ module.controller('ResourceServerPolicyScopeDetailCtrl', function($scope, $route
var policies = []; var policies = [];
for (i = 0; i < $scope.selectedPolicies.length; i++) { if ($scope.selectedPolicies) {
policies.push($scope.selectedPolicies[i].id); for (i = 0; i < $scope.selectedPolicies.length; i++) {
policies.push($scope.selectedPolicies[i].id);
}
} }
$scope.policy.policies = policies; $scope.policy.policies = policies;

View file

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

View file

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

View file

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