1
|
|
View Code Duplication |
"use strict"; |
2
|
|
|
app.controller('thirdPartyEntry2EntryController', ['$scope', '$state', 'Security', function ($scope, $state, Security, $rootScope) { |
3
|
|
|
$scope.directiveScopeDict = {}; |
4
|
|
|
$scope.directiveCtrlDict = {}; |
5
|
|
|
|
6
|
|
|
$scope.thirdPartyID = $state.params.thirdPartyID; |
7
|
|
|
|
8
|
|
|
function Initialize(){ |
9
|
|
|
var processForm = {}; |
10
|
|
|
|
11
|
|
|
$scope.processForm = processForm; |
12
|
|
|
$scope.processForm.Record = {}; |
13
|
|
|
} |
14
|
|
|
Initialize(); |
15
|
|
|
|
16
|
|
|
$scope.BackToParentState = function(){ |
17
|
|
|
$state.go('^'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
$scope.EventListener = function(scope, iElement, iAttrs, controller){ |
21
|
|
|
var tagName = iElement[0].tagName.toLowerCase(); |
22
|
|
|
var prgmID = scope.programId; |
23
|
|
|
var scopeID = scope.$id; |
|
|
|
|
24
|
|
|
var hashID = tagName + '_' + prgmID; |
25
|
|
|
|
26
|
|
|
if($scope.directiveScopeDict[hashID] == null || typeof($scope.directiveScopeDict[hashID]) == "undefined"){ |
27
|
|
|
$scope.directiveScopeDict[hashID] = scope; |
28
|
|
|
$scope.directiveCtrlDict[hashID] = controller; |
29
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
iElement.ready(function() { |
33
|
|
|
if(tagName=="process"){ |
34
|
|
|
$scope.GetThirdPartyRecord(); |
35
|
|
|
} |
36
|
|
|
}) |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$scope.GetThirdPartyRecord = function(){ |
40
|
|
|
var name = "process_dp54tp" |
41
|
|
|
$scope.directiveCtrlDict[name].ngModel.Record.ThirdPartyID = $scope.thirdPartyID; |
42
|
|
|
$scope.directiveCtrlDict[name].ngModel.InquiryCriteria.Action = "amend"; |
43
|
|
|
|
44
|
|
|
$scope.directiveScopeDict[name].InquiryData(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$scope.SetDefaultValue = function(scope, iElement, iAttrs, controller){ |
48
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$scope.StatusChange = function(fieldName, newValue, newObj, scope, iElement, iAttrs, controller){ |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$scope.ValidateBuffer = function(scope, iElement, iAttrs, controller){ |
55
|
|
|
return true; |
56
|
|
|
} |
57
|
|
|
$scope.CustomInquiryDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){ |
58
|
|
|
if(responseObj.data.thirdParty.num_rows){ |
59
|
|
|
ctrl.ThirdParty = responseObj.data.thirdParty.data[0]; |
60
|
|
|
|
61
|
|
|
ctrl.ngModel.ProcessRecord = ctrl.ThirdParty; |
62
|
|
|
ctrl.ngModel.ProcessCriteria.ThirdPartyLang = []; |
63
|
|
|
|
64
|
|
|
if(responseObj.data.computerLanguage.num_rows){ |
65
|
|
|
ctrl.ThirdPartyLang = responseObj.data.thirdPartyLang.data; |
66
|
|
|
ctrl.ComputerLanguage = ExtractComputerLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data); |
67
|
|
|
ctrl.ngModel.ProcessCriteria.ThirdPartyLang = ExtractThirdPartyLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
function ExtractComputerLang(comLangRows, thirdPartyLang){ |
74
|
|
|
var name = "process_dp54tp"; |
75
|
|
|
var ctrl = $scope.directiveCtrlDict[name]; |
|
|
|
|
76
|
|
|
|
77
|
|
|
var langArray = comLangRows.slice(); |
78
|
|
|
|
79
|
|
|
// use forEach() will actual update the array |
80
|
|
|
langArray.forEach(comLangObj => { |
81
|
|
|
var thirdPartLangObj = thirdPartyLang.filter(x => x.LanguageID === comLangObj.LanguageID); |
82
|
|
|
|
83
|
|
|
// if exist in thirdPartyLang set true |
84
|
|
|
if(Object.keys(thirdPartLangObj).length === 0){ |
85
|
|
|
comLangObj.isSelect = false; |
86
|
|
|
}else{ |
87
|
|
|
comLangObj.isSelect = true; |
88
|
|
|
} |
89
|
|
|
}); |
90
|
|
|
return langArray; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
function ExtractThirdPartyLang(comLangRows, thirdPartyLang){ |
94
|
|
|
var name = "process_dp54tp"; |
95
|
|
|
var ctrl = $scope.directiveCtrlDict[name]; |
|
|
|
|
96
|
|
|
|
97
|
|
|
var langArray = comLangRows.slice(); |
98
|
|
|
|
99
|
|
|
// use forEach() will actual update the array |
100
|
|
|
langArray.forEach(comLangObj => { |
101
|
|
|
var thirdPartLangObj = thirdPartyLang.filter(x => x.LanguageID === comLangObj.LanguageID); |
102
|
|
|
|
103
|
|
|
// if exist in thirdPartyLang, assign to processCriteria |
104
|
|
|
if(Object.keys(thirdPartLangObj).length === 0){ |
|
|
|
|
105
|
|
|
}else{ |
106
|
|
|
comLangObj.isSelect = true; |
107
|
|
|
//ctrl.ngModel.ProcessCriteria.ThirdPartyLang.push(comLangObj); |
108
|
|
|
} |
109
|
|
|
}); |
110
|
|
|
var selectedLangArray = langArray.filter(x => x.isSelect == true); |
111
|
|
|
return selectedLangArray; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
$scope.ToggleThirdPartyLang = function(comLangRow){ |
115
|
|
|
var name = "process_dp54tp"; |
116
|
|
|
var ctrl = $scope.directiveCtrlDict[name]; |
117
|
|
|
var thirdPartyLangArray = ctrl.ngModel.ProcessCriteria.ThirdPartyLang; |
118
|
|
|
comLangRow.isSelect = !comLangRow.isSelect; |
119
|
|
|
|
120
|
|
|
// remove from ProcessCriteria |
121
|
|
|
var selectedLangArray = thirdPartyLangArray.filter(x => x.LanguageID != comLangRow.LanguageID); |
122
|
|
|
|
123
|
|
|
// add to ProcessCriteria |
124
|
|
|
if(comLangRow.isSelect){ |
125
|
|
|
selectedLangArray.push(comLangRow); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
ctrl.ngModel.ProcessCriteria.ThirdPartyLang = selectedLangArray; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
$scope.UpdateData = function(){ |
132
|
|
|
var name = "process_dp54tp"; |
133
|
|
|
var scope = $scope.directiveScopeDict[name]; |
134
|
|
|
var ctrl = $scope.directiveCtrlDict[name]; |
135
|
|
|
ctrl.ngModel.ProcessCriteria.Editmode = "amend"; |
136
|
|
|
scope.SubmitData(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
$scope.DeleteData = function(){ |
140
|
|
|
var name = "process_dp54tp"; |
141
|
|
|
var scope = $scope.directiveScopeDict[name]; |
142
|
|
|
var ctrl = $scope.directiveCtrlDict[name]; |
143
|
|
|
ctrl.ngModel.ProcessCriteria.Editmode = "delete"; |
144
|
|
|
|
145
|
|
|
scope.SubmitData(); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
$scope.CustomSubmitDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){ |
149
|
|
|
//$scope.GetThirdPartyRecord(); |
150
|
|
|
var editmode = ctrl.ngModel.ProcessCriteria.Editmode; |
151
|
|
|
|
152
|
|
|
if(editmode == "delete"){ |
153
|
|
|
if(responseObj.status == "success"){ |
154
|
|
|
$scope.BackToParentState(); |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
}]); |
160
|
|
|
|