better message for "no enough funds"
This commit is contained in:
parent
fce9c2357f
commit
1af5d6dd5f
2 changed files with 26 additions and 9 deletions
|
|
@ -41,14 +41,20 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
var networkName = (new bitcore.Address($scope.toAddress)).network.name;
|
var networkName = (new bitcore.Address($scope.toAddress)).network.name;
|
||||||
$scope.network = networkName;
|
$scope.network = networkName;
|
||||||
|
|
||||||
$scope.notAvailable = false;
|
$scope.insuffientFunds = false;
|
||||||
|
$scope.noMatchingWallet = false;
|
||||||
|
|
||||||
var wallets = profileService.getWallets({
|
var wallets = profileService.getWallets({
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
network: networkName,
|
network: networkName,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!wallets || !wallets.length) {
|
||||||
|
$scope.noMatchingWallet = true;
|
||||||
|
}
|
||||||
|
|
||||||
var filteredWallets = [];
|
var filteredWallets = [];
|
||||||
var index = 0;
|
var index = 0, enoughFunds = false;
|
||||||
|
|
||||||
lodash.each(wallets, function(w) {
|
lodash.each(wallets, function(w) {
|
||||||
walletService.getStatus(w, {}, function(err, status) {
|
walletService.getStatus(w, {}, function(err, status) {
|
||||||
|
|
@ -56,15 +62,20 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
$log.error(err);
|
$log.error(err);
|
||||||
} else {
|
} else {
|
||||||
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
|
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
|
||||||
if (status.availableBalanceSat > $scope.toAmount) filteredWallets.push(w);
|
if (status.availableBalanceSat > $scope.toAmount) {
|
||||||
|
filteredWallets.push(w);
|
||||||
|
enoughFunds = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++index == wallets.length) {
|
if (++index == wallets.length) {
|
||||||
if (!lodash.isEmpty(filteredWallets)) {
|
if (!lodash.isEmpty(filteredWallets)) {
|
||||||
$scope.wallets = lodash.clone(filteredWallets);
|
$scope.wallets = lodash.clone(filteredWallets);
|
||||||
$scope.notAvailable = false;
|
|
||||||
} else {
|
} else {
|
||||||
$scope.notAvailable = true;
|
|
||||||
|
if (!enoughFunds)
|
||||||
|
$scope.insuffientFunds = true;
|
||||||
|
|
||||||
$log.warn('No wallet available to make the payment');
|
$log.warn('No wallet available to make the payment');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,19 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center" ng-show="notAvailable">
|
<div class="text-center" ng-show="noMatchingWallet">
|
||||||
<span class="badge badge-assertive" translate>No wallet with enough funds</span>
|
<span class="badge badge-assertive" translate>No appropiate wallet to make this payment</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center" ng-show="insuffientFunds">
|
||||||
|
<span class="badge badge-assertive" translate>Insufficient funds</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
|
<wallets ng-if="wallets[0]" wallets="wallets"></wallets>
|
||||||
|
|
||||||
<div class="list card">
|
<div ng-show="wallets[0]" class="list card">
|
||||||
<div class="item item-icon-left item-icon-right" ng-click="showDescriptionPopup()">
|
<div class="item item-icon-left item-icon-right" ng-click="showDescriptionPopup()">
|
||||||
<i class="icon ion-ios-chatbubble-outline size-21"></i>
|
<i class="icon ion-ios-chatbubble-outline size-21"></i>
|
||||||
<span ng-show="!description" translate>Add description</span>
|
<span ng-show="!description" translate>Add description</span>
|
||||||
|
|
@ -59,7 +65,7 @@
|
||||||
<i ng-show="!description" class="icon ion-ios-plus-empty size-21"></i>
|
<i ng-show="!description" class="icon ion-ios-plus-empty size-21"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="button button-block button-positive" ng-click="approve()" ng-if="!isCordova" translate>Click to pay</button>
|
<button ng-show="wallets[0]" class="button button-block button-positive" ng-click="approve()" ng-if="!isCordova" translate>Click to pay</button>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<accept class="accept-slide" ng-if="isCordova"></accept>
|
<accept class="accept-slide" ng-if="isCordova"></accept>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue