2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
23 var editPEPOptionsController = function ($scope, $modalInstance, message, PapUrlService, UserInfoService, Notification){
24 if(message.pepOptionsDictionaryData==null)
25 $scope.label='Add PEP Options',
28 $scope.label='Edit PEP Options'
29 $scope.disableCd=true;
31 var headers = message.pepOptionsDictionaryData.actions;
32 var SplitChars = ':#@';
33 if (headers.indexOf(SplitChars) >= 0) {
34 var splitHeader = headers.split(SplitChars);
35 var singleHeader = splitHeader;
36 var splitEqual = '=#@';
37 for(i = 0; i < singleHeader.length; i++){
38 if (singleHeader[i].indexOf(splitEqual) >= 0) {
39 var splitValue = singleHeader[i].split(splitEqual);
40 var key = splitValue[0];
41 var value = splitValue[1];
42 var newItemNo = $scope.choices.length+1;
43 $scope.choices.push({'id':'choice'+newItemNo, 'option': key , 'number' : value });
47 var splitEqual = '=#@';
48 if (headers.indexOf(splitEqual) >= 0) {
49 var splitValue = headers.split(splitEqual);
50 var key = splitValue[0];
51 var value = splitValue[1];
52 $scope.choices.push({'id':'choice'+1, 'option': key , 'number' : value });
58 PapUrlService.getPapUrl().then(function(data) {
60 papUrl = config.PAP_URL;
64 /*getting user info from session*/
66 UserInfoService.getFunctionalMenuStaticDetailSession()
67 .then(function (response) {
68 loginId = response.userid;
71 $scope.editPEPOptions = message.pepOptionsDictionaryData;
73 $scope.saveCLPepOptions = function(pepOptionsDictionaryData) {
74 var finalData = extend(pepOptionsDictionaryData, $scope.actions[0]);
75 var uuu = papUrl + "/ecomp/cl_dictionary/save_pepOptions.htm";
76 var postData={pepOptionsDictionaryData: finalData, loginId: loginId};
81 contentType: 'application/json',
82 data: JSON.stringify(postData),
83 success : function(data){
84 $scope.$apply(function(){
85 $scope.pepOptionsDictionaryDatas=data.pepOptionsDictionaryDatas;});
86 if($scope.pepOptionsDictionaryDatas == "Duplicate"){
87 Notification.error("PEP Options Dictionary exists with Same PEP Name.")
89 console.log($scope.pepOptionsDictionaryDatas);
90 $modalInstance.close({pepOptionsDictionaryDatas:$scope.pepOptionsDictionaryDatas});
93 error : function(data){
94 alert("Error while saving.");
99 $scope.close = function() {
100 $modalInstance.close();
103 function extend(obj, src) {
104 for (var key in src) {
105 if (src.hasOwnProperty(key)) obj[key] = src[key];
110 $scope.actions = [{"attributes" : $scope.choices}];
111 $scope.addNewChoice = function() {
112 var newItemNo = $scope.choices.length+1;
113 $scope.choices.push({'id':'choice'+newItemNo});
115 $scope.removeChoice = function() {
116 var lastItem = $scope.choices.length-1;
117 $scope.choices.splice(lastItem);