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=========================================================
20 app.controller('editFWParentListController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, PolicyAppService, Notification){
21 if(message.fwDictListDictionaryData==null){
22 $scope.slchoices = [];
23 $scope.alchoices = [];
24 $scope.label='Add Parent List'
26 $scope.label='Edit Parent List'
27 $scope.disableCd=true;
28 $scope.slchoices = [];
29 $scope.alchoices = [];
30 var slList = message.fwDictListDictionaryData.serviceList;
31 var alList = message.fwDictListDictionaryData.addressList;
34 if (slList.indexOf(splitEqual) >= 0) {
35 var splitValue = slList.split(splitEqual);
36 for(i = 0; i < splitValue.length; i++){
37 var key = splitValue[i];
38 $scope.slchoices.push({'id':'choice'+i+1, 'option': key});
42 $scope.slchoices.push({'id':'choice'+1, 'option': key});
46 if (alList.indexOf(splitEqual) >= 0) {
47 var splitALValue = alList.split(splitEqual);
48 for(i = 0; i < splitALValue.length; i++){
49 var key = splitALValue[i];
50 $scope.alchoices.push({'id':'choice'+i+1, 'option': key});
54 $scope.alchoices.push({'id':'choice'+1, 'option': key});
59 PolicyAppService.getData('getDictionary/get_ServiceListDictionaryDataByName').then(function (data) {
61 $scope.data = JSON.parse(j.data);
62 console.log($scope.data);
63 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
64 console.log($scope.serviceListDictionaryDatas);
66 console.log("failed");
69 PolicyAppService.getData('getDictionary/get_AddressGroupDictionaryDataByName').then(function (data) {
71 $scope.data = JSON.parse(j.data);
72 console.log($scope.data);
73 $scope.addressGroupDictionaryDatas = JSON.parse($scope.data.addressGroupDictionaryDatas);
74 console.log($scope.addressGroupDictionaryDatas);
76 console.log("failed");
79 /*getting user info from session*/
81 UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
82 .then(function (response) {
83 userid = response.userid;
86 $scope.editParentList = message.fwDictListDictionaryData;
88 $scope.saveFWParentList = function(fwDictListDictionaryData) {
89 var regex = new RegExp("^[a-zA-Z0-9_]*$");
90 if(!regex.test(fwDictListDictionaryData.parentItemName)) {
91 Notification.error("Enter Valid Parent List Name without spaces or special characters");
93 var addSLData = extend(fwDictListDictionaryData, $scope.attributeDatas[0]);
94 var finalData = extend(addSLData, $scope.attributeALDatas[0]);
95 var uuu = "saveDictionary/fw_dictionary/save_FWDictionaryList";
96 var postData={fwDictListDictionaryData: finalData, userid: userid};
101 contentType: 'application/json',
102 data: JSON.stringify(postData),
103 success : function(data){
104 $scope.$apply(function(){
105 $scope.fwDictListDictionaryDatas=data.fwDictListDictionaryDatas;});
106 if($scope.fwDictListDictionaryDatas == "Duplicate"){
107 Notification.error("FW DictionaryList Dictionary exists with Same Name.")
109 console.log($scope.fwDictListDictionaryDatas);
110 $modalInstance.close({fwDictListDictionaryDatas:$scope.fwDictListDictionaryDatas});
113 error : function(data){
114 alert("Error while saving.");
120 $scope.close = function() {
121 $modalInstance.close();
124 function extend(obj, src) {
125 for (var key in src) {
126 if (src.hasOwnProperty(key)) obj[key] = src[key];
132 $scope.attributeDatas = [{"attributes" : $scope.slchoices}];
133 $scope.addServiceGroupNewChoice = function() {
134 var newItemNo = $scope.slchoices.length+1;
135 $scope.slchoices.push({'id':'choice'+newItemNo});
137 $scope.removeServiceGroupChoice = function() {
138 var lastItem = $scope.slchoices.length-1;
139 $scope.slchoices.splice(lastItem);
142 $scope.attributeALDatas = [{"alAttributes" : $scope.alchoices}];
143 $scope.addAddressGroupNewChoice = function() {
144 var newItemNo = $scope.alchoices.length+1;
145 $scope.alchoices.push({'id':'choice'+newItemNo});
147 $scope.removeAddressGroupChoice = function() {
148 var lastItem = $scope.alchoices.length-1;
149 $scope.alchoices.splice(lastItem);