Skip to content

Instantly share code, notes, and snippets.

@alejandroiglesias
Created March 11, 2014 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandroiglesias/9494797 to your computer and use it in GitHub Desktop.
Save alejandroiglesias/9494797 to your computer and use it in GitHub Desktop.
var _pageConfirm = {
include: 'partials/buyer/rfp-detail/send-confirmation.html',
header: 'Confirmation',
primary_button: {
label: "Done",
css_classes: "btn-success"
},
do_load: function() {
return (($scope.recipientsToNotify.length > 0) || ($scope.recipientsToUpdate.length > 0));
},
load_promises: function() {
return sendNotifications();
},
load_results: function(results) {
resultsNotifications(results);
MessagePoll.singleton.look_now();
}
};
function sendNotifications() {
var promises = [];
if ($scope.recipientsToNotify.length) {
promises.push(RFP.sendNotification(
$scope.rfp_detail.id, $scope.notification.subject, $scope.notification.message, $scope.recipientsToNotify, $scope.notification.save_intro_message_for_user));
}
if ($scope.recipientsToUpdate.length) {
promises.push(RFP.sendUpdate(
$scope.rfp_detail.id, $scope.update.message, $scope.recipientsToUpdate));
}
if ($scope.notification.save_intro_message_for_user) {
$scope.rfp_detail.notification_subject = $scope.notification.subject;
$scope.rfp_detail.notification_template = $scope.notification.message;
RFP.update($scope.rfp_detail.id, $scope.rfp_detail);
}
var _rfp = angular.copy($scope.rfp_detail);
var eventName = 'Notifications sent';
var properties = {
sellerName: $scope.recipientsToNotify.concat($scope.recipientsToUpdate).map(function(element) {
return element.label;
}).join(', ')
};
Analytics.apiCommon(eventName, properties, {
rfp: _rfp
}, promises, 'rfpId');
return promises;
};
var pageConfirmation = {
header: "Confirmation",
include: "partials/common/submit_confirmation.html",
primary_button: {
label: "Done",
css_classes: "btn-success"
},
load_promises: function() {
var promises = [];
var action = {
promise: Proposal.submit($stateParams.proposal_id, $scope.submit.intro_note.message, doingSubmit ? $scope.submit.intro_note.save_intro_message_for_user : false, $scope.submit.copySender),
eventName: 'Submit proposal',
properties: {
dueDate: $scope.managed_submit_summary.data.rfp.respond_by_date
}
};
$scope.submit.salutation = "Sending...";
promises.push(action.promise);
Analytics.apiCommon(action.eventName, action.properties, {rfp: $scope.managed_submit_summary.data.rfp}, action.promise, 'rfpId');
return promises;
},
load_results: function(results) {
$scope.submit.confirmation = doingSubmit ?
"Your proposal was successfully submitted to " + $scope.submit.summary.buyer.name + " for the " + $scope.submit.summary.rfp.name + " campaign!" :
"Your changes were successfully sent to " + $scope.submit.summary.buyer.name + " for the " + $scope.submit.summary.rfp.name + " campaign!";
$scope.submit.salutation = doingSubmit ? "Congratulations!" : "Changes Sent!";
if (typeof $scope.reloadAfterSubmit === 'function') $scope.reloadAfterSubmit();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment