implement send all support

This commit is contained in:
Matias Alejo Garcia 2015-06-19 15:00:27 -03:00
commit 206fe41db5
4 changed files with 35 additions and 3 deletions

View file

@ -278,6 +278,11 @@
<div>
<h4 class="title m0">
<button class="outline light-gray round tiny right m0 lh"
ng-click="home.sendAll(index.availableMaxBalance, index.feeToSendMaxStr)"
ng-if="index.availableBalance > 0 && !home.blockUx && !home.lockAmount" translate> Send All
</button>
<div ng-show="!index.lockedBalance && index.availableBalanceStr">
<div class="size-12">
<span class="db text-bold">
@ -397,10 +402,10 @@
</div>
<div class="row" ng-show="!home.onGoingProcess">
<div class="large-6 medium-6 small-6 columns" ng-show="!home.blockUx && (home._paypro || home.lockAddress)">
<div class="large-6 medium-6 small-6 columns" ng-show="!home.blockUx && (home._paypro || home.lockAddress || home.lockAmount)">
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
</div>
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress)}">
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
<button type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline"
ng-style="{'background-color':index.backgroundColor}" translate>
Send

View file

@ -436,6 +436,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.lockedBalanceBTC = strip(self.lockedBalanceSat / COIN);
self.availableBalanceBTC = strip(self.availableBalanceBTC / COIN);
// KB to send max
self.feePerKbSat = config.feePerKbSat || 10000;
var feeToSendMaxSat = balance.totalKbToSendMax * self.feePerKbSat;
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
//STR
self.totalBalanceStr = profileService.formatAmount(self.totalBalanceSat) + ' ' + self.unitName;

View file

@ -917,6 +917,27 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return actions.hasOwnProperty('create');
};
this._doSendAll = function(amount) {
this.setForm(null, amount);
};
this.sendAll = function(amount, feeStr) {
var msg = gettextCatalog.getString("{{fee}} will be discounted for bitcoin networking fees", {
fee: feeStr
});
if (isCordova) {
navigator.notification.confirm(
msg,
this._doSendAll(amount),
'OK', 'Cancel'
);
} else {
if (confirm(msg))
this._doSendAll(amount);
}
}
this.bindTouchDown();
this.setAddress();
this.setSendFormInputs();

View file

@ -58,7 +58,7 @@ angular
historicLog.add(level, args.join(' '));
orig.apply(null, args);
} catch (e) {
console.log('Error at log decorator:', e);
console.log('ERROR (at log decorator):', e, args[0]);
}
};
});