only show matching network wallet in payment intents

This commit is contained in:
Matias Alejo Garcia 2015-04-23 16:17:18 -03:00
commit cd901f5b3e
4 changed files with 88 additions and 66 deletions

View file

@ -9,15 +9,18 @@
<div class="ellipsis"><b translate>Address</b>: {{uri.address.toString()}}</div>
<div ng-show="uri.amount"><b translate>Amount</b>: {{uri.amount}}</div>
<div ng-show="uri.message"><b translate>Message</b>: {{uri.message}}</div>
<div ng-show="uri.network == 'testnet'"><b translate>Network</b>: {{uri.network}}</div>
</div>
<h2 translate>Select a wallet</h2>
<ul class="no-bullet" ng-init="wallets = payment.getWallets()">
<ul class="no-bullet" ng-init="wallets = payment.getWallets(uri.network)">
<li class="panel" ng-repeat="w in wallets">
<a ng-click="payment.selectWallet(w.id)">
<div class="avatar-wallet"
ng-style="{'background-color':w.color}">{{(w.name || w.id) | limitTo: 1}}</div>
<div class="ellipsis">{{w.name || w.id}}</div>
<div class="size-12">{{w.m}} of {{w.n}}</div>
<div class="size-12">{{w.m}} of {{w.n}}
<span ng-show="w.network=='testnet'">[Testnet]</span>
</div>
</a>
</li>
</ul>

View file

@ -104,12 +104,21 @@ angular.module('copayApp.controllers').controller('indexController', function($r
};
self.setTab = function(tab) {
if (self.tab && document.getElementById(self.tab)) {
if (self.tab === tab)
return;
if (!self.tab)
self.tab = 'walletHome';
if (document.getElementById(self.tab)) {
document.getElementById(self.tab).className = 'tab-out tab-view ' + self.tab;
var old = document.getElementById('menu-' + self.tab);
if (old) {
old.className = '';
old.style.borderTopColor = '';
}
}
if (document.getElementById(tab)) {
document.getElementById(tab).className = 'tab-in tab-view ' + tab;

View file

@ -13,7 +13,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
query.push(key + "=" + value);
});
var queryString = query ? query.join("&") : null;
this.bitcoinURI = $stateParams.data + ( queryString ? '?' + queryString : '');
this.bitcoinURI = $stateParams.data + (queryString ? '?' + queryString : '');
var URI = bitcore.URI;
var isUriValid = URI.isValid(this.bitcoinURI);
@ -30,11 +30,12 @@ angular.module('copayApp.controllers').controller('paymentUriController',
var unitName = config.unitName;
uri.amount = strip(uri.amount * satToUnit) + ' ' + unitName;
uri.network = uri.address.network.name;
return uri;
}
};
this.getWallets = function() {
this.getWallets = function(network) {
if (!profileService.profile) return;
var config = configService.getSync();
config.colorFor = config.colorFor || {};
@ -44,9 +45,13 @@ angular.module('copayApp.controllers').controller('paymentUriController',
n: c.n,
name: c.walletName,
id: c.walletId,
network: c.network,
color: config.colorFor[c.walletId] || '#2C3E50'
};
});
ret = lodash.filter(ret, function(w) {
return (w.network == network);
});
return lodash.sortBy(ret, 'walletName');
};

View file

@ -36,8 +36,11 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
var ref = window.open(url, '_blank', 'location=no');
};
root.path = function(path) {
$state.transitionTo(path);
root.path = function(path, cb) {
$state.transitionTo(path)
.then(function() {
if (cb) return cb();
});
hideSidebars();
};
@ -51,15 +54,17 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
if (fc && !fc.isComplete()) {
root.path('copayers');
} else {
root.path('walletHome');
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'walletHome');
});
}
};
root.send = function() {
root.path('walletHome');
$rootScope.$emit('Local/SetTab', 'walletHome');
root.path('walletHome', function() {
$rootScope.$emit('Local/SetTab', 'send');
});
};
root.home = function() {