Created
January 22, 2018 11:43
-
-
Save jeson114/b241c26cce74793c2f2f541c80e3e437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleRateCardToggle() { | |
if (deal.ratecard.msa.enabled === false) {2 | |
var allRoles = []; | |
if (isRateCardActive()) { | |
deal.scenarios.items.forEach(getRoles); | |
var message = 'You have scenarios that use rate cards. If you disable the customer rate card switch all roles from this rate card will be deleted from this deal.'; | |
console.log(message); | |
SharedState.set('confirmMessage', message); | |
SharedState.set('confirmAction', function() { | |
var activeRateCards = deal.ratecard.list.filter(function(item) { | |
return item.active === true; | |
}); | |
angular.forEach(activeRateCards, function(rateCardItem) { | |
removeRateCard(rateCardItem, allRoles); | |
}); | |
}); | |
SharedState.set('cancelAction', function() { | |
$scope.deal.ratecard.msa.enabled = true; | |
}); | |
SharedState.turnOn('confirm'); | |
} else { | |
updateMSAReference(); | |
} | |
} | |
function isRateCardActive() { | |
return deal.ratecard.list.some(function(item) { | |
return item.active; | |
}); | |
} | |
function getRoles(scenario) { | |
ocRoleHelper | |
.getRateCardRoles(scenario.roles.items) | |
.forEach(addRoles); | |
return; | |
function addRoles(role) { | |
allRoles.push(role); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment