Commit 22d15411 authored by nakavaram-nisum-com's avatar nakavaram-nisum-com Committed by tdutta-nisum-com

restricting api calls in update (#120)

parent 67879601
......@@ -265,85 +265,91 @@ myApp.controller("domainController",
else {
return "Please select account";
}
};
};
isDataUpdated = function () {
if (dataToPass.action == "Update") {
$scope.previousData = {
domainId: dataToPass.domainId,
accountinfo: dataToPass.AccountName,
domainname: dataToPass.domainName
}
$scope.currentdata = {
domainId: $scope.domainId,
accountinfo: $scope.AccountInfo.accountName,
domainname: $scope.domainName
}
$scope.cancel = function() {
var showConfirmDialog = false;
if(dataToPass.action=="Update"){
console.log(dataToPass.deliveryManagers+' response')
console.log($scope.employeeModel)
$scope.previousData={
domainId :dataToPass.domainId,
accountinfo:dataToPass.AccountName,
domainname:dataToPass.domainName
}
$scope.currentdata={
domainId :$scope.domainId,
accountinfo:$scope.AccountInfo.accountName,
domainname:$scope.domainName
}
var predata=JSON.stringify($scope.previousData);
var curdata=JSON.stringify($scope.currentdata);
var predata = JSON.stringify($scope.previousData);
var curdata = JSON.stringify($scope.currentdata);
var exsistingMangersList = dataToPass.deliveryManagers;
var currentMangersList = $scope.employeeModel;
var managerCheck = false;
if(exsistingMangersList.length === currentMangersList.length){
if (exsistingMangersList.length === currentMangersList.length) {
var temp1 = [];
var temp2 = [];
for (var i in exsistingMangersList){
for (var i in exsistingMangersList) {
temp1.push(exsistingMangersList[i].employeeId);
}
for (var j in currentMangersList){
for (var j in currentMangersList) {
temp2.push(currentMangersList[j].employeeId);
}
for(var k=0;k<exsistingMangersList.length;k++){
if(temp2.indexOf(temp1[k]) > -1){
for (var k = 0; k < exsistingMangersList.length; k++) {
if (temp2.indexOf(temp1[k]) > -1) {
managerCheck = true;
}else{
} else {
managerCheck = false;
}
}
}else{
} else {
managerCheck = false;
}
if(predata === curdata && managerCheck){
$mdDialog.hide('Cancelled');
if (predata === curdata && managerCheck) {
//$mdDialog.hide('Cancelled');
return false;
}
return true;
}
}
$scope.cancel = function () {
var showConfirmDialog = false;
if (dataToPass.action == "Update") {
if (isDataUpdated() != true) {
$mdDialog.hide('Cancelled');
}
else{
else {
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel:'cancel'
})).then(function(){
$mdDialog.hide('Cancelled');
})
}
}
if(dataToPass.action=="Add"){
var totalFields = $scope.myForm.$$controls;
for (key in totalFields) {
console.log("Model value of" + key + " ==>" + totalFields[key].$modelValue)
if(totalFields[key].$modelValue !== '' && totalFields[key].$modelValue !== undefined && totalFields[key].$modelValue.length !== 0) {
console.log("Came here!");
showConfirmDialog = true;
}
cancel: 'cancel'
})).then(function () {
$mdDialog.hide('Cancelled');
})
}
}
if(showConfirmDialog){
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel:'cancel'
})).then(function(){
$mdDialog.hide('Cancelled');
})
if (dataToPass.action == "Add") {
var totalFields = $scope.myForm.$$controls;
for (key in totalFields) {
console.log("Model value of" + key + " ==>" + totalFields[key].$modelValue)
if (totalFields[key].$modelValue !== '' && totalFields[key].$modelValue !== undefined && totalFields[key].$modelValue.length !== 0) {
showConfirmDialog = true;
}
}
if (showConfirmDialog) {
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel: 'cancel'
})).then(function () {
$mdDialog.hide('Cancelled');
})
}
else{
$mdDialog.hide('Cancelled');
else {
$mdDialog.hide('Cancelled');
}
}
};
......@@ -477,11 +483,19 @@ myApp.controller("domainController",
"id" : $scope.id,
"domainId" : dataToPass.domainId
};
$scope.addOrUpdateDomain(record,action);
if (isDataUpdated() != true) {
$mdDialog.show($mdDialog.alert({
skipHide: true,
title: 'Attention',
textContent: 'There is no data change to Update',
ok: 'ok'
}))
}
else {
$scope.addOrUpdateDomain(record, action);
}
}
}
};
}
......
......@@ -171,7 +171,6 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
url : appConfig.appUri + "/projectTeam/getEmployeesToTeam"
}).then(function mySuccess(response) {
$scope.managerDetails=response.data;
console.log("response",response)
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
......@@ -181,87 +180,93 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$scope.closeSelectBox = function () {
$mdSelect.hide();
}
$scope.cancel = function(){
var showConfirmDialog = false;
if(dataToPass.action=="Update"){
console.log(dataToPass);
$scope.previousData={
AccountID:dataToPass.accountId,
AccountName:dataToPass.accountName,
IndustryType:dataToPass.industryType,
ClientAddress:dataToPass.clientAddress,
}
$scope.currentData={
AccountID:$scope.accountId,
AccountName:$scope.accountName,
IndustryType:$scope.industryType,
ClientAddress:$scope.clientAddress
}
var predata=JSON.stringify($scope.previousData);
var curdata=JSON.stringify($scope.currentData);
var exsistingMangersList = dataToPass.deliveryManagers;
var currentMangersList = $scope.managersSelectedList;
console.log($scope.managersSelectedList);
var managerCheck = false;
isDataUpdated = function () {
if (dataToPass.action == "Update") {
$scope.previousData = {
AccountID: dataToPass.accountId,
AccountName: dataToPass.accountName,
IndustryType: dataToPass.industryType,
ClientAddress: dataToPass.clientAddress,
}
$scope.currentData = {
AccountID: $scope.accountId,
AccountName: $scope.accountName,
IndustryType: $scope.industryType,
ClientAddress: $scope.clientAddress
}
if(exsistingMangersList.length === currentMangersList.length){
var temp1 = [];
var temp2 = [];
var predata = JSON.stringify($scope.previousData);
var curdata = JSON.stringify($scope.currentData);
var exsistingMangersList = dataToPass.deliveryManagers;
var currentMangersList = $scope.managersSelectedList;
var managerCheck = false;
for (var i in exsistingMangersList){
temp1.push(exsistingMangersList[i].employeeId);
}
for (var j in currentMangersList){
temp2.push(currentMangersList[j].employeeId);
}
for(var k=0;k<exsistingMangersList.length;k++){
if(temp2.indexOf(temp1[k]) > -1){
managerCheck = true;
}else{
managerCheck = false;
}
}
}
else{
managerCheck = false;
if (exsistingMangersList.length === currentMangersList.length) {
var temp1 = [];
var temp2 = [];
for (var i in exsistingMangersList) {
temp1.push(exsistingMangersList[i].employeeId);
}
if(predata === curdata && managerCheck){
$mdDialog.hide('Cancelled');
for (var j in currentMangersList) {
temp2.push(currentMangersList[j].employeeId);
}
else{
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel:'cancel'
})).then(function(){
$mdDialog.hide('Cancelled');
})
}
for (var k = 0; k < exsistingMangersList.length; k++) {
if (temp2.indexOf(temp1[k]) > -1) {
managerCheck = true;
} else {
managerCheck = false;
}
}
if(dataToPass.action=="Add"){
var totalFields = $scope.myForm.$$controls;
for (key in totalFields) {
console.log("Model value of" + key + " ==>" + totalFields[key].$modelValue)
if(totalFields[key].$modelValue !== '' && totalFields[key].$modelValue !== undefined && totalFields[key].$modelValue.length !== 0) {
console.log("Came here!");
showConfirmDialog = true;
}
else {
managerCheck = false;
}
if (predata === curdata && managerCheck) {
//$mdDialog.hide('Cancelled');
return false;
}
return true;
}
if(showConfirmDialog){
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel:'cancel'
})).then(function(){
$mdDialog.hide('Cancelled');
})
}
$scope.cancel = function () {
var showConfirmDialog = false;
if (dataToPass.action == "Update") {
if (isDataUpdated() != true) {
$mdDialog.hide('Cancelled');
}
else{
$mdDialog.hide('Cancelled');
else {
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel: 'cancel'
})).then(function () {
$mdDialog.hide('Cancelled');
})
}
}
if (dataToPass.action == "Add") {
var totalFields = $scope.myForm.$$controls;
for (key in totalFields) {
// console.log("Model value of" + key + " ==>" + totalFields[key].$modelValue)
if (totalFields[key].$modelValue !== '' && totalFields[key].$modelValue !== undefined && totalFields[key].$modelValue.length !== 0) {
showConfirmDialog = true;
}
}
if (showConfirmDialog) {
$mdDialog.show($mdDialog.confirm({
skipHide: true,
textContent: 'Are you sure you want to cancel this?',
ok: 'ok',
cancel: 'cancel'
})).then(function () {
$mdDialog.hide('Cancelled');
})
}
else {
$mdDialog.hide('Cancelled');
}
}
}
......@@ -364,11 +369,20 @@ 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()};
record.id = $scope.parentData.id;
addOrUpdateAccount(record,$scope.templateTitle,"U");
$timeout(function(){updateGrid($scope.templateTitle, record)},200);
}
record.id = $scope.parentData.id;
if (isDataUpdated() != true) {
$mdDialog.show($mdDialog.alert({
skipHide: true,
title: 'Attention',
textContent: 'There is no data change to Update',
ok: 'ok'
}))
}
else {
addOrUpdateAccount(record, $scope.templateTitle, "U");
$timeout(function () { updateGrid($scope.templateTitle, record) }, 200);
}
}
}
};
addOrUpdateAccount = function(record,action,flag){
......
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