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 editFWParentListController = function ($scope, $modalInstance, message, PapUrlService, UserInfoService, FWDictionaryService, Notification){
24 if(message.fwDictListDictionaryData==null){
25 $scope.slchoices = [];
26 $scope.alchoices = [];
27 $scope.label='Add Parent List'
29 $scope.label='Edit Parent List'
30 $scope.disableCd=true;
31 $scope.slchoices = [];
32 $scope.alchoices = [];
33 var slList = message.fwDictListDictionaryData.serviceList;
34 var alList = message.fwDictListDictionaryData.addressList;
37 if (slList.indexOf(splitEqual) >= 0) {
38 var splitValue = slList.split(splitEqual);
39 for(i = 0; i < splitValue.length; i++){
40 var key = splitValue[i];
41 $scope.slchoices.push({'id':'choice'+i+1, 'option': key});
45 $scope.slchoices.push({'id':'choice'+1, 'option': key});
49 if (alList.indexOf(splitEqual) >= 0) {
50 var splitALValue = alList.split(splitEqual);
51 for(i = 0; i < splitALValue.length; i++){
52 var key = splitALValue[i];
53 $scope.alchoices.push({'id':'choice'+i+1, 'option': key});
57 $scope.alchoices.push({'id':'choice'+1, 'option': key});
63 PapUrlService.getPapUrl().then(function(data) {
65 papUrl = config.PAP_URL;
68 FWDictionaryService.getServiceListDictionaryDataByName(papUrl).then(function (data) {
70 $scope.data = JSON.parse(j.data);
71 console.log($scope.data);
72 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
73 console.log($scope.serviceListDictionaryDatas);
75 console.log("failed");
78 FWDictionaryService.getAddressGroupDictionaryDataByName(papUrl).then(function (data) {
80 $scope.data = JSON.parse(j.data);
81 console.log($scope.data);
82 $scope.addressGroupDictionaryDatas = JSON.parse($scope.data.addressGroupDictionaryDatas);
83 console.log($scope.addressGroupDictionaryDatas);
85 console.log("failed");
89 /*getting user info from session*/
91 UserInfoService.getFunctionalMenuStaticDetailSession()
92 .then(function (response) {
93 loginId = response.userid;
96 $scope.editParentList = message.fwDictListDictionaryData;
98 $scope.saveFWParentList = function(fwDictListDictionaryData) {
99 var addSLData = extend(fwDictListDictionaryData, $scope.attributeDatas[0]);
100 var finalData = extend(addSLData, $scope.attributeALDatas[0]);
101 var uuu = papUrl + "/ecomp/fw_dictionary/save_FWDictionaryList.htm";
102 var postData={fwDictListDictionaryData: finalData, loginId: loginId};
107 contentType: 'application/json',
108 data: JSON.stringify(postData),
109 success : function(data){
110 $scope.$apply(function(){
111 $scope.fwDictListDictionaryDatas=data.fwDictListDictionaryDatas;});
112 if($scope.fwDictListDictionaryDatas == "Duplicate"){
113 Notification.error("FW DictionaryList Dictionary exists with Same Name.")
115 console.log($scope.fwDictListDictionaryDatas);
116 $modalInstance.close({fwDictListDictionaryDatas:$scope.fwDictListDictionaryDatas});
119 error : function(data){
120 alert("Error while saving.");
125 $scope.close = function() {
126 $modalInstance.close();
129 function extend(obj, src) {
130 for (var key in src) {
131 if (src.hasOwnProperty(key)) obj[key] = src[key];
137 $scope.attributeDatas = [{"attributes" : $scope.slchoices}];
138 $scope.addServiceGroupNewChoice = function() {
139 var newItemNo = $scope.slchoices.length+1;
140 $scope.slchoices.push({'id':'choice'+newItemNo});
142 $scope.removeServiceGroupChoice = function() {
143 var lastItem = $scope.slchoices.length-1;
144 $scope.slchoices.splice(lastItem);
147 $scope.attributeALDatas = [{"alAttributes" : $scope.alchoices}];
148 $scope.addAddressGroupNewChoice = function() {
149 var newItemNo = $scope.alchoices.length+1;
150 $scope.alchoices.push({'id':'choice'+newItemNo});
152 $scope.removeAddressGroupChoice = function() {
153 var lastItem = $scope.alchoices.length-1;
154 $scope.alchoices.splice(lastItem);