simplify recipient summary logic so that entire list is expanded with one click
This commit is contained in:
parent
8caffb8632
commit
4867e9983f
5 changed files with 25 additions and 36 deletions
|
|
@ -436,21 +436,20 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
};
|
||||
|
||||
if (tx.outputs) {
|
||||
tx.amount = lodash.reduce(tx.outputs, function(total, o) {
|
||||
tx.outputs.details = JSON.parse(JSON.stringify(tx.outputs));
|
||||
tx.amount = lodash.reduce(tx.outputs.details, function(total, o) {
|
||||
o.parent = tx.outputs;
|
||||
formatAmount(o, o.amount * self.satToUnit);
|
||||
return total + o.amount;
|
||||
}, 0);
|
||||
var summary = tx.outputs;
|
||||
tx.outputs = [{
|
||||
tx.outputs.summary = [{
|
||||
amount: tx.amount,
|
||||
message: tx.message,
|
||||
summary: summary
|
||||
parent: tx.outputs
|
||||
}];
|
||||
tx.outputs[0].parent = tx.outputs;
|
||||
tx.outputs.transform = formatAmount;
|
||||
tx.outputs.accumulator = 'amount';
|
||||
tx.outputs.recipientCount = summary.length;
|
||||
formatAmount(tx.outputs[0], tx.amount * self.satToUnit);
|
||||
formatAmount(tx.outputs.summary[0], tx.amount * self.satToUnit);
|
||||
tx.outputs.isSummarized = true;
|
||||
tx.outputs.list = tx.outputs.summary;
|
||||
}
|
||||
formatAmount(tx, tx.amount * self.satToUnit);
|
||||
|
||||
|
|
|
|||
|
|
@ -255,10 +255,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.loading = true;
|
||||
$scope.error = null;
|
||||
$timeout(function() {
|
||||
lodash.times(
|
||||
txp.outputs ? txp.outputs.recipientCount : 0,
|
||||
function(n) { $scope.expand(txp.outputs); }
|
||||
);
|
||||
fc.signTxProposal(txp, function(err, txpsi) {
|
||||
profileService.lockFC();
|
||||
self.setOngoingProcess();
|
||||
|
|
@ -368,21 +364,13 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
self.copyAddress(addr);
|
||||
};
|
||||
|
||||
$scope.expand = function(list) {
|
||||
if (list && list.length && list[list.length - 1].summary) {
|
||||
var lastItem = list.pop();
|
||||
if (lastItem.summary.length === 0) return;
|
||||
var nextItem = lastItem.summary.shift();
|
||||
lastItem[list.accumulator] -= nextItem[list.accumulator];
|
||||
list.push(nextItem);
|
||||
if (lastItem.summary.length) {
|
||||
if (lastItem.summary.length === 1) {
|
||||
list.push(lastItem.summary.pop());
|
||||
} else {
|
||||
list.transform(lastItem, lastItem[list.accumulator]);
|
||||
list.push(lastItem);
|
||||
}
|
||||
}
|
||||
$scope.toggleOutputSummary = function(output) {
|
||||
if (output.parent.isSummarized) {
|
||||
output.parent.isSummarized = false;
|
||||
output.parent.list = output.parent.details;
|
||||
} else {
|
||||
output.parent.isSummarized = true;
|
||||
output.parent.list = output.parent.summary;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue