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 class="button-block">
<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>Send</span>
</button>
</div>
<button class="item button button-block button-balanced" ng-click="approve()" ng-disabled="!txp">
<span ng-show="wallet.canSign()" translate>Approve</span>
<span ng-show="!wallet.canSign()" translate>Send</span>
</button>
</ion-content>
</ion-view>

View file

@ -1,11 +1,11 @@
<div class="padding">
<input type="text" ng-model="data.comment" autofocus>
<input type="text" ng-model="comment" autofocus>
</div>
<div class="row">
<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 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>

View file

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

View file

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

View file

@ -153,11 +153,11 @@ angular.module('copayApp.directives')
link: function(scope, element, attrs) {
scope.$on("$ionicSlides.sliderInitialized", function(event, data) {
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.$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 {
height: 105px;
}
.no-pager .swiper-pagination {
display: none;
}
/*
* Calculator
*/