send form

This commit is contained in:
Matias Alejo Garcia 2015-01-03 20:32:31 -03:00
commit 38495f11b7
2 changed files with 47 additions and 21 deletions

View file

@ -3,7 +3,7 @@ var bitcore = require('bitcore');
var preconditions = require('preconditions').singleton(); var preconditions = require('preconditions').singleton();
angular.module('copayApp.controllers').controller('SendController', angular.module('copayApp.controllers').controller('SendController',
function($scope, $rootScope, $window, $timeout, $modal, $filter, notification, isMobile, rateService, txStatus) { function($scope, $rootScope, $window, $timeout, $modal, $filter, notification, isMobile, rateService, txStatus, isCordova) {
var satToUnit; var satToUnit;
@ -73,7 +73,7 @@ angular.module('copayApp.controllers').controller('SendController',
} }
$timeout(function() { $timeout(function() {
$rootScope.$digest(); $rootScope.$digest();
}, 1); }, 100);
}; };
$scope.setInputs = function() { $scope.setInputs = function() {
@ -178,25 +178,35 @@ angular.module('copayApp.controllers').controller('SendController',
} }
$scope.loading = true; $scope.loading = true;
var comment = form.comment.$modelValue; $scope.creatingTX = true;
var merchantData = $scope._merchantData; if ($scope.isWindowsPhoneApp)
var address, amount; $rootScope.wpInputFocused = true;
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
}
w.spend({ $timeout(function () {
merchantData: merchantData, var comment = form.comment.$modelValue;
toAddress: address, var merchantData = $scope._merchantData;
amountSat: amount, var address, amount;
comment: comment, if (!merchantData) {
}, function(err, txid, status) { address = form.address.$modelValue;
$scope.loading = false; amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
if (err) }
return $scope.setError(err);
txStatus.notify(status); w.spend({
$scope.resetForm(); merchantData: merchantData,
toAddress: address,
amountSat: amount,
comment: comment,
}, function (err, txid, status) {
$scope.loading = false;
$scope.creatingTX = false;
if ($scope.isWindowsPhoneApp)
$rootScope.wpInputFocused = false;
if (err)
return $scope.setError(err);
txStatus.notify(status);
$scope.resetForm();
});
}); });
}; };

View file

@ -29,7 +29,23 @@
</div> </div>
</div> </div>
<div class="row" ng-show="!fetchingURL"> <div class="row" ng-show="creatingTX">
<div class="large-12 columns">
<div class="panel">
<div class="box-notification">
<div class="box-icon secondary">
<i class="fi-bitcoin-circle icon-rotate spinner size-24"></i>
</div>
<span class="text-secondary size-14">
Creating Transaction...
</span>
</div>
</div>
</div>
</div>
<div class="row" ng-show="!fetchingURL && !creatingTX">
<div class="large-8 large-centered columns"> <div class="large-8 large-centered columns">
<form name="sendForm" ng-submit="submitForm(sendForm)" novalidate> <form name="sendForm" ng-submit="submitForm(sendForm)" novalidate>
<div class="panel"> <div class="panel">