Add support for custom billing invoice email address

Fixes #782
This commit is contained in:
Joseph Schorr 2015-12-28 13:59:50 -05:00
parent 16f16e8a15
commit 10efa96009
12 changed files with 94 additions and 23 deletions

View file

@ -0,0 +1,15 @@
.billing-options .settings-option {
padding: 4px;
font-size: 18px;
margin-bottom: 10px;
}
.billing-options .settings-option label {
margin-left: 6px;
}
.billing-options .settings-option .settings-description {
font-size: 16px;
color: #888;
padding-left: 26px;
}

View file

@ -506,21 +506,6 @@ i.toggle-icon:hover {
vertical-align: middle;
}
.settings-option {
padding: 4px;
font-size: 18px;
margin-bottom: 10px;
}
.settings-option label {
margin-left: 6px;
}
.settings-option .settings-description {
font-size: 12px;
color: #aaa;
}
.organization-header-element {
padding: 20px;
margin-bottom: 20px;

View file

@ -31,7 +31,7 @@
<!-- Options -->
<div style="margin-bottom: 20px">
<div class="panel-title">
Billing Options
Billing Receipts
<div class="cor-loader-inline" ng-show="working"></div>
</div>
<div class="panel-body">
@ -39,7 +39,7 @@
<input id="invoiceEmail" type="checkbox" ng-model="invoice_email">
<label for="invoiceEmail">Send Receipt Emails</label>
<div class="settings-description">
If checked, a receipt email will be sent to {{ obj.email }} on every successful charge
If checked, a receipt email will be sent to <a href="javascript:void(0)" ng-click="changeInvoiceEmailAddress()">{{ obj.invoice_email_address || obj.email }}</a> on every successful charge
</div>
</div>
</div>

View file

@ -34,6 +34,23 @@ angular.module('quay').directive('billingOptions', function () {
return difference < (60 * 60 * 24 * 60 * 1000 /* 60 days */);
};
$scope.changeInvoiceEmailAddress = function() {
bootbox.prompt('Enter the email address for receiving receipts', function(email) {
// Copied from Angular.
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
if (!email || !EMAIL_REGEXP.test(email)) {
return;
}
$scope.obj['invoice_email_address'] = email;
var errorHandler = ApiService.errorDisplay('Could not change user details');
ApiService.changeDetails($scope.organization, $scope.obj).then(function(resp) {
$scope.working = false;
}, errorHandler);
});
};
$scope.changeCard = function() {
var previousCard = $scope.currentCard;
$scope.changingCard = true;