Change default address list

This commit is contained in:
Yemel Jardi 2014-06-23 13:26:13 -03:00
parent 78493f9d91
commit 38ac18458b
2 changed files with 10 additions and 35 deletions

View File

@ -390,7 +390,7 @@
</span>
</a>
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|withoutFunds) > 1">
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="addresses.length != (addresses|limitAddress).length">
<span ng-if="!showAll">Show all</span>
<span ng-if="showAll">Show less</span>
</a>

View File

@ -17,41 +17,16 @@ angular.module('copayApp.filters', [])
})
.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;
}
if (elements.length <= 1 || showAll) {
return elements;
}
};
})
.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;
// Show last 3 non-change addresses plus those with balance
var addrs = elements.filter(function(e, i) {
return (!e.isChange && i < 3) || (e.balance && e.balance > 0);
});
return addrs;
};
})
;