Wallet/js/controllers/walletForPayment.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

var bitcore = require('bitcore');
2014-12-09 15:46:03 -03:00
angular.module('copayApp.controllers').controller('walletForPaymentController', function($rootScope, $scope, $modal, identityService, go) {
$scope.selectWallet = function(cb) {
2014-12-09 15:46:03 -03:00
var ModalInstanceCtrl = function($scope, $modalInstance, identityService) {
$scope.loading = true;
preconditions.checkState($rootScope.iden);
var iden = $rootScope.iden;
iden.on('newWallet', function() {
$scope.setWallets();
});
$scope.setWallets = function() {
2014-12-09 15:46:03 -03:00
$scope.wallets = $rootScope.iden.listWallets();
};
$scope.ok = function(w) {
$modalInstance.close();
return cb(w);
};
$scope.cancel = function() {
$modalInstance.close();
return cb();
};
};
$modal.open({
2014-12-09 15:46:03 -03:00
templateUrl: 'views/modals/walletSelection.html',
windowClass: 'tiny',
controller: ModalInstanceCtrl,
});
};
2014-12-09 15:46:03 -03:00
// INIT: (not it a function, since there is no associated html)
if (!$rootScope.pendingPayment) {
go.walletHome();
} else {
$scope.selectWallet(function(w) {
if (w) {
identityService.setFocusedWallet(w);
go.send();
} else {
go.walletHome();
}
});
};
});