nexus site path corrected
[portal.git] / ecomp-portal-BE / war / WEB-INF / fusion / jsp / role_function_list.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal
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
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
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   ================================================================================
19   --%>
20
21 <%-- <%@ include file="/WEB-INF/fusion/jsp/include.jsp" %> --%>
22       
23 <%@ taglib prefix="c"      uri="http://java.sun.com/jsp/jstl/core" %>
24 <%@ taglib prefix="fmt"    uri="http://java.sun.com/jsp/jstl/fmt" %>
25 <%@ taglib prefix="fn"     uri="http://java.sun.com/jsp/jstl/functions" %>
26
27 <link rel="stylesheet" type="text/css" href="static/ebz/sandbox.css"  >
28 <link rel="stylesheet" type="text/css" href="static/fusion/css/jquery-ui.css">
29
30 <script src= "static/ebz/angular_js/angular.js"></script> 
31 <script src= "static/ebz/angular_js/angular-sanitize.js"></script>
32 <script src= "static/ebz/angular_js/att_abs_tpls.js"></script>
33 <script src= "static/ebz/angular_js/app.js"></script>
34 <script src= "static/ebz/angular_js/gestures.js"></script>
35
36 <script src="static/js/jquery-1.10.2.js"></script>
37 <script src="static/js/modalService.js"></script>
38 <script src="static/js/jquery.mask.min.js" type="text/javascript"></script>
39 <script src="static/js/jquery-ui.js" type="text/javascript"></script>
40 <%@ include file="/WEB-INF/fusion/jsp/popup_modal_rolefunction.html" %>
41 <div ng-controller="roleFunctionListController" >       
42         <div class="pageTitle">
43
44                 <h1 class="heading1" style="margin-top:20px;">Role Functions</h1>
45                 
46                 <a ng-click="addNewRoleFunctionModalPopup();" class="icon-add" size="small" ></a>
47          <br><br>
48                 
49         </div>
50          
51         <br>
52         Click on the edit icon to update a role function, the plus icon to add additional role functions, or the delete icon to remove them.
53         <br>
54         <div id="rolesTable" title="Role Functions">
55           <table att-table table-data="availableRoleFunctions" current-page="1">
56                 <thead att-table-row type="header">
57                         <tr>
58                                 <th att-table-header width="70%">Name</th>
59                                 <th att-table-header width="10%">Code</th>
60                                 <th att-table-header width="10%">Edit?</th>
61                                 <th att-table-header width="10%">Delete?</th>
62                         </tr>
63                 </thead>
64                 <tbody att-table-row type="body" row-repeat="availableRoleFunction in availableRoleFunctions" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->
65                   <tr>
66                     <td att-table-body width="70%">{{ availableRoleFunction.name }}</td>
67                     <td att-table-body width="10%">{{ availableRoleFunction.code }}</td>
68                     <td att-table-body width="10%">
69                     <!-- <a ng-click="editRoleFunctionPopup(availableRoleFunction);" >
70                     <img src="static/fusion/images/editicon.gif">
71                     </a> -->
72                     <div ng-click="editRoleFunctionModalPopup(availableRoleFunction);" style="font-size:20px;"><a href="javascript:void(0)" class="icon-edit"></a></div>
73                     </td>
74                      <td att-table-body width="10%">
75                         <!-- <a ng-click="removeRole(availableRoleFunction);" ><img src="static/fusion/images/deleteicon.gif"></a> -->
76                         <div ng-click="removeRole(availableRoleFunction);" style="font-size:20px;"><a href="javascript:void(0)" class="icon-trash"></a></div>
77                      </td>
78                   </tr>
79                 </tbody>
80                 </table>
81         </div>
82         
83 <!--    <div align="left" style="marin-bottom: 50px;"> -->
84 <!--            <button type="submit" onClick="window.location='role_function.htm';" att-button -->
85 <!--                    btn-type="primary" size="small">Create</button> -->
86 <!--    </div> -->
87         
88         <div id="dialog" title="Add Role Function">
89                 
90                 <div class="fn-ebz-container" >
91                 <label class="fn-ebz-text-label"><sup><b>*</b></sup>Name:</label><br>
92                 <input type="text" class="fn-ebz-text" ng-model="editRoleFunction.name"
93                         maxlength="30" /> 
94                 </div>
95                 <br/>
96                 <div class="fn-ebz-container" >
97                 <label class="fn-ebz-text-label"><sup><b>*</b></sup>Code:</label><br>
98                 <input type="text" class="fn-ebz-text" ng-model="editRoleFunction.code" ng-disabled="editRoleFunction.code!=null"
99                         maxlength="30" /> 
100                 </div>
101                 <br/>
102                 <button type="submit" ng-click="saveRoleFunction(editRoleFunction);" att-button
103                         btn-type="primary" size="small">Save</button>
104                 
105         </div>
106         
107 </div>
108
109
110
111
112 <script>
113 app.controller('roleFunctionListController', function ($scope, modalService, $modal){
114         $( "#dialog" ).hide();
115         $scope.availableRoleFunctions=${availableRoleFunctions};
116         
117         
118         $scope.editRoleFunction = null;
119         var dialog = null;
120         $scope.editRoleFunctionPopup = function(availableRoleFunction) {
121                 $scope.editRoleFunction = availableRoleFunction;
122                 $( "#dialog" ).dialog({
123                       modal: true
124             });
125         };
126         
127         $scope.editRoleFunctionModalPopup = function(availableRoleFunction) {
128                 $scope.editRoleFunction = availableRoleFunction;
129                 var modalInstance = $modal.open({
130                     templateUrl: 'edit_role_function_popup.html',
131                     controller: 'rolefunctionpopupController',
132                     resolve: {
133                         message: function () {
134                                 var message = {
135                                                 availableRoleFunction: $scope.editRoleFunction
136                                 };
137                           return message;
138                         }                                       
139                       }
140                   }); 
141                 modalInstance.result.then(function(response){
142             console.log('response', response);
143             $scope.availableRoleFunctions=response.availableRoleFunctions;
144         });
145         };
146         
147         $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) {
148                 $scope.editRoleFunction = null;
149                 var modalInstance = $modal.open({
150                     templateUrl: 'edit_role_function_popup.html',
151                     controller: 'rolefunctionpopupController',
152                     resolve: {
153                         message: function () {
154                                 var message = {
155                                                 availableRoleFunction: $scope.editRoleFunction
156                                 };
157                           return message;
158                         }                                       
159                       }
160                   }); 
161                 modalInstance.result.then(function(response){
162             console.log('response', response);
163             $scope.availableRoleFunctions=response.availableRoleFunctions;
164         });
165         };
166         
167         $scope.addNewRoleFunctionPopup = function() {
168                 $scope.editRoleFunction = null;
169                 $( "#dialog" ).dialog({
170                       modal: true
171             });
172         };
173         
174         $scope.saveRoleFunction = function(availableRoleFunction) {
175                   var uuu = "role_function_list/saveRoleFunction.htm";
176                   var postData={availableRoleFunction: availableRoleFunction};
177                   $.ajax({
178                          type : 'POST',
179                          url : uuu,
180                          dataType: 'json',
181                          contentType: 'application/json',
182                          data: JSON.stringify(postData),
183                          success : function(data){
184                                 $scope.$apply(function(){
185                                         $scope.availableRoleFunctions=[];$scope.$apply();
186                                         $scope.availableRoleFunctions=data.availableRoleFunctions;});  
187                                 //alert("Update Successful.") ;
188                                 console.log($scope.availableRoleFunctions);
189                                 
190                                 $scope.editRoleFunction = null;
191                                 $( "#dialog" ).dialog("close");
192                          },
193                          error : function(data){
194                                  alert("Error while saving.");
195                          }
196                   });
197                 };
198         
199                 
200                 $scope.removeRole = function(availableRoleFunction) {
201                         if (confirm("You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?")) {
202                                 //alert('deleted'+roleFunction.name);
203                                 var uuu = "role_function_list/removeRoleFunction.htm";
204                                   var postData={availableRoleFunction: availableRoleFunction};
205                                   $.ajax({
206                                          type : 'POST',
207                                          url : uuu,
208                                          dataType: 'json',
209                                          contentType: 'application/json',
210                                          data: JSON.stringify(postData),
211                                          success : function(data){
212                                                 $scope.$apply(function(){$scope.availableRoleFunctions=data.availableRoleFunctions;});  
213                                          },
214                                          error : function(data){
215                                                  console.log(data);
216                                                  alert("Error while deleting: "+ data.responseText);
217                                          }
218                                   });
219                         }
220                         
221                 };
222                 
223
224 });
225 </script>