shapeshift shows message if no available wallet to send from

This commit is contained in:
Kadir Sekha 2017-12-14 13:26:58 +09:00
commit 1689470fec
2 changed files with 84 additions and 76 deletions

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $interval, profileService, walletService, popupService) { angular.module('copayApp.controllers').controller('shapeshiftController', function($scope, $interval, profileService, walletService, popupService, lodash) {
var walletsBtc = []; var walletsBtc = [];
var walletsBch = []; var walletsBch = [];
@ -39,13 +39,15 @@ angular.module('copayApp.controllers').controller('shapeshiftController', functi
$scope.$on("$ionicView.beforeEnter", function(event, data) { $scope.$on("$ionicView.beforeEnter", function(event, data) {
walletsBtc = profileService.getWallets({coin: 'btc'}); walletsBtc = profileService.getWallets({coin: 'btc'});
walletsBch = profileService.getWallets({coin: 'bch'}); walletsBch = profileService.getWallets({coin: 'bch'});
$scope.fromWallets = walletsBtc.concat(walletsBch); $scope.fromWallets = lodash.filter(walletsBtc.concat(walletsBch), function(w) {
$scope.toWallets = walletsBch; return w.status.balance.availableAmount > 0;
if ($scope.fromWallets.length == 0 || $scope.toWallets.length == 0) return; });
if ($scope.fromWallets.length == 0) return;
$scope.onFromWalletSelect($scope.fromWallets[0]); $scope.onFromWalletSelect($scope.fromWallets[0]);
$scope.onToWalletSelect($scope.toWallets[0]); $scope.onToWalletSelect($scope.toWallets[0]);
$scope.singleFromWallet = $scope.fromWallets.length == 1; $scope.singleFromWallet = $scope.fromWallets.length == 1;
$scope.singleToWallet = $scope.toWallets.length == 1; $scope.singleToWallet = $scope.toWallets.length == 1;
$scope.fromWalletSelectorTitle = 'From';
$scope.toWalletSelectorTitle = 'To'; $scope.toWalletSelectorTitle = 'To';
$scope.showFromWallets = false; $scope.showFromWallets = false;
$scope.showToWallets = false; $scope.showToWallets = false;

View file

@ -7,10 +7,15 @@
</ion-nav-back-button> </ion-nav-back-button>
</ion-nav-bar> </ion-nav-bar>
<ion-content> <ion-content>
<shapeshift-coin-trader>
<div class="send-header-wrapper shapeshift-banner"> <div class="send-header-wrapper shapeshift-banner">
<img class="shapeshift-logo" src="img/shapeshiftlogo.svg"/> <img class="shapeshift-logo" src="img/shapeshiftlogo.svg"/>
</div> </div>
<div class="list card ng-hide" ng-show="fromWallets.length == 0">
<div class="item item-heading">
<span translate>No available wallets to convert from.</span>
</div>
</div>
<shapeshift-coin-trader class="ng-hide" ng-show="fromWallets.length > 0">
<div class="list card"> <div class="list card">
<div class="item item-heading"> <div class="item item-heading">
<span translate><strong>From</strong></span> <span translate><strong>From</strong></span>
@ -88,6 +93,7 @@
</ion-content> </ion-content>
<wallet-selector <wallet-selector
wallet-selector-title="fromWalletSelectorTitle"
wallet-selector-wallets="fromWallets" wallet-selector-wallets="fromWallets"
wallet-selector-selected-wallet="fromWallet" wallet-selector-selected-wallet="fromWallet"
wallet-selector-show="showFromWallets" wallet-selector-show="showFromWallets"