Remove unused vars and methods
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / dictionaryController / DecisionRainyDayDictController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017, 2019 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20 app.controller('editRainyDayDictController' , function ($scope, $modalInstance, message, UserInfoServiceDS2, Notification){
21
22         if(message.rainyDayDictionaryData==null)
23         $scope.label='Add Allowed Treatments',
24         $scope.treatments = [];
25     else{
26         $scope.treatments = [];
27         $scope.label='Edit Treatment'
28         $scope.disableCd=true;
29         var headers = message.rainyDayDictionaryData.treatments;
30         var splitEqual = ',';
31         if(headers != null && headers != ""){
32                 if (headers.indexOf(splitEqual) >= 0) {
33                         var splitValue = headers.split(splitEqual);
34                         for(i = 0; i < splitValue.length; i++){
35                                 var key  = splitValue[i];
36                                 $scope.treatments.push({'treatment': key});
37                         }
38                 }else{
39                  var key  = headers;
40                  $scope.treatments.push({'treatment': key});
41             }
42         }
43     }
44     
45         
46         /*getting user info from session*/
47         var userid = null;
48         UserInfoServiceDS2.getFunctionalMenuStaticDetailSession()
49                 .then(function (response) {                     
50                         userid = response.userid;               
51          });
52     
53     $scope.editRainyDayTreatment = message.rainyDayDictionaryData;
54     $scope.saveDecisionTreatments = function(rainyDayDictionaryData) {
55                 var uuu = "saveDictionary/decision_dictionary/save_RainyDay";
56                 var postData={rainyDayDictionaryData: rainyDayDictionaryData, userid: userid};
57                 $.ajax({
58                         type : 'POST',
59                         url : uuu,
60                         dataType: 'json',
61                         contentType: 'application/json',
62                         data: JSON.stringify(postData),
63                         success : function(data){
64                                 $scope.$apply(function(){
65                                         $scope.rainyDayDictionaryDatas=data.rainyDayDictionaryDatas;});
66                                 if($scope.rainyDayDictionaryDatas == "Duplicate"){
67                                         Notification.error("Allowed Treatments Dictionary exists with Same Building Block and Workstep.")
68                                 }else{      
69                                         console.log($scope.rainyDayDictionaryDatas);
70                                         $modalInstance.close({rainyDayDictionaryDatas:$scope.rainyDayDictionaryDatas});
71                                 }
72                         },
73                         error : function(data){
74                                 alert("Error while saving.");
75                         }
76                 });
77     };
78     
79     $scope.treatmentDatas = [{"userDataTypeValues" : $scope.treatments}];
80     $scope.addNewTreatment = function() {
81       $scope.treatments.push({});
82     };    
83     $scope.removeTreatment = function() {
84       var lastItem = $scope.treatments.length-1;
85       $scope.treatments.splice(lastItem);
86     };
87     
88
89     $scope.close = function() {
90         $modalInstance.close();
91     };
92 });