2014-11-03 18:02:21 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2014-11-29 18:35:48 -03:00
|
|
|
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, balanceService) {
|
2014-11-03 18:02:21 -03:00
|
|
|
|
2014-12-01 05:24:19 -03:00
|
|
|
$rootScope.title = 'Payment intent';
|
2014-11-03 18:02:21 -03:00
|
|
|
|
2014-12-01 05:24:19 -03:00
|
|
|
$scope.open = function() {
|
2014-11-04 15:24:56 -03:00
|
|
|
var modalInstance = $modal.open({
|
|
|
|
|
templateUrl: 'myModalContent.html',
|
2014-12-01 05:24:19 -03:00
|
|
|
controller: ModalInstanceCtrl
|
2014-11-04 15:24:56 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Please note that $modalInstance represents a modal window (instance) dependency.
|
|
|
|
|
// It is not the same as the $modal service used above.
|
|
|
|
|
|
2014-12-01 05:24:19 -03:00
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
$scope.wallets = ret;
|
|
|
|
|
$scope.loading = false;
|
|
|
|
|
};
|
|
|
|
|
if ($rootScope.iden) {
|
|
|
|
|
var iden = $rootScope.iden;
|
|
|
|
|
iden.on('newWallet', function() {
|
|
|
|
|
$scope.setWallets();
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-11-04 15:24:56 -03:00
|
|
|
$scope.ok = function(selectedItem) {
|
2014-11-29 18:35:48 -03:00
|
|
|
identityService.setPaymentWallet(selectedItem);
|
2014-11-04 15:24:56 -03:00
|
|
|
$modalInstance.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.cancel = function() {
|
2014-11-05 16:37:25 -03:00
|
|
|
$rootScope.pendingPayment = null;
|
|
|
|
|
$modalInstance.close();
|
2014-11-30 19:14:22 -03:00
|
|
|
$location.path('/homeWallet');
|
2014-11-04 15:24:56 -03:00
|
|
|
};
|
2014-11-03 18:02:21 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|