send form

This commit is contained in:
Matias Alejo Garcia 2015-01-03 20:32:31 -03:00
parent 22a533377b
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();
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;
@ -73,7 +73,7 @@ angular.module('copayApp.controllers').controller('SendController',
}
$timeout(function() {
$rootScope.$digest();
}, 1);
}, 100);
};
$scope.setInputs = function() {
@ -178,25 +178,35 @@ angular.module('copayApp.controllers').controller('SendController',
}
$scope.loading = true;
var comment = form.comment.$modelValue;
var merchantData = $scope._merchantData;
var address, amount;
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
}
$scope.creatingTX = true;
if ($scope.isWindowsPhoneApp)
$rootScope.wpInputFocused = true;
w.spend({
merchantData: merchantData,
toAddress: address,
amountSat: amount,
comment: comment,
}, function(err, txid, status) {
$scope.loading = false;
if (err)
return $scope.setError(err);
txStatus.notify(status);
$scope.resetForm();
$timeout(function () {
var comment = form.comment.$modelValue;
var merchantData = $scope._merchantData;
var address, amount;
if (!merchantData) {
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
}
w.spend({
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

@ -28,8 +28,24 @@
</div>
</div>
</div>
<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">
<div class="row" ng-show="!fetchingURL && !creatingTX">
<div class="large-8 large-centered columns">
<form name="sendForm" ng-submit="submitForm(sendForm)" novalidate>
<div class="panel">