modified code according to data

parent c4cdf947
......@@ -184,6 +184,15 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$mdSelect.hide();
}
var getDeliveryManagersFromService = function(){
var managerIds = [];
dataToPass.deliveryManagers.forEach(function(manager){
managerIds.push(manager.employeeId);
})
return managerIds;
}
var confirmationMsg = function(){
$mdDialog.show($mdDialog.confirm({
......@@ -208,14 +217,14 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
}
}
else{
var record = {"accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.managersSelectedList};
var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,record);
if(isFormUpated == true){
confirmationMsg();
}
else{
$mdDialog.hide('Cancelled');
}
var dataRequired = {"accountName":dataToPass.accountName,"industryType":dataToPass.industryType,"clientAddress":dataToPass.clientAddress,"deliveryManagers":getDeliveryManagersFromService()};
var isFormUpated = myFactory.updateFormDataCheck($scope.myForm,dataRequired);
if(isFormUpated == true){
confirmationMsg();
}
else{
$mdDialog.hide('Cancelled');
}
}
}
......@@ -269,18 +278,20 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
ev.stopPropagation();
});
$scope.accountManagers = function(){
var employeeIdsArray = [];
for(i=0;i< $scope.managersSelectedList.length;i++){
employeeIdsArray[i] =$scope.managersSelectedList[i].employeeId;
}
return employeeIdsArray;
}
$scope.validateFields = function(action){
var managersSelectedList = $scope.managersSelectedList;
var accountName = $scope.accountName;
var industryType = $scope.industryType;
var clientAddress = $scope.clientAddress;
$scope.accountManagers = function(){
var employeeIdsArray = [];
for(i=0;i< $scope.managersSelectedList.length;i++){
employeeIdsArray[i] =$scope.managersSelectedList[i].employeeId;
}
return employeeIdsArray;
}
if(action == "Add"){
if(accountName == undefined || accountName == ""){
$scope.alertMsg = "Please enter the account Name";
......@@ -306,6 +317,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$timeout(function(){updateGrid($scope.templateTitle, record)},200);
}
}else if(action == "Update"){
console.log($scope.myForm);
if(accountName == undefined || accountName == ""){
$scope.alertMsg = "Please enter the account Name";
document.getElementById('accountName').focus();
......@@ -325,8 +337,8 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
else{
$scope.alertMsg = "";
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);
if(isFormUpated == true){
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