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
|
|
@ -1,21 +1,23 @@
|
|||
<div class="ng-animate-disabled row collapse line-b" ng-class="text-gray">
|
||||
<li ng-if="output.summary" class="line-b p10 oh" ng-click="expand(output.parent)">
|
||||
<li ng-if="output.parent.isSummarized" class="line-b p10 oh" ng-click="toggleOutputSummary(output)">
|
||||
<span class="text-gray" translate>Recipients</span>:
|
||||
<span class="right enable_text_select">{{output.summary.length}}
|
||||
<span class="right enable_text_select">{{output.parent.length}}
|
||||
<i class="icon-arrow-down size-24"></i>
|
||||
</span>
|
||||
</li>
|
||||
<li ng-if="!output.summary" class="line-b p10 oh" ng-click="copyAddress(output.toAddress)">
|
||||
<li ng-if="!output.parent.isSummarized" class="line-b p10 oh" ng-click="toggleOutputSummary(output)">
|
||||
<span class="text-gray" translate>To</span>:
|
||||
<span class="right enable_text_select">{{output.toAddress}}</span>
|
||||
<span class="right enable_text_select">{{output.toAddress}}
|
||||
<i class="icon-arrow-up size-24"></i>
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p10" ng-click="expand(output.parent)">
|
||||
<li class="line-b p10" ng-click="toggleOutputSummary(output)">
|
||||
<span class="text-gray" translate>Amount</span>:
|
||||
<span class="right">{{output.amountStr}}
|
||||
<span class="label gray radius enable_text_select">{{output.alternativeAmountStr}}</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh" ng-click="expand(output.parent)">
|
||||
<li class="line-b p10 oh" ng-click="toggleOutputSummary(output)">
|
||||
<span class="text-gray" translate>Note</span>:
|
||||
<span class="right enable_text_select">{{output.message}}</span>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<div class="ellipsis size-14">
|
||||
<span ng-if="tx.outputs">
|
||||
<span translate>Recipients</span>:
|
||||
<span>{{tx.outputs.recipientCount}}</span>
|
||||
<span>{{tx.outputs.length}}</span>
|
||||
</span>
|
||||
<span ng-if="!tx.outputs">
|
||||
<span translate>To</span>:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<h4 class="title m0" translate>Details</h4>
|
||||
<ul class="no-bullet size-14 m0">
|
||||
<div ng-if="tx.outputs"
|
||||
ng-repeat="output in tx.outputs"
|
||||
ng-repeat="output in tx.outputs.list"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
<li ng-if="!tx.outputs" class="line-b p10 oh" ng-click="copyAddress(tx.toAddress)">
|
||||
|
|
|
|||
|
|
@ -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