paypro: fixes. clean up form reset from paypro. etc.

This commit is contained in:
Christopher Jeffrey 2014-08-01 20:22:11 -07:00 committed by Manuel Araoz
commit 64b38802bf
3 changed files with 38 additions and 58 deletions

View file

@ -64,13 +64,6 @@ angular.module('copayApp.controllers').controller('SendController',
function done(ntxid, ca) { function done(ntxid, ca) {
var txp = w.txProposals.txps[ntxid]; var txp = w.txProposals.txps[ntxid];
var merchantData = txp.merchant; var merchantData = txp.merchant;
var amt = angular.element(document.querySelector('input#amount'));
var sendto = angular.element(document
.querySelector('div.send-note > p[ng-class]:first-of-type'));
var tamount = angular.element(document
.querySelector('div.send-note > p[ng-class]:nth-of-type(2)'));
var submit = angular.element(document.querySelector('button[type=submit]'));
var sendall = angular.element(document.querySelector('[title="Send all funds"]'));
if (w.isShared()) { if (w.isShared()) {
$scope.loading = false; $scope.loading = false;
var message = 'The transaction proposal has been created'; var message = 'The transaction proposal has been created';
@ -83,13 +76,6 @@ angular.module('copayApp.controllers').controller('SendController',
} }
notification.success('Success!', message); notification.success('Success!', message);
$scope.loadTxs(); $scope.loadTxs();
if (merchantData) {
amt.attr('disabled', false);
sendto.html(sendto.html().replace(/<br><b>Server:.*$/, ''));
tamount.html('');
submit.attr('disabled', true);
sendall.attr('class', sendall.attr('class').replace(' hidden', ''));
}
} else { } else {
w.sendTx(ntxid, function(txid, ca) { w.sendTx(ntxid, function(txid, ca) {
if (txid) { if (txid) {
@ -107,13 +93,6 @@ angular.module('copayApp.controllers').controller('SendController',
} }
$scope.loading = false; $scope.loading = false;
$scope.loadTxs(); $scope.loadTxs();
if (merchantData) {
amt.attr('disabled', false);
sendto.html(sendto.html().replace(/<br><b>Server:.*$/, ''));
tamount.html('');
submit.attr('disabled', true);
sendall.attr('class', sendall.attr('class').replace(' hidden', ''));
}
}); });
} }
$rootScope.pendingPayment = null; $rootScope.pendingPayment = null;

View file

@ -44,11 +44,14 @@ angular.module('copayApp.directives')
// XXX There needs to be a better way to do this: // XXX There needs to be a better way to do this:
total = +total / config.unitToSatoshi; total = +total / config.unitToSatoshi;
// XXX Pretty much all of this code accesses the raw DOM. It's
// very bad, there's probably a better, more angular-y way to
// do things here.
var address = angular.element( var address = angular.element(
document.querySelector('input#address')); document.querySelector('input#address'));
var amount = angular.element( var amount = angular.element( document.querySelector('input#amount'));
document.querySelector('input#amount'));
amount.val(total); amount.val(total);
amount.attr('disabled', true); amount.attr('disabled', true);
@ -67,8 +70,7 @@ angular.module('copayApp.directives')
+ expires.toISOString() + expires.toISOString()
+ ')'); + ')');
var submit = angular.element( var submit = angular.element( document.querySelector('button[type=submit]'));
document.querySelector('button[type=submit]'));
submit.attr('disabled', false); submit.attr('disabled', false);
var sendall = angular.element( var sendall = angular.element(
@ -76,39 +78,36 @@ angular.module('copayApp.directives')
sendall.attr('class', sendall.attr('class') + ' hidden'); sendall.attr('class', sendall.attr('class') + ' hidden');
// Reset all the changes from the payment protocol weirdness. // Reset all the changes from the payment protocol weirdness.
//address.attr('ng-change', 'ppChange()'); // XXX Bad hook.
//scope.ppChange = scope.ppChange || function() { if (!scope.__watchingAddress) {
//address.on('change', function(ev) { scope.__watchingAddress = true;
scope.$watch('address', function(newValue, oldValue) { scope.$watch('address', function(newValue, oldValue) {
var val = address.val(); var val = address.val();
var uri = copay.HDPath.parseBitcoinURI(val || ''); var uri = copay.HDPath.parseBitcoinURI(val || '');
if (!uri || !uri.merchant) { if (!uri || !uri.merchant) {
if (amount.attr('disabled') === true) { if (amount.attr('disabled')) {
amount.attr('disabled', false); amount.val('');
amount.attr('disabled', false);
}
sendto.html(sendto.html().replace(/<br><b>Server:.*$/, ''));
if (!/hidden/.test(tamount.attr('class'))) {
tamount.attr(tamount.attr('class') + ' hidden');
}
if (~tamount.html().indexOf('(CA: ')) {
tamount.html('');
}
if (!submit.attr('disabled')) {
submit.attr('disabled', true);
}
if (/ hidden$/.test(sendall.attr('class'))) {
sendall.attr('class',
sendall.attr('class').replace(' hidden', ''));
}
} }
if (submit.attr('disabled') === false) { // TODO: Check paymentRequest expiration,
submit.attr('disabled', true); // delete if beyond expiration date.
} });
sendto.html(sendto.html().replace(/<br><b>Server:.*$/, '')); }
if (!/hidden/.test(tamount.attr('class'))) {
tamount.attr(tamount.attr('class') + ' hidden');
}
if (~tamount.html().indexOf('(CA: ')) {
tamount.html('');
}
if (submit.attr('disabled') === false) {
submit.attr('disabled', true);
}
if (/ hidden$/.test(sendall.attr('class'))) {
sendall.attr('class',
sendall.attr('class').replace(' hidden', ''));
}
}
// TODO: Check paymentRequest expiration,
// delete if beyond expiration date.
//};
});
//scope.$apply(); // scope.$digest();
ctrl.$setValidity('validAddress', true); ctrl.$setValidity('validAddress', true);

View file

@ -1035,7 +1035,9 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
// 'Content-Length': (pay.byteLength || pay.length) + '', // 'Content-Length': (pay.byteLength || pay.length) + '',
// 'Content-Transfer-Encoding': 'binary' // 'Content-Transfer-Encoding': 'binary'
}, },
data: buf, // Technically how this should be done via XHR. // Technically how this should be done via XHR (used to
// be the ArrayBuffer, now you send the View instead).
data: view,
responseType: 'arraybuffer' responseType: 'arraybuffer'
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {