mirror of https://github.com/BTCPrivate/copay.git
autocomplete send form after uri handled
This commit is contained in:
parent
8b25b5932f
commit
8acaca75fb
|
@ -71,7 +71,9 @@ angular.module('copayApp.controllers').controller('HeaderController',
|
|||
|
||||
$rootScope.$watch('txAlertCount', function(txAlertCount) {
|
||||
if (txAlertCount && txAlertCount > 0) {
|
||||
notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount);
|
||||
notification.info('New Transaction', ($rootScope.txAlertCount == 1) ?
|
||||
'You have a pending transaction proposal' :
|
||||
'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -23,6 +23,13 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
return flag;
|
||||
};
|
||||
|
||||
if ($rootScope.pendingPayment) {
|
||||
var pp = $rootScope.pendingPayment;
|
||||
$scope.address = pp.address;
|
||||
var amount = pp.amount / config.unitToSatoshi * 100000000;
|
||||
$scope.amount = amount;
|
||||
}
|
||||
|
||||
// Detect protocol
|
||||
$scope.isHttp = ($window.location.protocol.indexOf('http') === 0);
|
||||
|
||||
|
@ -61,6 +68,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
$scope.loading = false;
|
||||
});
|
||||
}
|
||||
$rootScope.pendingPayment = null;
|
||||
});
|
||||
|
||||
// reset fields
|
||||
|
@ -265,7 +273,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
};
|
||||
|
||||
$scope.topAmount = function(form) {
|
||||
$scope.amount = $scope.getAvailableAmount();
|
||||
$scope.amount = $scope.getAvailableAmount();
|
||||
form.amount.$pristine = false;
|
||||
};
|
||||
});
|
||||
|
|
|
@ -13,6 +13,10 @@ angular.module('copayApp.controllers').controller('SigninController',
|
|||
$scope.selectedWalletId = $scope.wallets.length ? $scope.wallets[0].id : null;
|
||||
$scope.openPassword = '';
|
||||
|
||||
if ($rootScope.pendingPayment) {
|
||||
notification.info('Login Required', 'Please open wallet to complete payment');
|
||||
}
|
||||
|
||||
$scope.open = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams) {
|
||||
angular.module('copayApp.controllers').controller('UriPaymentController', function($rootScope, $scope, $routeParams, $timeout, $location) {
|
||||
var data = decodeURIComponent($routeParams.data);
|
||||
var splitDots = data.split(':');
|
||||
$scope.protocol = splitDots[0];
|
||||
|
@ -12,7 +12,19 @@ angular.module('copayApp.controllers').controller('UriPaymentController', functi
|
|||
function(key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
});
|
||||
$scope.amount = parseInt(data.amount);
|
||||
$scope.amount = parseFloat(data.amount);
|
||||
$scope.message = data.message;
|
||||
|
||||
$rootScope.pendingPayment = {
|
||||
protocol: $scope.protocol,
|
||||
address: $scope.address,
|
||||
amount: $scope.amount,
|
||||
message: $scope.message
|
||||
};
|
||||
|
||||
$timeout(function() {
|
||||
$location.path('signin');
|
||||
}, 1000);
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -103,7 +103,11 @@ angular.module('copayApp.services')
|
|||
});
|
||||
w.on('ready', function(myPeerID) {
|
||||
$rootScope.wallet = w;
|
||||
$location.path('addresses');
|
||||
if ($rootScope.pendingPayment) {
|
||||
$location.path('send');
|
||||
} else {
|
||||
$location.path('addresses');
|
||||
}
|
||||
if (!config.disableVideo)
|
||||
video.setOwnPeer(myPeerID, w, handlePeerVideo);
|
||||
});
|
||||
|
|
|
@ -373,7 +373,7 @@ describe("Unit: Controllers", function() {
|
|||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
var routeParams = {
|
||||
data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=1&message=a%20bitcoin%20donation'
|
||||
data: 'bitcoin:19mP9FKrXqL46Si58pHdhGKow88SUPy1V8%3Famount=0.1&message=a%20bitcoin%20donation'
|
||||
};
|
||||
what = $controller('UriPaymentController', {
|
||||
$scope: scope,
|
||||
|
@ -389,7 +389,7 @@ describe("Unit: Controllers", function() {
|
|||
should.exist(what);
|
||||
scope.protocol.should.equal('bitcoin');
|
||||
scope.address.should.equal('19mP9FKrXqL46Si58pHdhGKow88SUPy1V8');
|
||||
scope.amount.should.equal(1);
|
||||
scope.amount.should.equal(0.1);
|
||||
scope.message.should.equal('a bitcoin donation');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue