Removes all Coinbase dependencies from amount view

This commit is contained in:
Gustavo Maximiliano Cortez 2017-01-12 09:58:12 -03:00
parent e42d09574b
commit c3131838ef
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
5 changed files with 22 additions and 20 deletions

View File

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService, coinbaseService, appConfigService) {
angular.module('copayApp.controllers').controller('amountController', function($scope, $filter, $timeout, $ionicScrollDelegate, $ionicHistory, gettextCatalog, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, txFormatService, ongoingProcess, bitpayCardService, popupService, bwcError, payproService, profileService, bitcore, amazonService, glideraService, appConfigService) {
var unitToSatoshi;
var satToUnit;
var unitDecimals;
@ -20,8 +20,8 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.isGlidera = data.stateParams.isGlidera;
$scope.glideraAccessToken = data.stateParams.glideraAccessToken;
// Coinbase
$scope.coinbase = data.stateParams.coinbase;
// Go to...
$scope.nextStep = data.stateParams.nextStep;
$scope.cardId = data.stateParams.cardId;
$scope.showMenu = $ionicHistory.backView() && $ionicHistory.backView().stateName == 'tabs.send';
@ -30,13 +30,13 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.toAddress = data.stateParams.toAddress;
$scope.toName = data.stateParams.toName;
$scope.toEmail = data.stateParams.toEmail;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera || !!$scope.coinbase;
$scope.showAlternativeAmount = !!$scope.cardId || !!$scope.isGiftCard || !!$scope.isGlidera || !!$scope.nextStep;
$scope.toColor = data.stateParams.toColor;
$scope.showSendMax = false;
$scope.customAmount = data.stateParams.customAmount;
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !$scope.coinbase && !data.stateParams.toAddress) {
if (!$scope.cardId && !$scope.isGiftCard && !$scope.isGlidera && !$scope.nextStep && !data.stateParams.toAddress) {
$log.error('Bad params at amount')
throw ('bad params');
}
@ -357,15 +357,9 @@ angular.module('copayApp.controllers').controller('amountController', function($
isGlidera: $scope.isGlidera,
glideraAccessToken: $scope.glideraAccessToken
});
} else if ($scope.coinbase) {
} else if ($scope.nextStep) {
var amountAlternative = $scope.showAlternativeAmount ? _amount : $filter('formatFiatAmount')(toFiat(_amount));
if (amountAlternative < 1) {
popupService.showAlert(gettextCatalog.getString('Error'), 'Amount must be at least 1.00 ' + $scope.alternativeIsoCode);
return;
}
var goTo = 'tabs.buyandsell.coinbase.' + $scope.coinbase;
$state.transitionTo(goTo, {
$state.transitionTo($scope.nextStep, {
amount: amountAlternative,
currency: $scope.alternativeIsoCode
});

View File

@ -15,6 +15,14 @@ angular.module('copayApp.controllers').controller('buyCoinbaseController', funct
$scope.$on("$ionicView.beforeEnter", function(event, data) {
amount = data.stateParams.amount;
currency = data.stateParams.currency;
console.log('[buyCoinbase.js:17]',amount, currency); //TODO
if (amount < 1) {
popupService.showAlert('Error', 'Amount must be at least 1.00 ' + currency, function() {
$ionicHistory.goBack();
});
return;
}
$scope.network = coinbaseService.getNetwork();
$scope.wallets = profileService.getWallets({

View File

@ -942,7 +942,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
})
.state('tabs.buyandsell.coinbase.amount', {
url: '/amount/:coinbase/:currency',
url: '/amount/:nextStep/:currency',
views: {
'tab-home@tabs': {
controller: 'amountController',

View File

@ -1,7 +1,7 @@
<ion-view id="view-amount" hide-tabs>
<ion-nav-bar class="bar-royal">
<ion-nav-title>
{{coinbase ? (coinbase == 'buy' ? 'Buy bitcoin' : 'Sell bitcoin') : ('Enter Amount' | translate)}}
{{'Enter Amount' | translate}}
</ion-nav-title>
<ion-nav-back-button>
</ion-nav-back-button>
@ -14,7 +14,7 @@
<ion-content scroll="false">
<div ng-if="!customAmount && !isGlidera && !coinbase">
<div ng-if="!customAmount && !isGlidera && !nextStep">
<div class="item item-no-bottom-border recipient-label" translate>Recipient</div>
<div class="item item-text-wrap item-icon-left bitcoin-address" ng-class="{'item-big-icon-left':cardId}">
@ -39,8 +39,8 @@
</div>
</div>
<div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera && !coinbase,
'amount-pane-no-recipient': customAmount || isGlidera || coinbase}">
<div ng-class="{'amount-pane-recipient': !customAmount && !isGlidera && !nextStep,
'amount-pane-no-recipient': customAmount || isGlidera || nextStep}">
<div class="amount-bar oh">
<div class="title">

View File

@ -68,13 +68,13 @@
<div class="list card"
ng-show="accountId">
<a class="item item-icon-right"
href ui-sref="tabs.buyandsell.coinbase.amount({coinbase: 'buy', currency: currency})">
href ui-sref="tabs.buyandsell.coinbase.amount({nextStep: 'tabs.buyandsell.coinbase.buy', currency: currency})">
<img src="img/buy-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-buy">
Buy Bitcoin
<i class="icon bp-arrow-right"></i>
</a>
<a class="item item-icon-right"
href ui-sref="tabs.buyandsell.coinbase.amount({coinbase: 'sell', currency: currency})">
href ui-sref="tabs.buyandsell.coinbase.amount({nextStep: 'tabs.buyandsell.coinbase.sell', currency: currency})">
<img src="img/sell-bitcoin.svg" alt="buy bitcoin" width="35" class="item-img-sell">
Sell Bitcoin
<i class="icon bp-arrow-right"></i>