modified code according to data

parent c4cdf947
...@@ -184,6 +184,15 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -184,6 +184,15 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$mdSelect.hide(); $mdSelect.hide();
} }
var getDeliveryManagersFromService = function(){
var managerIds = [];
dataToPass.deliveryManagers.forEach(function(manager){
managerIds.push(manager.employeeId);
})
return managerIds;
}
var confirmationMsg = function(){ var confirmationMsg = function(){
$mdDialog.show($mdDialog.confirm({ $mdDialog.show($mdDialog.confirm({
...@@ -208,8 +217,8 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -208,8 +217,8 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
} }
} }
else{ else{
var record = {"accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.managersSelectedList}; var dataRequired = {"accountName":dataToPass.accountName,"industryType":dataToPass.industryType,"clientAddress":dataToPass.clientAddress,"deliveryManagers":getDeliveryManagersFromService()};
var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,record); var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,dataRequired);
if(isFormUpated == true){ if(isFormUpated == true){
confirmationMsg(); confirmationMsg();
} }
...@@ -269,11 +278,6 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -269,11 +278,6 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
ev.stopPropagation(); ev.stopPropagation();
}); });
$scope.validateFields = function(action){
var managersSelectedList = $scope.managersSelectedList;
var accountName = $scope.accountName;
var industryType = $scope.industryType;
var clientAddress = $scope.clientAddress;
$scope.accountManagers = function(){ $scope.accountManagers = function(){
var employeeIdsArray = []; var employeeIdsArray = [];
for(i=0;i< $scope.managersSelectedList.length;i++){ for(i=0;i< $scope.managersSelectedList.length;i++){
...@@ -281,6 +285,13 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -281,6 +285,13 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
} }
return employeeIdsArray; return employeeIdsArray;
} }
$scope.validateFields = function(action){
var managersSelectedList = $scope.managersSelectedList;
var accountName = $scope.accountName;
var industryType = $scope.industryType;
var clientAddress = $scope.clientAddress;
if(action == "Add"){ if(action == "Add"){
if(accountName == undefined || accountName == ""){ if(accountName == undefined || accountName == ""){
$scope.alertMsg = "Please enter the account Name"; $scope.alertMsg = "Please enter the account Name";
...@@ -306,6 +317,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -306,6 +317,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$timeout(function(){updateGrid($scope.templateTitle, record)},200); $timeout(function(){updateGrid($scope.templateTitle, record)},200);
} }
}else if(action == "Update"){ }else if(action == "Update"){
console.log($scope.myForm);
if(accountName == undefined || accountName == ""){ if(accountName == undefined || accountName == ""){
$scope.alertMsg = "Please enter the account Name"; $scope.alertMsg = "Please enter the account Name";
document.getElementById('accountName').focus(); document.getElementById('accountName').focus();
...@@ -325,8 +337,8 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo ...@@ -325,8 +337,8 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
else{ else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"accountId":$scope.accountId, "accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.accountManagers()}; var record = {"accountId":$scope.accountId, "accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.accountManagers()};
var dataRequired = {"accountName":dataToPass.accountName,"industryType":dataToPass.industryType,"clientAddress":dataToPass.clientAddress,"deliveryManagers":dataToPass.deliveryManagers}; var dataRequired = {"accountName":dataToPass.accountName,"industryType":dataToPass.industryType,"clientAddress":dataToPass.clientAddress,"deliveryManagers":getDeliveryManagersFromService()};
console.log($scope.myForm);
var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,dataRequired); var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,dataRequired);
if(isFormUpated == true){ if(isFormUpated == true){
addOrUpdateAccount(record, $scope.templateTitle, "U"); addOrUpdateAccount(record, $scope.templateTitle, "U");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment