| @@ 1-159 (lines=159) @@ | ||
| 1 | "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 | ||
| @@ 1-152 (lines=152) @@ | ||
| 1 | "use strict"; |
|
| 2 | app.controller('thirdPartyEntry2CreateController', ['$scope', '$state', 'Security', 'MessageService', function ($scope, $state, Security, MessageService) { |
|
| 3 | $scope.directiveScopeDict = {}; |
|
| 4 | $scope.directiveCtrlDict = {}; |
|
| 5 | ||
| 6 | function Initialize(){ |
|
| 7 | var processForm = {}; |
|
| 8 | ||
| 9 | $scope.processForm = processForm; |
|
| 10 | $scope.processForm.Record = {}; |
|
| 11 | } |
|
| 12 | Initialize(); |
|
| 13 | ||
| 14 | $scope.BackToParentState = function(){ |
|
| 15 | $state.go('rc-55-list-third-party'); |
|
| 16 | } |
|
| 17 | ||
| 18 | $scope.EventListener = function(scope, iElement, iAttrs, controller){ |
|
| 19 | var tagName = iElement[0].tagName.toLowerCase(); |
|
| 20 | var prgmID = scope.programId; |
|
| 21 | var scopeID = scope.$id; |
|
| 22 | var hashID = tagName + '_' + prgmID; |
|
| 23 | ||
| 24 | if($scope.directiveScopeDict[hashID] == null || typeof($scope.directiveScopeDict[hashID]) == "undefined"){ |
|
| 25 | $scope.directiveScopeDict[hashID] = scope; |
|
| 26 | $scope.directiveCtrlDict[hashID] = controller; |
|
| 27 | ||
| 28 | } |
|
| 29 | ||
| 30 | iElement.ready(function() { |
|
| 31 | if(tagName=="process"){ |
|
| 32 | $scope.GetThirdPartyRecord(); |
|
| 33 | $scope.ResetForm(); |
|
| 34 | } |
|
| 35 | }) |
|
| 36 | } |
|
| 37 | ||
| 38 | $scope.GetThirdPartyRecord = function(){ |
|
| 39 | var name = "process_dp54tp" |
|
| 40 | ||
| 41 | $scope.directiveCtrlDict[name].ngModel.InquiryCriteria.Action = "create"; |
|
| 42 | ||
| 43 | $scope.directiveScopeDict[name].InquiryData(); |
|
| 44 | } |
|
| 45 | $scope.ResetForm = function(){ |
|
| 46 | var name = "process_dp54tp" |
|
| 47 | $scope.directiveCtrlDict[name].ngModel.ProcessRecord = {Name: ""}; |
|
| 48 | } |
|
| 49 | ||
| 50 | $scope.SetDefaultValue = function(scope, iElement, iAttrs, controller){ |
|
| 51 | ||
| 52 | } |
|
| 53 | ||
| 54 | $scope.StatusChange = function(fieldName, newValue, newObj, scope, iElement, iAttrs, controller){ |
|
| 55 | } |
|
| 56 | ||
| 57 | $scope.ValidateBuffer = function(scope, iElement, iAttrs, controller){ |
|
| 58 | return true; |
|
| 59 | } |
|
| 60 | $scope.CustomInquiryDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){ |
|
| 61 | if(responseObj.data.computerLanguage.num_rows){ |
|
| 62 | /* |
|
| 63 | ctrl.ThirdParty = responseObj.data.thirdParty.data[0]; |
|
| 64 | ||
| 65 | ctrl.ngModel.ProcessRecord = ctrl.ThirdParty; |
|
| 66 | */ |
|
| 67 | console.dir(scope) |
|
| 68 | console.dir(ctrl) |
|
| 69 | //ctrl.ngModel.ProcessRecord = Object.assign({}, ctrl.ThirdParty); |
|
| 70 | //ctrl.ngModel.ProcessRecord = ctrl.ThirdParty; |
|
| 71 | ctrl.ngModel.ProcessCriteria.ThirdPartyLang = []; |
|
| 72 | ||
| 73 | ctrl.ThirdPartyLang = responseObj.data.thirdPartyLang.data; |
|
| 74 | ctrl.ComputerLanguage = ExtractComputerLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data); |
|
| 75 | ctrl.ngModel.ProcessCriteria.ThirdPartyLang = ExtractThirdPartyLang(responseObj.data.computerLanguage.data, responseObj.data.thirdPartyLang.data); |
|
| 76 | } |
|
| 77 | ||
| 78 | } |
|
| 79 | ||
| 80 | function ExtractComputerLang(comLangRows, thirdPartyLang){ |
|
| 81 | var name = "process_dp54tp"; |
|
| 82 | var ctrl = $scope.directiveCtrlDict[name]; |
|
| 83 | ||
| 84 | var langArray = comLangRows.slice(); |
|
| 85 | ||
| 86 | // use forEach() will actual update the array |
|
| 87 | langArray.forEach(comLangObj => { |
|
| 88 | comLangObj.isSelect = false; |
|
| 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.CreateData = function(){ |
|
| 132 | var name = "process_dp54tp"; |
|
| 133 | var scope = $scope.directiveScopeDict[name]; |
|
| 134 | var ctrl = $scope.directiveCtrlDict[name]; |
|
| 135 | ctrl.ngModel.ProcessCriteria.Editmode = "create"; |
|
| 136 | scope.SubmitData(); |
|
| 137 | } |
|
| 138 | ||
| 139 | $scope.CustomSubmitDataResult = function(responseObj, httpStatusCode, scope, iElement, attrs, ctrl){ |
|
| 140 | //$scope.GetThirdPartyRecord(); |
|
| 141 | ||
| 142 | if(responseObj.status == "success"){ |
|
| 143 | $scope.ResetForm(); |
|
| 144 | //$scope.GetThirdPartyRecord(); |
|
| 145 | ||
| 146 | ctrl.ComputerLanguage.forEach(comLangObj => { |
|
| 147 | comLangObj.isSelect = false; |
|
| 148 | }); |
|
| 149 | ctrl.ngModel.ProcessCriteria.ThirdPartyLang = []; |
|
| 150 | } |
|
| 151 | } |
|
| 152 | }]); |
|
| 153 | ||