Wallet/js/controllers/paymentIntent.js
Gustavo Maximiliano Cortez 68f21f3c4d fix payment intent
2014-12-01 17:28:03 -03:00

49 lines
1.4 KiB
JavaScript

'use strict';
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, $timeout, balanceService) {
$rootScope.title = 'Payment intent';
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl
});
};
// Please note that $modalInstance represents a modal window (instance) dependency.
// It is not the same as the $modal service used above.
var ModalInstanceCtrl = function($scope, $modalInstance, identityService) {
$scope.loading = true;
$scope.setWallets = function() {
if (!$rootScope.iden) return;
var ret = _.filter($rootScope.iden.listWallets(), function(w) {
return w.balanceInfo && w.balanceInfo.totalBalanceBTC;
});
$timeout(function() {
$scope.wallets = ret;
$scope.loading = false;
$scope.$digest();
}, 1000);
};
if ($rootScope.iden) {
var iden = $rootScope.iden;
iden.on('newWallet', function() {
$scope.setWallets();
});
}
$scope.ok = function(selectedItem) {
identityService.setPaymentWallet(selectedItem);
$modalInstance.close();
};
$scope.cancel = function() {
$rootScope.pendingPayment = null;
$modalInstance.close();
$location.path('/homeWallet');
};
};
});