2 * ================================================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ================================================================================
\r
20 app.controller('rolefunctionpopupController', function ($scope, confirmBoxService, message, $http,RoleService, conf, isEditing){
\r
21 if(message.availableRoleFunction==null) {
\r
22 $scope.label='Add Role Function';
\r
26 $scope.label='Edit Role Function'
\r
27 $scope.disableCd=true;
\r
28 var tempText = new String(message.availableRoleFunction.name);
\r
29 $scope.editRoleFunction = angular.copy(message.availableRoleFunction);
\r
32 $scope.tempText = tempText;
\r
33 $scope.isEditing = isEditing;
\r
35 $scope.saveRoleFunction = function(availableRoleFunction) {
\r
36 var uuu = conf.api.saveRoleFunction;
\r
37 var postData={availableRoleFunction: availableRoleFunction};
\r
39 if(availableRoleFunction==null){
\r
40 confirmBoxService.showInformation("Please enter valid role function details.");
\r
42 var exists = false,x;
\r
43 for(x in message.availableRoleFunctions){
\r
44 console.log(message.availableRoleFunctions[x].name);
\r
45 if(message.availableRoleFunctions[x].name==availableRoleFunction.name){
\r
46 confirmBoxService.showInformation("Role Function already exists.");
\r
48 availableRoleFunction.name = $scope.tempText;
\r
52 if (message.availableRoleFunctions[x].code == availableRoleFunction.code) {
\r
53 confirmBoxService.showInformation("Code already exists. Please create a role function with a different code to proceed.");
\r
55 availableRoleFunction.name = $scope.tempText;
\r
61 if(!exists && availableRoleFunction.name.trim() != '' && availableRoleFunction.code.trim() != ''){
\r
62 $http.post(uuu, JSON.stringify(postData)).then(function(res){
\r
63 console.log("data");
\r
64 // console.log(res.data);
\r
65 // $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions;
\r
66 RoleService.getRoleFunctionList().then(function(data){
\r
69 $scope.data = JSON.parse(j.data);
\r
70 $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions);
\r
72 //$scope.resetMenu();
\r
73 $scope.closeThisDialog({result: true, availableRoleFunctions: $scope.availableRoleFunctions });
\r
75 console.log("failed");
\r
77 $scope.closeThisDialog(true);
\r
91 $scope.close = function() {
\r
92 this.closeThisDialog(true);
\r