2 ================================================================================
4 ================================================================================
5 Copyright (C) 2017 AT&T Intellectual Property
6 ================================================================================
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ================================================================================
21 <script type="text/ng-template" id="role_functions_popup.html">
22 <div class="modal__informative font-showcase" style="width:700px;height:500px;overflow:scroll">
23 <div class="modal__header">
24 <h2 class="font-showcase-font-name" style="width: 500px;">Select Role Functions</h2>
26 <button align="right" class="button button--primary button--small" herf="javascript:void(0)" ng-click="close()">Close</button>
27 <div class="divider-container"><hr> </div>
28 <div class="modal__content">
29 <table table-data="availableRoleFunctions" att-table>
30 <thead att-table-row type="header">
32 <th att-table-header sortable="false" width="10%"> </th>
33 <th att-table-header sortable="false" width="90%">Role Function</th>
36 <tbody att-table-row type="body" row-repeat="availableRoleFunction in availableRoleFunctions" style="max-height: 980px;" >
40 <div ng-click="toggleRoleFunction(availableRoleFunction.selected,availableRoleFunction);">
41 <input type="checkbox" ng-model="availableRoleFunction.selected" att-toggle-main>
44 <td width="90%">{{ availableRoleFunction.name }}</td>
54 <script type="text/ng-template" id="child_roles_popup.html">
55 <div class="modal__informative font-showcase" style="width:700px;height:500px;overflow:scroll">
56 <div class="modal__header">
57 <h2 class="font-showcase-font-name" style="width: 500px;">Select Child Roles</h2>
59 <button align="right" class="button button--primary button--small" herf="javascript:void(0)" ng-click="close()">Close</button>
60 <div class="divider-container"><hr> </div>
61 <div class="modal__content">
62 <table table-data="availableRoles" att-table>
63 <thead att-table-row type="header">
65 <th att-table-header sortable="false" width="10%"> </th>
66 <th att-table-header sortable="false" width="90%">Role</th>
69 <tbody att-table-row type="body" row-repeat="availableRole in availableRoles" style="max-height: 980px;" >
71 <td att-table-body width="10%">
72 <div ng-click="toggleChildRole(availableRole.selected,availableRole);">
73 <input type="checkbox" ng-model="availableRole.selected" att-toggle-main>
76 <td att-table-body width="90%">{{ availableRole.name }}</td>
86 var rolepopupController = function ($scope, $modalInstance, role,modalService){
89 if($scope.role.childRoles==null){
90 $scope.role.childRoles=[];
93 $scope.ociavailableRoles=${availableRoles};
94 console.log($scope.ociavailableRoles);
95 $scope.availableRoles=[];
96 if($scope.ociavailableRoles)
97 $.each($scope.ociavailableRoles, function(i, a){
98 var availableRole = a;
99 availableRole.selected = false;
100 if($scope.role.childRoles){
101 $.each($scope.role.childRoles, function(j, b){
103 availableRole.selected = true;
107 $scope.availableRoles.push(availableRole);
111 $scope.ociavailableRoleFunctions=${availableRoleFunctions};
113 $scope.availableRoleFunctions = [];
114 if($scope.ociavailableRoleFunctions)
115 $.each($scope.ociavailableRoleFunctions, function(i, a){
116 var availableRoleFunction = a;
117 availableRoleFunction.selected = false;
118 $.each($scope.role.roleFunctions, function(j, b){
119 if(a.code === b.code) {
120 availableRoleFunction.selected = true;
123 $scope.availableRoleFunctions.push(availableRoleFunction);
127 $scope.toggleRoleFunction = function(selected,availableRoleFunction) {
128 //alert('toggleRole: '+selected);
131 //remove role function
133 var index = $scope.role.roleFunctions.indexOf(availableRoleFunction);
135 $scope.role.roleFunctions.splice(index, 1);
138 var uuu = "role/removeRoleFunction.htm?role_id=${param.role_id}";
139 modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the role function "+availableRoleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?",
141 var postData={roleFunction:availableRoleFunction};
146 contentType: 'application/json',
147 data: JSON.stringify(postData),
148 success : function(data){
149 $scope.$apply(function(){$scope.role=data.role;});
151 error : function(data){
152 modalService.showFailure("Fail","Error while saving.");
158 availableRoleFunction.selected=!availableRoleFunction.selected;
164 $scope.role.roleFunctions.push(availableRoleFunction);
167 var uuu = "role/addRoleFunction.htm?role_id=${param.role_id}";
168 modalService.popupConfirmWinWithCancel("Confirm","You are about to add the role function "+availableRoleFunction.name+" to the role for "+$scope.role.name+". Do you want to continue?",
170 var postData={roleFunction:availableRoleFunction};
175 contentType: 'application/json',
176 data: JSON.stringify(postData),
177 success : function(data){
178 $scope.$apply(function(){$scope.role=data.role;});
180 error : function(data){
181 modalService.showFailure("Fail","Error while saving.");
187 availableRoleFunction.selected=!availableRoleFunction.selected;
195 $scope.toggleChildRole = function(selected,availableRole) {
196 //alert('toggleRole: '+selected);
201 var index = $scope.role.childRoles.indexOf(availableRole);
203 $scope.role.childRoles.splice(index, 1);
206 var uuu = "role/removeChildRole.htm?role_id=${param.role_id}";
207 modalService.popupConfirmWinWithCancel("Confirm","You are about to remove the child role "+availableRole.name+" from the role for "+$scope.role.name+". Do you want to continue?",
209 var postData={childRole:availableRole};
214 contentType: 'application/json',
215 data: JSON.stringify(postData),
216 success : function(data){
217 console.log('role',data.role);
218 $scope.$apply(function(){$scope.role=data.role;});
220 error : function(data){
221 modalService.showFailure("Fail","Error while saving.");
227 availableRole.selected=true;
233 $scope.role.childRoles.push(availableRole);
236 var uuu = "role/addChildRole.htm?role_id=${param.role_id}";
237 modalService.popupConfirmWinWithCancel("Confirm","You are about to add the child role "+availableRole.name+" to the role for "+$scope.role.name+". Do you want to continue?",
239 var postData={childRole:availableRole};
244 contentType: 'application/json',
245 data: JSON.stringify(postData),
246 success : function(data){
247 $scope.$apply(function(){$scope.role=data.role;});
249 error : function(data){
250 modalService.showFailure("Fail","Error while saving.");
256 availableRole.selected=false;
266 $scope.close = function() {
267 console.log('role', $scope.role);
268 $modalInstance.close({role:$scope.role});