mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #3095 from cmgustavo/bug/modal-txp-05
Fixes txp modals for single outputs
This commit is contained in:
commit
0791c3fc32
|
@ -1,24 +1,14 @@
|
|||
<div class="ng-animate-disabled row collapse">
|
||||
<li ng-if="output.isSummary" class="line-b p10 oh" ng-click="toggleOutputDetails(output)">
|
||||
<span class="text-gray" translate>Recipients</span>:
|
||||
<span class="right enable_text_select">{{output.recipientCount}}
|
||||
<i ng-show="output.showDetails" class="icon-arrow-up3 size-24"></i>
|
||||
<i ng-show="!output.showDetails" class="icon-arrow-down3 size-24"></i>
|
||||
</span>
|
||||
</li>
|
||||
<li ng-if="!output.isSummary" class="line-b p10 oh" ng-click="copyAddress(output.toAddress)">
|
||||
<li class="p10 oh" ng-click="copyAddress(output.toAddress)">
|
||||
<span class="text-gray" translate>To</span>:
|
||||
<span class="right enable_text_select">{{output.toAddress || output.address}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span ng-show="output.isSummary" class="text-gray" translate>Total</span>
|
||||
<span ng-show="!output.isSummary" class="text-gray" translate>Amount</span>:
|
||||
</li>
|
||||
<li class="p10">
|
||||
<span class="text-gray" translate>Amount</span>:
|
||||
<span class="right">{{output.amountStr}}
|
||||
<span ng-show="output.alternativeAmountStr" class="label gray radius">{{output.alternativeAmountStr}}</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
</li>
|
||||
<li class="p10 oh">
|
||||
<span class="text-gray" translate>Note</span>:
|
||||
<span class="right">{{output.message}}</span>
|
||||
</li>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
@ -11,19 +11,20 @@
|
|||
<time class="right size-12 text-gray m5t">{{ (tx.ts || tx.createdOn ) * 1000 | amTimeAgo}}</time>
|
||||
</div>
|
||||
<div class="ellipsis size-14">
|
||||
<span ng-if="!tx.showSingle">
|
||||
<span ng-if="tx.hasMultiplesOutputs">
|
||||
<span translate>Recipients</span>:
|
||||
<span>{{tx.outputs.length}}</span>
|
||||
<span>{{tx.recipientCount}}</span>
|
||||
</span>
|
||||
<span ng-if="tx.showSingle">
|
||||
<span ng-if="!tx.hasMultiplesOutputs">
|
||||
<span translate>To</span>:
|
||||
<span ng-if="tx.merchant">
|
||||
<span ng-show="tx.merchant.pr.ca"><i class="fi-lock"></i> {{tx.merchant.domain}}</span>
|
||||
<span ng-show="!tx.merchant.pr.ca"><i class="fi-unlock"></i> {{tx.merchant.domain}}</span>
|
||||
</span>
|
||||
<contact address="{{tx.toAddress}}" ng-hide="tx.merchant"> </contact>
|
||||
<span ng-if="!tx.merchant">
|
||||
{{tx.toAddress}}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="ellipsis text-gray size-14">
|
||||
{{tx.message}}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="modal-content fix-modals-touch">
|
||||
<div class="header-modal text-center">
|
||||
<div class="size-42" ng-show="btx.action != 'invalid'">
|
||||
<span ng-if="btx.action == 'received'">+</span><span ng-if="btx.action == 'sent'">-</span>{{btx.amountStr}} {{settings.unitName}}
|
||||
<span ng-if="btx.action == 'received'">+</span><span ng-if="btx.action == 'sent'">-</span>{{btx.amountStr}}
|
||||
</div>
|
||||
<div class="size-42" ng-show="btx.action == 'invalid'">
|
||||
-
|
||||
|
@ -25,17 +25,8 @@
|
|||
<h4 class="title m0" translate>Details</h4>
|
||||
|
||||
<ul class="no-bullet size-14 m0">
|
||||
<div ng-if="btx.action != 'received'">
|
||||
<div ng-if="!btx.showSingle"
|
||||
ng-repeat="output in [ btx.outputs.summary ]"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
<div ng-if="!btx.showSingle && btx.outputs.summary.showDetails"
|
||||
ng-repeat="output in btx.outputs.details"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
</div>
|
||||
<li ng-if="btx.showSingle && btx.addressTo && btx.addressTo != 'N/A'" class="line-b p10 oh" ng-click="copyAddress(btx.addressTo)">
|
||||
|
||||
<li ng-if="!btx.hasMultiplesOutputs && btx.addressTo && btx.addressTo != 'N/A'" class="line-b p10 oh" ng-click="copyAddress(btx.addressTo)">
|
||||
<span class="text-gray" translate>To</span>:
|
||||
<span class="right">
|
||||
<span ng-if="btx.merchant">
|
||||
|
@ -47,6 +38,26 @@
|
|||
</span>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<li ng-show="btx.hasMultiplesOutputs" class="line-b p10 oh"
|
||||
ng-click="showMultiplesOutputs = !showMultiplesOutputs">
|
||||
<span class="text-gray" translate>Recipients</span>:
|
||||
<span class="right">{{btx.recipientCount}}
|
||||
<i ng-show="showMultiplesOutputs" class="icon-arrow-up3 size-24"></i>
|
||||
<i ng-show="!showMultiplesOutputs" class="icon-arrow-down3 size-24"></i>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<div class="line-b" ng-show="btx.hasMultiplesOutputs && showMultiplesOutputs"
|
||||
ng-repeat="output in btx.outputs"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
|
||||
<li ng-show="btc.message" class="line-b p10 oh">
|
||||
<span class="text-gray" translate>Note</span>:
|
||||
<span class="right">{{btx.message}}</span>
|
||||
</li>
|
||||
|
||||
<li ng-if="btx.action == 'invalid'" class="line-b p10 oh">
|
||||
<span class="right" translate>
|
||||
This transaction has become invalid; possibly due to a double spend attempt.
|
||||
|
@ -59,7 +70,7 @@
|
|||
</li>
|
||||
<li class="line-b p10" ng-show="btx.action != 'received'">
|
||||
<span class="text-gray" translate>Fee</span>:
|
||||
<span class="right">{{feeStr}}</span>
|
||||
<span class="right">{{btx.feeStr}}</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh" ng-if="btx.message && btx.action != 'received'">
|
||||
<span class="text-gray" translate>Note</span>:
|
||||
|
|
|
@ -14,21 +14,41 @@
|
|||
<div class="modal-content fix-modals-touch" ng-init="updateCopayerList()">
|
||||
<h4 class="title m0" translate>Details</h4>
|
||||
<ul class="no-bullet size-14 m0">
|
||||
<div ng-if="!tx.showSingle"
|
||||
ng-repeat="output in [ tx.outputs.summary ]"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
<div ng-if="!tx.showSingle && tx.outputs.summary.showDetails"
|
||||
ng-repeat="output in tx.outputs.details"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
<div ng-if="tx.showSingle"
|
||||
ng-repeat="output in [ tx ]"
|
||||
<li ng-if="!tx.hasMultiplesOutputs"
|
||||
class="line-b p10 oh"
|
||||
ng-click="copyAddress(tx.toAddress)">
|
||||
<span class="text-gray" translate>To</span>:
|
||||
<span class="right enable_text_select">{{tx.toAddress}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span ng-show="tx.hasMultiplesOutputs" class="text-gray" translate>Total</span>
|
||||
<span ng-show="!tx.hasMultiplesOutputs" class="text-gray" translate>Amount</span>:
|
||||
<span class="right">{{tx.amountStr}}
|
||||
<span ng-show="tx.alternativeAmountStr" class="label gray radius">{{tx.alternativeAmountStr}}</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p10 oh">
|
||||
<span class="text-gray" translate>Note</span>:
|
||||
<span class="right">{{tx.message}}</span>
|
||||
</li>
|
||||
|
||||
<li ng-show="tx.hasMultiplesOutputs" class="line-b p10 oh"
|
||||
ng-click="showMultiplesOutputs = !showMultiplesOutputs">
|
||||
<span class="text-gray" translate>Recipients</span>:
|
||||
<span class="right">{{tx.recipientCount}}
|
||||
<i ng-show="showMultiplesOutputs" class="icon-arrow-up3 size-24"></i>
|
||||
<i ng-show="!showMultiplesOutputs" class="icon-arrow-down3 size-24"></i>
|
||||
</span>
|
||||
</li>
|
||||
|
||||
<div class="line-b" ng-show="tx.hasMultiplesOutputs && showMultiplesOutputs"
|
||||
ng-repeat="output in tx.outputs"
|
||||
ng-include="'views/includes/output.html'">
|
||||
</div>
|
||||
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Fee</span>:
|
||||
<span class="right">{{feeStr}}</span>
|
||||
<span class="right">{{tx.feeStr}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Time</span>:
|
||||
|
@ -131,7 +151,7 @@
|
|||
ng-show="tx.status=='broadcasted'" translate>
|
||||
Payment sent!
|
||||
</div>
|
||||
<div class="text-center text-warning"
|
||||
<div class="text-center text-warning m10t"
|
||||
ng-show="tx.status=='rejected'" translate>
|
||||
Payment finally rejected
|
||||
</div>
|
||||
|
|
|
@ -505,7 +505,6 @@
|
|||
</span>
|
||||
<span ng-if="btx.action != 'invalid'">
|
||||
{{btx.amountStr}}
|
||||
{{home.getUnitName()}}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp, bwsError, utilService) {
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
|
@ -469,49 +469,11 @@ 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);
|
||||
var total = lodash.reduce(tx.outputs.details, function(total, o) {
|
||||
formatAmount(o);
|
||||
return total + o.amount;
|
||||
}, 0);
|
||||
if (tx.action != 'received') {
|
||||
tx.amount = total;
|
||||
}
|
||||
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(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;
|
||||
};
|
||||
|
||||
self.summarizeOutputs(tx, formatAmount);
|
||||
formatAmount(tx);
|
||||
|
||||
tx.feeStr = profileService.formatAmount(tx.fee) + ' ' + config.unitName;
|
||||
tx.alternativeIsoCode = config.alternativeIsoCode;
|
||||
tx = utilService.processTx(tx);
|
||||
|
||||
var action = lodash.find(tx.actions, {
|
||||
copayerId: self.copayerId
|
||||
|
@ -546,21 +508,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
var c = 0;
|
||||
self.txHistoryPaging = txs[self.limitHistory] ? true : false;
|
||||
lodash.each(txs, function(tx) {
|
||||
tx = utilService.processTx(tx);
|
||||
|
||||
// no future transactions...
|
||||
if (tx.time > now)
|
||||
tx.time = now;
|
||||
|
||||
tx.rateTs = Math.floor((tx.ts || now) / 1000);
|
||||
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++;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, feeService, bwsError) {
|
||||
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, feeService, bwsError, utilService) {
|
||||
|
||||
var self = this;
|
||||
$rootScope.hideMenuBar = false;
|
||||
|
@ -171,9 +171,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.error = null;
|
||||
$scope.tx = tx;
|
||||
$scope.amountStr = tx.amountStr;
|
||||
$scope.feeStr = tx.feeStr;
|
||||
$scope.alternativeAmountStr = tx.alternativeAmountStr;
|
||||
$scope.copayers = copayers
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.canSign = fc.canSign();
|
||||
|
@ -204,7 +201,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
var action = lodash.find(tx.actions, {
|
||||
copayerId: fc.credentials.copayerId
|
||||
});
|
||||
$scope.tx = tx;
|
||||
$scope.tx = utilService.processTx(tx);
|
||||
if (!action && tx.status == 'pending')
|
||||
$scope.tx.pendingForUs = true;
|
||||
$scope.updateCopayerList();
|
||||
|
@ -348,10 +345,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
self.copyAddress(addr);
|
||||
};
|
||||
|
||||
$scope.toggleOutputDetails = function(summary) {
|
||||
summary.showDetails = !summary.showDetails;
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
@ -1014,7 +1007,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.color = fc.backgroundColor;
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.isShared = fc.credentials.n > 1;
|
||||
$scope.feeStr = btx.feeStr;
|
||||
|
||||
$scope.getAmount = function(amount) {
|
||||
return self.getAmount(amount);
|
||||
|
@ -1038,9 +1030,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
$scope.toggleOutputDetails = function(summary) {
|
||||
summary.showDetails = !summary.showDetails;
|
||||
};
|
||||
};
|
||||
|
||||
var modalInstance = $modal.open({
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('utilService', function(profileService, rateService, configService, lodash) {
|
||||
var root = {};
|
||||
|
||||
var formatAmountStr = function(amount) {
|
||||
if (!amount) return;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
return profileService.formatAmount(amount) + ' ' + config.unitName;
|
||||
};
|
||||
|
||||
var formatAlternativeStr = function(amount) {
|
||||
if (!amount) return;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
return (rateService.toFiat(amount, config.alternativeIsoCode) ? rateService.toFiat(amount, config.alternativeIsoCode).toFixed(2) : 'N/A') + ' ' + config.alternativeIsoCode;
|
||||
};
|
||||
|
||||
var formatFeeStr = function(fee) {
|
||||
if (!fee) return;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
return profileService.formatAmount(fee) + ' ' + config.unitName;
|
||||
};
|
||||
|
||||
root.processTx = function(tx) {
|
||||
if (!tx) return;
|
||||
|
||||
var outputs = tx.outputs ? tx.outputs.length : 0;
|
||||
if (outputs > 1 && tx.action != 'received') {
|
||||
tx.hasMultiplesOutputs = true;
|
||||
tx.recipientCount = outputs;
|
||||
tx.amount = lodash.reduce(tx.outputs, function(total, o) {
|
||||
o.amountStr = formatAmountStr(o.amount);
|
||||
o.alternativeAmountStr = formatAlternativeStr(o.amount);
|
||||
return total + o.amount;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
tx.amountStr = formatAmountStr(tx.amount);
|
||||
tx.alternativeAmountStr = formatAlternativeStr(tx.amount);
|
||||
tx.feeStr = formatFeeStr(tx.fee || tx.fees);
|
||||
|
||||
return tx;
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
Loading…
Reference in New Issue