add confirm fixes
This commit is contained in:
parent
c21afeca30
commit
e040871e26
2 changed files with 31 additions and 25 deletions
|
|
@ -27,9 +27,6 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
|
|
||||||
function setAvailableUnits() {
|
function setAvailableUnits() {
|
||||||
|
|
||||||
// TODO: Depends on the available wallets
|
|
||||||
// also, depends on forceCurrency & forceCoin
|
|
||||||
// Take this from somewhere elase
|
|
||||||
availableUnits = [{
|
availableUnits = [{
|
||||||
name: 'Bitcoin',
|
name: 'Bitcoin',
|
||||||
id: 'btc',
|
id: 'btc',
|
||||||
|
|
@ -70,20 +67,18 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
_id = data.stateParams.id; // Optional (BitPay Card ID or Wallet ID)
|
_id = data.stateParams.id; // Optional (BitPay Card ID or Wallet ID)
|
||||||
$scope.nextStep = data.stateParams.nextStep;
|
$scope.nextStep = data.stateParams.nextStep;
|
||||||
|
|
||||||
// TODO
|
|
||||||
$scope.currency = data.stateParams.currency;
|
|
||||||
$scope.forceCurrency = data.stateParams.forceCurrency;
|
$scope.forceCurrency = data.stateParams.forceCurrency;
|
||||||
$scope.forceCoin = data.stateParams.forceCoin;
|
$scope.forceCoin = data.stateParams.forceCoin;
|
||||||
|
|
||||||
|
if (data.stateParams.coin) {
|
||||||
|
var index = lodash.findIndex(availableUnits, { id: data.stateParams.coin });
|
||||||
|
|
||||||
// TODO
|
if (index < 0) {
|
||||||
// if (data.stateParams.coin) {
|
$log.warn('Could not find desired coin:' + data.stateParams.coin)
|
||||||
// unitIndex = lodash.indexOf(data.stateParams.coin.toUpperCase());
|
} else {
|
||||||
// if (unitIndex < 0) {
|
unitIndex = index;
|
||||||
// $log.warn('Could not find desired coin:' + data.stateParams.coin)
|
}
|
||||||
// unitIndex = 0;
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
setAvailableUnits();
|
setAvailableUnits();
|
||||||
updateUnitUI();
|
updateUnitUI();
|
||||||
|
|
@ -172,11 +167,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
$scope.toggleAlternative = function() {
|
$scope.toggleAlternative = function() {
|
||||||
if ($scope.forceCurrency) return;
|
|
||||||
$scope.showAlternativeAmount = !$scope.showAlternativeAmount;
|
|
||||||
|
|
||||||
if ($scope.amount && isExpression($scope.amount)) {
|
if ($scope.amount && isExpression($scope.amount)) {
|
||||||
var amount = evaluate(format($scope.amount));
|
var amount = evaluate(format($scope.amount));
|
||||||
$scope.globalResult = '= ' + processResult(amount);
|
$scope.globalResult = '= ' + processResult(amount);
|
||||||
|
|
@ -193,8 +184,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.changeUnit = function() {
|
$scope.changeUnit = function() {
|
||||||
// TODO
|
if ($scope.forceCurrency || $scope.forceCoin) return;
|
||||||
// if ($scope.forceCurrency || $scope.forceCoin) return;
|
|
||||||
|
|
||||||
unitIndex++;
|
unitIndex++;
|
||||||
if (unitIndex >= availableUnits.length) unitIndex = 0;
|
if (unitIndex >= availableUnits.length) unitIndex = 0;
|
||||||
|
|
@ -334,27 +324,42 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.finish = function() {
|
$scope.finish = function() {
|
||||||
|
|
||||||
|
var unit = availableUnits[unitIndex];
|
||||||
var _amount = evaluate(format($scope.amount));
|
var _amount = evaluate(format($scope.amount));
|
||||||
|
|
||||||
if ($scope.nextStep) {
|
if ($scope.nextStep) {
|
||||||
|
|
||||||
|
var coin = unit.id;
|
||||||
|
if (unit.isFiat) {
|
||||||
|
coin = availableUnits[altUnitIndex].id;
|
||||||
|
}
|
||||||
|
|
||||||
$state.transitionTo($scope.nextStep, {
|
$state.transitionTo($scope.nextStep, {
|
||||||
id: _id,
|
id: _id,
|
||||||
amount: $scope.useSendMax ? null : _amount,
|
amount: $scope.useSendMax ? null : _amount,
|
||||||
// TODO
|
currency: unit.id.toUpperCase(),
|
||||||
currency: $scope.showAlternativeAmount ? fiatCode : (coin).toUpperCase(),
|
|
||||||
coin: coin,
|
coin: coin,
|
||||||
useSendMax: $scope.useSendMax
|
useSendMax: $scope.useSendMax
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var amount = $scope.showAlternativeAmount ? fromFiat(_amount) : _amount;
|
var amount = _amount;
|
||||||
|
|
||||||
|
if (unit.isFiat) {
|
||||||
|
amount = fromFiat(_amount);
|
||||||
|
} else if ($scope.useSendMax){
|
||||||
|
amount = (amount * unitToSatoshi).toFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$state.transitionTo('tabs.send.confirm', {
|
$state.transitionTo('tabs.send.confirm', {
|
||||||
recipientType: $scope.recipientType,
|
recipientType: $scope.recipientType,
|
||||||
toAmount: $scope.useSendMax ? null : (amount * unitToSatoshi).toFixed(0),
|
toAmount: amount,
|
||||||
toAddress: $scope.toAddress,
|
toAddress: $scope.toAddress,
|
||||||
toName: $scope.toName,
|
toName: $scope.toName,
|
||||||
toEmail: $scope.toEmail,
|
toEmail: $scope.toEmail,
|
||||||
toColor: $scope.toColor,
|
toColor: $scope.toColor,
|
||||||
coin: coin,
|
coin: unit.id,
|
||||||
useSendMax: $scope.useSendMax
|
useSendMax: $scope.useSendMax
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
// no min amount? (sendMax) => look for no empty wallets
|
// no min amount? (sendMax) => look for no empty wallets
|
||||||
minAmount = minAmount || 1;
|
minAmount = minAmount || 1;
|
||||||
|
|
||||||
|
console.log('[confirm.js.76]', network, coin); //TODO
|
||||||
$scope.wallets = profileService.getWallets({
|
$scope.wallets = profileService.getWallets({
|
||||||
onlyComplete: true,
|
onlyComplete: true,
|
||||||
network: network,
|
network: network,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue