Wallet/js/controllers/paymentIntent.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
var bitcore = require('bitcore');
2014-11-06 11:17:05 -03:00
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, $location, controllerUtils) {
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
_.each(wids, function(wid) {
var w = $rootScope.iden.getWalletById(wid);
2014-11-04 10:17:42 -03:00
if (w && w.isReady()) {
2014-11-06 12:47:54 -03:00
2014-11-04 10:17:42 -03:00
$scope.wallets.push(w);
2014-11-05 16:37:25 -03:00
controllerUtils.clearBalanceCache(w);
2014-11-04 17:18:15 -03:00
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
2014-11-06 12:47:54 -03:00
}, true);
2014-11-05 16:37:25 -03:00
2014-11-04 10:17:42 -03:00
}
});
2014-11-04 15:24:56 -03:00
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function() {
return $scope.wallets;
}
}
});
};
// 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, items, controllerUtils) {
$scope.wallets = items;
$scope.ok = function(selectedItem) {
controllerUtils.setPaymentWallet(selectedItem);
$modalInstance.close();
};
$scope.cancel = function() {
2014-11-05 16:37:25 -03:00
$rootScope.pendingPayment = null;
2014-11-06 11:17:05 -03:00
$location.path('/');
2014-11-05 16:37:25 -03:00
$modalInstance.close();
2014-11-04 15:24:56 -03:00
};
};
});