mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #401 from yemel/feature/group-txinputs-by-address
Group inputs by address
This commit is contained in:
commit
570d1a69a9
|
@ -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>
|
||||
|
|
|
@ -2,7 +2,21 @@
|
|||
|
||||
angular.module('copay.filters', [])
|
||||
.filter('amTimeAgo', ['amMoment', function(amMoment) {
|
||||
return function(input) {
|
||||
return amMoment.preprocessDate(input).fromNow();
|
||||
};
|
||||
}]);
|
||||
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