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>
|
||||||
<div class="tx-copayers">
|
<div class="tx-copayers">
|
||||||
<div class="large-5 columns">
|
<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>
|
<p class="left text-gray size-12"> {{vin.addr}} </p>
|
||||||
<small class="right">{{vin.value}}</small>
|
<small class="right">{{vin.value}}</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,21 @@
|
||||||
|
|
||||||
angular.module('copay.filters', [])
|
angular.module('copay.filters', [])
|
||||||
.filter('amTimeAgo', ['amMoment', function(amMoment) {
|
.filter('amTimeAgo', ['amMoment', function(amMoment) {
|
||||||
return function(input) {
|
return function(input) {
|
||||||
return amMoment.preprocessDate(input).fromNow();
|
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