Skip to content

Commit

Permalink
feat(masspay): new feature simplifies making mass payments such as IC…
Browse files Browse the repository at this point in the history
…Os or dividents
  • Loading branch information
beregovoy68 committed Dec 25, 2016
1 parent ad1e592 commit 139bda5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,16 @@ <h2 class="sectionHeader">MASS PAYMENT</h2>
</div>
</ng-switch>
</div>
<div id="asset-mass-pay-confirmation" waves-dialog ok-button-caption="CONFIRM" on-dialog-ok="mass.broadcastTransaction()">

<div id="asset-mass-pay-confirmation" waves-dialog ok-button-caption="CONFIRM" ok-button-enabled="!mass.broadcast.pending" on-dialog-ok="mass.broadcastTransaction()">
<div class="dialog-confirmation">
<p class="dialog-text">You are sending <span class="confirmation-value">{{mass.confirm.amount.value}}</span>
<span class="confirmation-value">{{mass.confirm.amount.currency}}</span> with
<span class="confirmation-value">{{mass.confirm.fee.value}}</span>
<span class="confirmation-value">{{mass.confirm.fee.currency}}</span> total fee <br/>
to <span class="confirmation-value">{{mass.confirm.recipients}}</span> recipients.
</p>
<p class="dialog-text">Please <span class="fontBold"> CONFIRM </span>to execute or <span class="fontBold"> CANCEL </span> to discard.</p>
</div>
</div>
</div>
</div>
Expand Down
37 changes: 32 additions & 5 deletions src/js/portfolio/mass.payment.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,31 @@
var ZERO_MONEY = Money.fromTokens(0, Currency.WAV);

function WavesMassPaymentController ($scope, $window, $timeout, constants, events, applicationContext, autocomplete,
notificationService, assetService, dialogService) {
notificationService, assetService, dialogService,
transactionBroadcast, apiService) {
var mass = this;
var minimumFee = new Money(constants.MINIMUM_TRANSACTION_FEE, Currency.WAV);

mass.summary = {
totalAmount: ZERO_MONEY,
totalFee: ZERO_MONEY
};
mass.confirm = {
amount: {},
fee: {},
recipients: 0
};
mass.transfers = [];
mass.inputPayments = [];
mass.autocomplete = autocomplete;
mass.stage = LOADING_STAGE;
mass.broadcast = new transactionBroadcast.instance(apiService.assets.massPay,
function (transaction, response) {
var displayMessage = 'Sent ' + mass.summary.totalAmount.formatAmount(true) + ' of ' +
mass.summary.totalAmount.currency.displayName + ' to ' + mass.summary.totalTransactions +
' recipients';
notificationService.notice(displayMessage);
});
mass.validationOptions = {
rules: {
massPayFee: {
Expand Down Expand Up @@ -54,7 +67,7 @@
else {
mass.asset = undefined;
}
mass.stage = LOADING_STAGE;
cleanup();

dialogService.open('#asset-mass-pay-dialog');
});
Expand Down Expand Up @@ -130,6 +143,8 @@
totalTransactions++;
});

mass.broadcast.setTransaction(transactions);

mass.summary.totalAmount = totalAmount;
mass.summary.totalTransactions = totalTransactions;
mass.summary.totalFee = totalFee;
Expand All @@ -154,7 +169,12 @@
return false;
}

//TODO: set transaction
// setting data for the confirmation dialog
mass.confirm.amount.value = mass.summary.totalAmount.formatAmount(true);
mass.confirm.amount.currency = mass.summary.totalAmount.currency.displayName;
mass.confirm.fee.value = mass.summary.totalFee.formatAmount(true);
mass.confirm.fee.currency = mass.summary.totalFee.currency.displayName;
mass.confirm.recipients = mass.summary.totalTransactions;

$timeout(function () {
dialogService.open('#asset-mass-pay-confirmation');
Expand All @@ -164,7 +184,7 @@
}

function broadcastTransaction() {
//TODO: broadcast transaction
mass.broadcast.broadcast();
}

function handleFile(file) {
Expand Down Expand Up @@ -198,12 +218,19 @@
mass.summary.totalAmount = ZERO_MONEY;
mass.summary.totalTransactions = 0;
mass.summary.totalFee = ZERO_MONEY;
mass.stage = LOADING_STAGE;

mass.confirm.amount.value = '0';
mass.confirm.recipients = 0;
mass.confirm.fee.value = '0';

mass.autocomplete.defaultFee(constants.MINIMUM_TRANSACTION_FEE);
}
}

WavesMassPaymentController.$inject = ['$scope', '$window', '$timeout', 'constants.ui', 'portfolio.events',
'applicationContext', 'autocomplete.fees',
'notificationService', 'assetService', 'dialogService'];
'notificationService', 'assetService', 'dialogService', 'transactionBroadcast', 'apiService'];

angular
.module('app.portfolio')
Expand Down

0 comments on commit 139bda5

Please sign in to comment.