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;">
23 <div class="modal__header">
24 <h2 class="font-showcase-font-name" style="width: 500px;">Select Role Functions</h2>
26 <div class="divider-container"><hr> </div>
27 <div class="modal__content">
28 <table table-data="availableRoleFunctions" att-table>
29 <thead att-table-row type="header">
31 <th att-table-header sortable="false" width="10%"> </th>
32 <th att-table-header sortable="false" width="90%">Role Function</th>
35 <tbody att-table-row type="body" row-repeat="availableRoleFunction in availableRoleFunctions track by availableRoleFunction.code" style="max-height: 980px;" >
39 <div ng-click="toggleRoleFunction(availableRoleFunction.selected,availableRoleFunction);">
40 <input type="checkbox" ng-model="availableRoleFunction.selected" att-toggle-main>
43 <td width="90%">{{ availableRoleFunction.name }}</td>
49 <div class="modal__footer">
50 <button class="button button--primary button--small" herf="javascript:void(0)" ng-click="close()">Close</button>
56 <script type="text/ng-template" id="child_roles_popup.html">
57 <div class="modal__informative font-showcase" style="width:700px;">
58 <div class="modal__header">
59 <h2 class="font-showcase-font-name" style="width: 500px;">Select Child Roles</h2>
61 <div class="divider-container"><hr> </div>
62 <div class="modal__content">
63 <table table-data="availableRoles" att-table>
64 <thead att-table-row type="header">
66 <th att-table-header sortable="false" width="10%"> </th>
67 <th att-table-header sortable="false" width="90%">Role</th>
70 <tbody att-table-row type="body" row-repeat="availableRole in availableRoles track by availableRole.id" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
72 <td att-table-body width="10%">
73 <div ng-click="toggleChildRole(availableRole.selected,availableRole);">
74 <input type="checkbox" ng-model="availableRole.selected" att-toggle-main>
77 <td att-table-body width="90%">{{ availableRole.name }}</td>
82 <div class="modal__footer">
83 <button class="button button--primary button--small" herf="javascript:void(0)" ng-click="close()">Close</button>
90 var rolepopupController = function ($scope, $modalInstance, role){
93 if($scope.role.childRoles==null){
94 $scope.role.childRoles=[];
97 $scope.ociavailableRoles=${availableRoles};
98 console.log($scope.ociavailableRoles);
99 $scope.availableRoles=[];
100 if($scope.ociavailableRoles)
101 $.each($scope.ociavailableRoles, function(i, a){
102 var availableRole = a;
103 availableRole.selected = false;
104 if($scope.role.childRoles){
105 $.each($scope.role.childRoles, function(j, b){
107 availableRole.selected = true;
111 $scope.availableRoles.push(availableRole);
115 $scope.ociavailableRoleFunctions=${availableRoleFunctions};
117 $scope.availableRoleFunctions = [];
118 if($scope.ociavailableRoleFunctions)
119 $.each($scope.ociavailableRoleFunctions, function(i, a){
120 var availableRoleFunction = a;
121 availableRoleFunction.selected = false;
122 $.each($scope.role.roleFunctions, function(j, b){
123 if(a.code === b.code) {
124 availableRoleFunction.selected = true;
127 $scope.availableRoleFunctions.push(availableRoleFunction);
131 $scope.toggleRoleFunction = function(selected,availableRoleFunction) {
132 //alert('toggleRole: '+selected);
135 //remove role function
137 var index = $scope.role.roleFunctions.indexOf(availableRoleFunction);
139 $scope.role.roleFunctions.splice(index, 1);
142 var uuu = "role/removeRoleFunction.htm?role_id=${param.role_id}";
143 if (confirm("You are about to remove the role funtcion "+availableRoleFunction.name+" from the role for "+$scope.role.name+". Do you want to continue?")) {
145 var postData={roleFunction:availableRoleFunction};
150 contentType: 'application/json',
151 data: JSON.stringify(postData),
152 success : function(data){
153 $scope.$apply(function(){$scope.role=data.role;});
155 error : function(data){
156 alert("Error while saving.");
160 availableRoleFunction.selected=true;
165 $scope.role.roleFunctions.push(availableRoleFunction);
168 var uuu = "role/addRoleFunction.htm?role_id=${param.role_id}";
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 alert("Error while saving.");
189 $scope.toggleChildRole = function(selected,availableRole) {
190 //alert('toggleRole: '+selected);
195 var index = $scope.role.childRoles.indexOf(availableRole);
197 $scope.role.childRoles.splice(index, 1);
200 var uuu = "role/removeChildRole.htm?role_id=${param.role_id}";
201 if (confirm("You are about to remove the child role "+availableRole.name+" from the role for "+$scope.role.name+". Do you want to continue?")) {
203 var postData={childRole:availableRole};
208 contentType: 'application/json',
209 data: JSON.stringify(postData),
210 success : function(data){
211 console.log('role',data.role);
212 $scope.$apply(function(){$scope.role=data.role;});
214 error : function(data){
215 alert("Error while saving.");
219 availableRole.selected=true;
224 $scope.role.childRoles.push(availableRole);
227 var uuu = "role/addChildRole.htm?role_id=${param.role_id}";
229 var postData={childRole:availableRole};
234 contentType: 'application/json',
235 data: JSON.stringify(postData),
236 success : function(data){
237 $scope.$apply(function(){$scope.role=data.role;});
239 error : function(data){
240 alert("Error while saving.");
249 $scope.close = function() {
250 console.log('role', $scope.role);
251 $modalInstance.close({role:$scope.role});