mirror of https://github.com/BTCPrivate/copay.git
New Angular filter for correct the formatting issue of the currency value
This commit is contained in:
parent
a1fe7b3d7d
commit
5f99554478
40
index.html
40
index.html
|
@ -36,7 +36,12 @@
|
||||||
<span ng-if="$root.updatingBalance">
|
<span ng-if="$root.updatingBalance">
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="!$root.updatingBalance" data-options="disable_for_touch:true" tooltip="{{totalBalanceBTC}} BTC" tooltip-trigger="mouseenter" tooltip-placement="bottom">{{totalBalance || 0 |number}} {{$root.unitName}}
|
<span ng-if="!$root.updatingBalance"
|
||||||
|
data-options="disable_for_touch:true"
|
||||||
|
tooltip="{{totalBalanceBTC}} BTC"
|
||||||
|
tooltip-trigger="mouseenter"
|
||||||
|
tooltip-placement="bottom">{{totalBalance || 0
|
||||||
|
|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-4 medium-4 columns">
|
<div class="large-4 medium-4 columns">
|
||||||
|
@ -44,7 +49,11 @@
|
||||||
<span ng-if="$root.updatingBalance">
|
<span ng-if="$root.updatingBalance">
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="!$root.updatingBalance" data-options="disable_for_touch:true" tooltip="{{availableBalanceBTC}} BTC" tooltip-trigger="mouseenter" tooltip-placement="bottom">{{availableBalance || 0|number}} {{$root.unitName}}
|
<span ng-show="!$root.updatingBalance"
|
||||||
|
data-options="disable_for_touch:true"
|
||||||
|
tooltip="{{availableBalanceBTC}} BTC"
|
||||||
|
tooltip-trigger="mouseenter"
|
||||||
|
tooltip-placement="bottom">{{availableBalance || 0|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -404,11 +413,11 @@
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="!$root.updatingBalance">
|
<span ng-if="!$root.updatingBalance">
|
||||||
{{$root.balanceByAddr[addr.address] || 0|number}} {{$root.unitName}}
|
{{$root.balanceByAddr[addr.address] || 0|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="addrWithFund != addr.address">
|
<span ng-if="addrWithFund != addr.address">
|
||||||
{{addr.balance || 0|number}} {{$root.unitName}}
|
{{addr.balance || 0|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
@ -426,12 +435,12 @@
|
||||||
<span ng-if="$root.updatingBalance">
|
<span ng-if="$root.updatingBalance">
|
||||||
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="!$root.updatingBalance">{{balanceByAddr[selectedAddr.address] || 0 | number}}
|
<span ng-if="!$root.updatingBalance">{{balanceByAddr[selectedAddr.address] || 0 | noFractionNumber:4}}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="addrWithFund != selectedAddr.address" style="word-wrap: break-word;">
|
<span ng-if="addrWithFund != selectedAddr.address" style="word-wrap: break-word;">
|
||||||
{{selectedAddr.address}}<br/>
|
{{selectedAddr.address}}<br/>
|
||||||
{{selectedAddr.balance || 0|number}} {{$root.unitName}}
|
{{selectedAddr.balance || 0|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</span>
|
</span>
|
||||||
</strong>
|
</strong>
|
||||||
</p>
|
</p>
|
||||||
|
@ -462,7 +471,8 @@
|
||||||
<div class="txheader row m10">
|
<div class="txheader row m10">
|
||||||
<div class="large-8 medium-8 small-12 columns">
|
<div class="large-8 medium-8 small-12 columns">
|
||||||
<div class="row" ng-repeat="out in tx.outs">
|
<div class="row" ng-repeat="out in tx.outs">
|
||||||
<div class="large-3 medium-3 small-3 columns ellipsis"> {{out.value | number}} {{$root.unitName}}</div>
|
<div class="large-3 medium-3 small-3 columns ellipsis">
|
||||||
|
{{out.value | noFractionNumber:4}} {{$root.unitName}}</div>
|
||||||
<div class="large-1 medium-1 small-2 columns fi-arrow-right size-24"> </div>
|
<div class="large-1 medium-1 small-2 columns fi-arrow-right size-24"> </div>
|
||||||
<div class="large-8 medium-8 small-7 columns ellipsis">
|
<div class="large-8 medium-8 small-7 columns ellipsis">
|
||||||
<contact address="{{out.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
<contact address="{{out.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
||||||
|
@ -546,7 +556,7 @@
|
||||||
<p class="text-gray m5b" ng-show="!tx.finallyRejected && tx.missingSignatures>1">
|
<p class="text-gray m5b" ng-show="!tx.finallyRejected && tx.missingSignatures>1">
|
||||||
{{tx.missingSignatures}} signatures missing</p>
|
{{tx.missingSignatures}} signatures missing</p>
|
||||||
<div class="ellipsis small text-gray">
|
<div class="ellipsis small text-gray">
|
||||||
<strong>Fee:</strong> {{tx.fee|number}} {{$root.unitName}}
|
<strong>Fee:</strong> {{tx.fee|noFractionNumber:4}} {{$root.unitName}}
|
||||||
<strong>Proposal ID:</strong> {{tx.ntxid}}
|
<strong>Proposal ID:</strong> {{tx.ntxid}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -593,7 +603,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-5 medium-5 small-5 columns">
|
<div class="large-5 medium-5 small-5 columns">
|
||||||
<div ng-repeat="vin in btx.vinSimple">
|
<div ng-repeat="vin in btx.vinSimple">
|
||||||
<small class="right m5t">{{vin.value| number}} {{$root.unitName}}</small>
|
<small class="right m5t">{{vin.value| noFractionNumber:4}} {{$root.unitName}}</small>
|
||||||
<p class="ellipsis text-gray size-12">
|
<p class="ellipsis text-gray size-12">
|
||||||
<contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
<contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
||||||
</p>
|
</p>
|
||||||
|
@ -604,7 +614,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
<div class="large-6 medium-6 small-6 columns">
|
||||||
<div ng-repeat="vout in btx.voutSimple">
|
<div ng-repeat="vout in btx.voutSimple">
|
||||||
<small class="right m5t">{{vout.value| number}} {{$root.unitName}}</small>
|
<small class="right m5t">{{vout.value| noFractionNumber:4}} {{$root.unitName}}</small>
|
||||||
<p class="ellipsis text-gray size-12">
|
<p class="ellipsis text-gray size-12">
|
||||||
<contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
<contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
|
||||||
</p>
|
</p>
|
||||||
|
@ -614,9 +624,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="m10 size-12 text-gray">
|
<div class="m10 size-12 text-gray">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-4 medium-4 small-4 columns">Fees: {{btx.fees | number}} {{$root.unitName}}</div>
|
<div class="large-4 medium-4 small-4 columns">Fees: {{btx.fees | noFractionNumber:4}} {{$root.unitName}}</div>
|
||||||
<div class="large-4 medium-4 small-4 columns text-center">Confirmations: {{btx.confirmations || 0}}</div>
|
<div class="large-4 medium-4 small-4 columns text-center">Confirmations: {{btx.confirmations || 0}}</div>
|
||||||
<div class="large-4 medium-4 small-4 columns text-right">Total: {{btx.valueOut| number}} {{$root.unitName}}</div>
|
<div class="large-4 medium-4 small-4 columns text-right">Total: {{btx.valueOut| noFractionNumber:4}} {{$root.unitName}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -702,13 +712,13 @@
|
||||||
Total amount for this transaction:
|
Total amount for this transaction:
|
||||||
</small>
|
</small>
|
||||||
<div class="totalAmount">
|
<div class="totalAmount">
|
||||||
<b>{{amount + defaultFee |number}}</b> {{$root.unitName}}
|
<b>{{amount + defaultFee |noFractionNumber:4}}</b> {{$root.unitName}}
|
||||||
<small>
|
<small>
|
||||||
{{ ((amount + defaultFee) * unitToBtc) |number}} BTC
|
{{ ((amount + defaultFee) * unitToBtc) |noFractionNumber:4}} BTC
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
<small>
|
<small>
|
||||||
Including fee of {{defaultFee|number}} {{$root.unitName}}
|
Including fee of {{defaultFee|noFractionNumber:4}} {{$root.unitName}}
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -30,4 +30,28 @@ angular.module('copayApp.filters', [])
|
||||||
|
|
||||||
return addrs;
|
return addrs;
|
||||||
};
|
};
|
||||||
});
|
})
|
||||||
|
.filter('noFractionNumber',
|
||||||
|
[ '$filter', '$locale',
|
||||||
|
function(filter, locale) {
|
||||||
|
var numberFilter = filter('number');
|
||||||
|
var formats = locale.NUMBER_FORMATS;
|
||||||
|
return function(amount, fraction) {
|
||||||
|
var value = numberFilter(amount, fraction);
|
||||||
|
var sep = value.indexOf(formats.DECIMAL_SEP);
|
||||||
|
var group = value.indexOf(formats.GROUP_SEP);
|
||||||
|
if(amount >= 0) {
|
||||||
|
if (group > 0) {
|
||||||
|
return value.substring(0, sep);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
value = parseFloat(value);
|
||||||
|
if(value % 1 === 0) {
|
||||||
|
value = value.toFixed(0);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
} ]);
|
||||||
|
|
Loading…
Reference in New Issue