txp and txhistory share outputs.html for all amount/address/message

This commit is contained in:
Gregg Zigler 2015-07-28 10:22:46 -07:00
commit 43bca75728
5 changed files with 75 additions and 65 deletions

View file

@ -425,33 +425,43 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.summarizeOutputs = function(tx, formatAmount) {
tx.showSingle = true;
if (tx.outputs) {
tx.showSingle = false;
tx.outputs.details = lodash.clone(tx.outputs);
tx.amount = lodash.reduce(tx.outputs.details, function(total, o) {
formatAmount(o);
return total + o.amount;
}, 0);
tx.outputs.summary = {
amount: tx.amount,
message: tx.message,
isSummary: true,
showDetails: false,
recipientCount: tx.outputs.details.length
};
formatAmount(tx.outputs.summary);
if (tx.outputs.length === 1 && !tx.outputs[0].message) {
tx.showSingle = true;
tx.toAddress = tx.outputs[0].toAddress; // txproposal
tx.address = tx.outputs[0].address; // txhistory
}
}
};
self.setPendingTxps = function(txps) {
var config = configService.getSync().wallet.settings;
self.pendingTxProposalsCountForUs = 0;
lodash.each(txps, function(tx) {
function formatAmount(obj, amount) {
obj.amountStr = profileService.formatAmount(obj.amount) + ' ' + config.unitName;
obj.alternativeAmount = rateService.toFiat(obj.amount, config.alternativeIsoCode) ? rateService.toFiat(obj.amount, config.alternativeIsoCode).toFixed(2) : 'N/A';
obj.alternativeAmountStr = obj.alternativeAmount + " " + config.alternativeIsoCode;
function formatAmount(tx) {
tx.amountStr = profileService.formatAmount(tx.amount) + ' ' + config.unitName;
tx.alternativeAmount = rateService.toFiat(tx.amount, config.alternativeIsoCode) ? rateService.toFiat(tx.amount, config.alternativeIsoCode).toFixed(2) : 'N/A';
tx.alternativeAmountStr = tx.alternativeAmount + " " + config.alternativeIsoCode;
};
if (tx.outputs) {
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);
tx.outputs.summary = [{
amount: tx.amount,
message: tx.message,
parent: tx.outputs
}];
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);
self.summarizeOutputs(tx, formatAmount);
formatAmount(tx);
tx.feeStr = profileService.formatAmount(tx.fee) + ' ' + config.unitName;
tx.alternativeIsoCode = config.alternativeIsoCode;
@ -494,10 +504,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r
tx.time = now;
tx.rateTs = Math.floor((tx.ts || now) / 1000);
tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')(
if (tx.fees)
tx.feeStr = profileService.formatAmount(tx.fees) + ' ' + config.unitName;
function formatAmount(tx) {
tx.amountStr = profileService.formatAmount(tx.amount); //$filter('noFractionNumber')(
};
self.summarizeOutputs(tx, formatAmount);
formatAmount(tx);
if (c < self.limitHistory) {
self.txHistory.push(tx);
c++;

View file

@ -364,14 +364,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
self.copyAddress(addr);
};
$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;
}
$scope.toggleOutputDetails = function(summary) {
summary.showDetails = !summary.showDetails;
};
$scope.cancel = function() {
@ -1059,6 +1053,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
$scope.toggleOutputDetails = function(summary) {
summary.showDetails = !summary.showDetails;
};
};
var modalInstance = $modal.open({