Merge pull request #1717 from matiaspando/feature/selectWalletOnBIP21

Shows the wallet on a pop up
This commit is contained in:
Juan Ignacio Sosa Lopez 2014-11-04 16:42:51 -03:00
commit 7209745446
4 changed files with 68 additions and 18 deletions

View file

@ -11,6 +11,8 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
}
if ($rootScope.fromEmailConfirmation) {
$scope.confirmedEmail = true;
$rootScope.fromEmailConfirmation = false;
@ -29,6 +31,18 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
identityService.open($scope, form);
}
//TODO erase this function
$scope.setPayment = function() {
$rootScope.pendingPayment = {
"data": {
"amount": 20.3,
"label": "Luke-Jr",
"message": "Hola chango?"
},
"address": "175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"
};
}
function getParam(sname) {
var params = location.search.substr(location.search.indexOf("?") + 1);
var sval = "";

View file

@ -2,10 +2,8 @@
var bitcore = require('bitcore');
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $routeParams, $timeout, $location, controllerUtils) {
angular.module('copayApp.controllers').controller('PaymentIntentController', function($rootScope, $scope, $modal, controllerUtils) {
$rootScope.title = 'Select the wallet that you will use to spend your bitcoins';
$scope.wallets = [];
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
@ -13,15 +11,41 @@ angular.module('copayApp.controllers').controller('PaymentIntentController', fun
var w = $rootScope.iden.getWalletById(wid);
if (w && w.isReady()) {
$scope.wallets.push(w);
controllerUtils.updateBalance(w, function() {
$rootScope.$digest();
});
}
});
$scope.switchWallet = function(wid) {
//go to send page
controllerUtils.setPaymentWallet(wid);
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: ModalInstanceCtrl,
resolve: {
items: function() {
return $scope.wallets;
}
}
});
modalInstance.result.then(function(selectedItem) {}, function() {
$rootScope.pendingPayment = null;
});
};
// 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() {
$modalInstance.dismiss('cancel');
};
};
});