mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #456 from cmgustavo/feature/01-limit-addresses
Fixes #399 : Limit addresses list
This commit is contained in:
commit
b408d270f7
16
index.html
16
index.html
|
@ -324,12 +324,14 @@
|
||||||
<div ng-show='$root.wallet.publicKeyRing.isComplete()'>
|
<div ng-show='$root.wallet.publicKeyRing.isComplete()'>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-9 medium-12 columns" ng-if="addresses[0]">
|
<div class="large-9 medium-12 columns" ng-if="addresses[0]">
|
||||||
<div class="large-8 medium-8 columns">
|
<div class="large-8 medium-8 columns" ng-init="showAll=0">
|
||||||
<a class="panel radius db" ng-repeat="addr in addresses"
|
<a class="panel radius db" ng-repeat="addr in addresses | limitAddress:showAll"
|
||||||
ng-click="selectAddress(addr)"
|
ng-click="selectAddress(addr)"
|
||||||
ng-class="{selected : addr.address == selectedAddr.address}">
|
ng-class="{selected : addr.address == selectedAddr.address}">
|
||||||
<span>{{addr.address}}</span>
|
|
||||||
<span ng-if="addr.isChange">(change)</span>
|
<span>{{addr.address}}</span>
|
||||||
|
<small ng-if="addr.isChange">change</small>
|
||||||
|
|
||||||
<span class="right">
|
<span class="right">
|
||||||
<span ng-if="addrWithFund == addr.address">
|
<span ng-if="addrWithFund == addr.address">
|
||||||
<span ng-if="$root.updatingBalance">
|
<span ng-if="$root.updatingBalance">
|
||||||
|
@ -345,7 +347,13 @@
|
||||||
<i class="fi-bitcoin"></i>
|
<i class="fi-bitcoin"></i>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<button class="button small secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|withoutFunds) > 1">
|
||||||
|
<span ng-if="!showAll">Show all</span>
|
||||||
|
<span ng-if="showAll">Show less</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-4 medium-4 columns line-dashed-v text-center" ng-show="selectedAddr">
|
<div class="large-4 medium-4 columns line-dashed-v text-center" ng-show="selectedAddr">
|
||||||
<qrcode size="160" data="{{selectedAddr.address}}"></qrcode>
|
<qrcode size="160" data="{{selectedAddr.address}}"></qrcode>
|
||||||
|
|
|
@ -24,4 +24,44 @@ angular.module('copay.filters', [])
|
||||||
return function(elements) {
|
return function(elements) {
|
||||||
return elements.filter(Boolean);
|
return elements.filter(Boolean);
|
||||||
};
|
};
|
||||||
});
|
})
|
||||||
|
.filter('limitAddress', function() {
|
||||||
|
return function(elements, showAll) {
|
||||||
|
var addrs = [];
|
||||||
|
if (elements.length > 0) {
|
||||||
|
if (showAll) {
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
if (elements.length == 1) {
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (var i=0;i<elements.length;i++) {
|
||||||
|
if (!elements[i].isChange && (!elements[i].balance || elements[i].balance == 0)) {
|
||||||
|
addrs.push(elements[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i=0;i<elements.length;i++) {
|
||||||
|
if (elements[i].balance && elements[i].balance > 0) {
|
||||||
|
addrs.push(elements[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addrs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter('withoutFunds', function() {
|
||||||
|
return function(elements) {
|
||||||
|
var len = 0;
|
||||||
|
for (var i=0;i<elements.length;i++) {
|
||||||
|
if (!elements[i].balance || elements[i].balance == 0) {
|
||||||
|
len++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
;
|
||||||
|
|
Loading…
Reference in New Issue