Skip to content

Instantly share code, notes, and snippets.

@jeson114
Created January 22, 2018 11:43
Show Gist options
  • Save jeson114/b241c26cce74793c2f2f541c80e3e437 to your computer and use it in GitHub Desktop.
Save jeson114/b241c26cce74793c2f2f541c80e3e437 to your computer and use it in GitHub Desktop.
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