mirror of https://github.com/BTCPrivate/copay.git
Group inputs by address
This commit is contained in:
parent
3dc410b52a
commit
cedffc230b
|
@ -468,7 +468,7 @@
|
|||
</div>
|
||||
<div class="tx-copayers">
|
||||
<div class="large-5 columns">
|
||||
<div ng-repeat="vin in btx.vin">
|
||||
<div ng-repeat="vin in btx.vin | groupByAddress">
|
||||
<p class="left text-gray size-12"> {{vin.addr}} </p>
|
||||
<small class="right">{{vin.value}}</small>
|
||||
</div>
|
||||
|
|
|
@ -5,4 +5,18 @@ angular.module('copay.filters', [])
|
|||
return function(input) {
|
||||
return amMoment.preprocessDate(input).fromNow();
|
||||
};
|
||||
}]);
|
||||
}])
|
||||
.filter('groupByAddress', function() {
|
||||
return function(inputs) {
|
||||
function reduce(dic, input) {
|
||||
if(!dic[input.addr]) dic[input.addr] = 0;
|
||||
dic[input.addr] += input.value;
|
||||
return dic;
|
||||
}
|
||||
|
||||
var dic = inputs.reduce(reduce, {});
|
||||
return Object.keys(dic).map(function(key) {
|
||||
return { addr: key, value: dic[key] };
|
||||
});
|
||||
};
|
||||
});
|
Loading…
Reference in New Issue