fix typos - filter wallets in first process

This commit is contained in:
Javier 2016-11-25 17:05:35 -03:00
commit 9784c95e72
2 changed files with 30 additions and 24 deletions

View file

@ -31,7 +31,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.toEmail = data.stateParams.toEmail;
$scope.description = data.stateParams.description;
$scope.paypro = data.stateParams.paypro;
$scope.insuffientFunds = false;
$scope.insufficientFunds = false;
$scope.noMatchingWallet = false;
$scope.paymentExpired = {
value: false
@ -42,9 +42,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var config = configService.getSync().wallet;
$scope.feeLevel = config.settings && config.settings.feeLevel ? config.settings.feeLevel : 'normal';
$scope.network = (new bitcore.Address($scope.toAddress)).network.name;
setwallets();
if ($scope.useSendMax) $scope.showWalletSelector();
else initConfirm();
});
function setwallets() {
$scope.wallets = profileService.getWallets({
onlyComplete: true,
network: $scope.network,
@ -57,16 +62,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.wallet = $scope.wallets[0];
}
if ($scope.useSendMax) $scope.showWalletSelector();
else initConfirm();
});
var initConfirm = function() {
toAmount = parseInt(toAmount);
amountStr = txFormatService.formatAmountStr(toAmount);
$scope.displayAmount = getDisplayAmount(amountStr);
$scope.displayUnit = getDisplayUnit(amountStr);
var filteredWallets = [];
var index = 0;
var enoughFunds = false;
@ -87,14 +82,24 @@ angular.module('copayApp.controllers').controller('confirmController', function(
if (++index == $scope.wallets.length) {
if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets);
setWallet($scope.wallets[0]);
if (!$scope.useSendMax) setWallet($scope.wallets[0]);
} else {
if (!enoughFunds) $scope.insuffientFunds = true;
if (!enoughFunds) $scope.insufficientFunds = true;
$log.warn('No wallet available to make the payment');
}
}
});
});
$timeout(function() {
$scope.$apply();
});
};
var initConfirm = function() {
toAmount = parseInt(toAmount);
amountStr = txFormatService.formatAmountStr(toAmount);
$scope.displayAmount = getDisplayAmount(amountStr);
$scope.displayUnit = getDisplayUnit(amountStr);
txFormatService.formatAlternativeStr(toAmount, function(v) {
$scope.alternativeAmountStr = v;
@ -127,13 +132,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}, function(err, resp) {
ongoingProcess.set('retrievingInputs', false);
if (err) {
$scope.insuffientFunds = true;
$scope.insufficientFunds = true;
popupService.showAlert(gettextCatalog.getString('Error'), err);
return;
}
if (resp.amount == 0) {
$scope.insuffientFunds = true;
$scope.insufficientFunds = true;
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'));
return;
}
@ -207,6 +212,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
$scope.showWalletSelector = function() {
if ($scope.insufficientFunds || $scope.noMatchingWallet) return;
$scope.showWallets = true;
};
@ -387,7 +393,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
};
$scope.approve = function(onSendStatusChange) {
if (!toAmount) return;
if (!toAmount || $scope.insufficientFunds || $scope.noMatchingWallet) return;
if ($scope.paypro && $scope.paymentExpired.value) {
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.'));

View file

@ -7,7 +7,7 @@
</ion-nav-back-button>
</ion-nav-bar>
<ion-content ng-class="{'add-bottom-for-cta': !insuffientFunds && !noMatchingWallet}">
<ion-content ng-class="{'add-bottom-for-cta': !insufficientFunds && !noMatchingWallet}">
<div class="list">
<div class="item head">
<div class="sending-label">
@ -50,7 +50,7 @@
<span ng-if="tx.hasMultiplesOutputs" translate>Multiple recipients</span> -->
</span>
</div>
<a class="item item-icon-right" ng-hide="insuffientFunds || noMatchingWallet" ng-click="showWalletSelector()">
<a class="item item-icon-right" ng-hide="insufficientFunds || noMatchingWallet" ng-click="showWalletSelector()">
<span class="label" translate>From</span>
<div class="wallet">
<i class="icon big-icon-svg">
@ -60,14 +60,14 @@
</div>
<i class="icon bp-arrow-right"></i>
</a>
<a class="item single-line item-icon-right" ng-if="!insuffientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
<a class="item single-line item-icon-right" ng-if="!insufficientFunds && !noMatchingWallet" ng-click="showDescriptionPopup()">
<span class="label" translate>Add Memo</span>
<span class="item-note m10l">
{{description}}
</span>
<i class="icon bp-arrow-right"></i>
</a>
<div class="item single-line" ng-if="!insuffientFunds && !noMatchingWallet">
<div class="item single-line" ng-if="!insufficientFunds && !noMatchingWallet">
<span class="label" translate>Fee: {{feeLevel}}</span>
<span class="item-note">
{{fee || '...'}}
@ -76,7 +76,7 @@
<div class="text-center" ng-show="noMatchingWallet">
<span class="badge badge-energized" translate>No wallets available</span>
</div>
<div class="text-center" ng-show="insuffientFunds">
<div class="text-center" ng-show="insufficientFunds">
<span class="badge badge-energized" translate>Insufficient funds</span>
</div>
</div>
@ -84,12 +84,12 @@
</ion-content>
<click-to-accept
ng-click="approve(statusChangeHandler)"
ng-if="!isCordova && wallets[0] && !insuffientFunds"
ng-if="!isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
click-send-status="sendStatus">
Click to pay
</click-to-accept>
<slide-to-accept
ng-if="isCordova && wallets[0] && !insuffientFunds"
ng-if="isCordova && wallets[0] && !insufficientFunds && !noMatchingWallet"
slide-on-confirm="onConfirm()"
slide-send-status="sendStatus">
Slide to pay