This commit is contained in:
Javier 2016-08-25 10:19:39 -03:00
commit 48a2be626d
6 changed files with 43 additions and 53 deletions

View file

@ -55,11 +55,9 @@
</div> </div>
</div> </div>
<div class="button-block"> <button class="item button button-block button-balanced" ng-click="approve()" ng-disabled="!txp">
<button class="item button button-full button-balanced" ng-click="approve()" ng-disabled="!txp"> <span ng-show="wallet.canSign()" translate>Approve</span>
<span ng-show="wallet.canSign()" translate>Approve</span> <span ng-show="!wallet.canSign()" translate>Send</span>
<span ng-show="!wallet.canSign()" translate>Send</span> </button>
</button>
</div>
</ion-content> </ion-content>
</ion-view> </ion-view>

View file

@ -1,11 +1,11 @@
<div class="padding"> <div class="padding">
<input type="text" ng-model="data.comment" autofocus> <input type="text" ng-model="comment" autofocus>
</div> </div>
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<button class="button button-dark button-block" ng-click="commentPopupClose()" translate>Cancel</button> <button class="button button-dark button-block" ng-click="commentPopupClose(comment)" translate>Cancel</button>
</div> </div>
<div class="col"> <div class="col">
<button class="button button-dark button-block" ng-click="commentPopupSave()" translate>Save</button> <button class="button button-dark button-block" ng-click="commentPopupSave(comment)" translate>Save</button>
</div> </div>
</div> </div>

View file

@ -28,12 +28,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.commentPopupClose = function() { $scope.commentPopupClose = function() {
commentPopup.close(); commentPopup.close();
}; };
$scope.commentPopupSave = function() { $scope.commentPopupSave = function(description) {
$log.debug('Saving description: ' + $scope.data.comment); $log.debug('Saving description: ' + description);
$scope.description = $scope.data.comment; $scope.description = description;
$scope.txp = null; $scope.txp = null;
ongoingProcess.set('creatingTx', true);
createTx($scope.wallet, function(err, txp) { createTx($scope.wallet, function(err, txp) {
ongoingProcess.set('creatingTx', false);
if (err) return; if (err) return;
cachedTxp[$scope.wallet.id] = txp; cachedTxp[$scope.wallet.id] = txp;
apply(txp); apply(txp);
@ -97,7 +99,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$log.error('Bad params at amount') $log.error('Bad params at amount')
throw ('bad params'); throw ('bad params');
} }
$scope.isCordova = platformInfo.isCordova; $scope.isCordova = platformInfo.isCordova;
var config = configService.getSync().wallet; var config = configService.getSync().wallet;
@ -123,34 +124,32 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var filteredWallets = []; var filteredWallets = [];
var index = 0; var index = 0;
filterWallet(); ongoingProcess.set('scanning', true);
function filterWallet() { lodash.each(wallets, function(w) {
if (index == wallets.length) { walletService.getStatus(w, {}, function(err, status) {
if (!lodash.isEmpty(filteredWallets)) {
$log.debug('Wallet changed: ' + filteredWallets[0].name);
$scope.wallets = lodash.clone(filteredWallets);
setWallet(wallets[0], true);
$scope.notAvailable = false;
} else {
$scope.notAvailable = true;
$log.warn('No wallet available to make the payment');
}
$timeout(function() {
$scope.$apply();
}, 10);
return;
}
walletService.getStatus(wallets[index], {}, function(err, status) {
if (err) $log.error(err); if (err) $log.error(err);
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + wallets[index].name); if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
if (status.availableBalanceSat > amount) filteredWallets.push(wallets[index]); if (status.availableBalanceSat > amount) filteredWallets.push(w);
index++;
filterWallet(); if (++index == wallets.length) {
ongoingProcess.set('scanning', false);
if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets);
$scope.notAvailable = false;
} else {
$scope.notAvailable = true;
$log.warn('No wallet available to make the payment');
}
$timeout(function() {
$scope.$apply();
}, 10);
return;
}
}); });
}; });
txFormatService.formatAlternativeStr(amount, function(v) { txFormatService.formatAlternativeStr(amount, function(v) {
$scope.alternativeAmountStr = v; $scope.alternativeAmountStr = v;
@ -158,7 +157,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
}; };
$scope.$on('Wallet/Changed', function(event, wallet) { $scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) { if (lodash.isEmpty(wallet)) {
$log.debug('No wallet provided'); $log.debug('No wallet provided');
return; return;
} }
@ -172,6 +171,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.fee = $scope.txp = null; $scope.fee = $scope.txp = null;
$timeout(function() { $timeout(function() {
$ionicScrollDelegate.resize();
$scope.$apply(); $scope.$apply();
}, 10); }, 10);
@ -180,17 +180,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
stop = null; stop = null;
} }
function apply(txp) {
$scope.fee = txFormatService.formatAmountStr(txp.fee);
$scope.txp = txp;
$scope.$apply();
};
if (cachedTxp[wallet.id]) { if (cachedTxp[wallet.id]) {
apply(cachedTxp[wallet.id]); apply(cachedTxp[wallet.id]);
} else { } else {
ongoingProcess.set('creatingTx', true);
stop = $timeout(function() { stop = $timeout(function() {
createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.comment || null, function(err, txp) { createTx(wallet, function(err, txp) {
ongoingProcess.set('creatingTx', false);
if (err) return; if (err) return;
cachedTxp[wallet.id] = txp; cachedTxp[wallet.id] = txp;
apply(txp); apply(txp);

View file

@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
} }
$scope.$on('Wallet/Changed', function(event, wallet) { $scope.$on('Wallet/Changed', function(event, wallet) {
if (!wallet) { if (lodash.isEmpty(wallet)) {
$log.debug('No wallet provided'); $log.debug('No wallet provided');
return; return;
} }

View file

@ -153,11 +153,11 @@ angular.module('copayApp.directives')
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
scope.$on("$ionicSlides.sliderInitialized", function(event, data) { scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
scope.slider = data.slider; scope.slider = data.slider;
scope.$emit('Wallet/Changed', scope.wallets[0]); scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[0] : null);
}); });
scope.$on("$ionicSlides.slideChangeEnd", function(event, data) { scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
scope.$emit('Wallet/Changed', scope.wallets[data.slider.activeIndex]); scope.$emit('Wallet/Changed', scope.wallets ? scope.wallets[data.slider.activeIndex] : null);
}); });
} }
} }

View file

@ -880,10 +880,6 @@ input[type=file] {
.wallets { .wallets {
height: 105px; height: 105px;
} }
.no-pager .swiper-pagination {
display: none;
}
/* /*
* Calculator * Calculator
*/ */