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 * ================================================================================
20 app.controller('AdminMenuEditController', function ($scope, AdminService, modalService, $modal, $route){
21 $( "#dialog" ).hide();
23 /* AdminService.getRoleFunctionList().then(function(data){
26 $scope.data = JSON.parse(j.data);
27 $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions);
32 console.log("failed");
35 $scope.init = function () {
36 $scope.numberOfRecordstoShow=20;
37 AdminService.getFnMenuItems().then(function(data){
39 $scope.data =JSON.parse(j.data);
40 $scope.fnMenuItems =($scope.data.fnMenuItems);
43 console.log("failed");
48 $scope.mapActiveStatus = function(status){
58 $scope.addNewFnMenuItemModalPopup = function(availableFnMenuItem) {
59 $scope.editFnMenuItem = null;
60 var modalInstance = $modal.open({
61 templateUrl: 'fn_menu_add_popup.html',
62 controller: 'fn_menu_popupController',
64 message: function () {
66 availableFnMenuItem: $scope.editFnMenuItem
72 modalInstance.result.then(function(response){
73 console.log('response', response);
74 $scope.availableFnMenuItems=response.availableFnMenuItems;
79 $scope.removeMenuItem = function(fnMenuItem) {
80 modalService.popupConfirmWin("Confirm","You are about to delete the menu item "+fnMenuItem.label+". Do you want to continue?",
82 var uuu = "admin_fn_menu/removeMenuItem.htm";
83 var postData={fnMenuItem: fnMenuItem};
88 contentType: 'application/json',
89 data: JSON.stringify(postData),
90 success : function(data){
91 $scope.$apply(function(){$scope.fnMenuItem=data.fnMenuItem;});
94 error : function(data){
96 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
104 $scope.editRoleFunction = null;
106 $scope.editRoleFunctionPopup = function(availableRoleFunction) {
107 $scope.editRoleFunction = availableRoleFunction;
108 $( "#dialog" ).dialog({
113 $scope.editMenuItemModalPopup = function(availableFnMenuItem) {
114 $scope.editFnMenuItem = availableFnMenuItem;
115 var modalInstance = $modal.open({
116 templateUrl: 'fn_menu_add_popup.html',
117 controller: 'fn_menu_popupController',
119 message: function () {
121 availableFnMenuItem: $scope.editFnMenuItem
127 modalInstance.result.then(function(response){
128 $scope.availableFnMenuItems=response.availableFnMenuItems;
133 $scope.editRoleFunctionModalPopup = function(availableRoleFunction) {
134 $scope.editRoleFunction = availableRoleFunction;
135 var modalInstance = $modal.open({
136 templateUrl: 'edit_role_function_popup.html',
137 controller: 'rolefunctionpopupController',
139 message: function () {
141 availableRoleFunction: $scope.editRoleFunction
147 modalInstance.result.then(function(response){
148 console.log('response', response);
149 $scope.availableRoleFunctions=response.availableRoleFunctions;
153 $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) {
154 $scope.editRoleFunction = null;
155 var modalInstance = $modal.open({
156 templateUrl: 'edit_role_function_popup.html',
157 controller: 'rolefunctionpopupController',
159 message: function () {
161 availableRoleFunction: $scope.editRoleFunction
167 modalInstance.result.then(function(response){
168 console.log('response', response);
169 $scope.availableRoleFunctions=response.availableRoleFunctions;
173 $scope.addNewRoleFunctionPopup = function() {
174 $scope.editRoleFunction = null;
175 $( "#dialog" ).dialog({
180 $scope.saveRoleFunction = function(availableRoleFunction) {
181 var uuu = "role_function_list/saveRoleFunction.htm";
182 var postData={availableRoleFunction: availableRoleFunction};
187 contentType: 'application/json',
188 data: JSON.stringify(postData),
189 success : function(data){
190 $scope.$apply(function(){
191 $scope.availableRoleFunctions=[];$scope.$apply();
192 $scope.availableRoleFunctions=data.availableRoleFunctions;});
193 //alert("Update Successful.") ;
194 console.log($scope.availableRoleFunctions);
196 $scope.editRoleFunction = null;
197 $( "#dialog" ).dialog("close");
199 error : function(data){
200 modalService.showFailure("Fail","Error while saving.");
206 $scope.removeRole = function(availableRoleFunction) {
207 modalService.popupConfirmWin("Confirm","You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?",
209 var uuu = "role_function_list/removeRoleFunction.htm";
210 var postData={availableRoleFunction: availableRoleFunction};
215 contentType: 'application/json',
216 data: JSON.stringify(postData),
217 success : function(data){
218 $scope.$apply(function(){$scope.availableRoleFunctions=data.availableRoleFunctions;});
220 error : function(data){
222 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);