Feature/migrate currency to unit in value component (#2043)
* Migrate currency to unit * Update locales
This commit is contained in:
@@ -32,15 +32,9 @@
|
||||
{{ formattedValue }}
|
||||
</ng-container>
|
||||
</div>
|
||||
<small *ngIf="currency && size === 'medium'" class="ml-1">
|
||||
{{ currency }}
|
||||
</small>
|
||||
<small *ngIf="unit && size === 'medium'" class="ml-1">
|
||||
{{ unit }}
|
||||
</small>
|
||||
<div *ngIf="currency && size !== 'medium'" class="ml-1">
|
||||
{{ currency }}
|
||||
</div>
|
||||
<div *ngIf="unit && size !== 'medium'" class="ml-1">
|
||||
{{ unit }}
|
||||
</div>
|
||||
|
@@ -24,8 +24,9 @@ Loading.args = {
|
||||
|
||||
export const Currency = Template.bind({});
|
||||
Currency.args = {
|
||||
currency: 'USD',
|
||||
isCurrency: true,
|
||||
locale: 'en-US',
|
||||
unit: 'USD',
|
||||
value: 7
|
||||
};
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import { isNumber } from 'lodash';
|
||||
})
|
||||
export class ValueComponent implements OnChanges {
|
||||
@Input() colorizeSign = false;
|
||||
@Input() currency = '';
|
||||
@Input() icon = '';
|
||||
@Input() isAbsolute = false;
|
||||
@Input() isCurrency = false;
|
||||
@@ -47,7 +46,7 @@ export class ValueComponent implements OnChanges {
|
||||
this.absoluteValue = Math.abs(<number>this.value);
|
||||
|
||||
if (this.colorizeSign) {
|
||||
if (this.currency || this.isCurrency) {
|
||||
if (this.isCurrency) {
|
||||
try {
|
||||
this.formattedValue = this.absoluteValue.toLocaleString(
|
||||
this.locale,
|
||||
@@ -68,6 +67,13 @@ export class ValueComponent implements OnChanges {
|
||||
);
|
||||
} catch {}
|
||||
}
|
||||
} else if (this.isCurrency) {
|
||||
try {
|
||||
this.formattedValue = this.value?.toLocaleString(this.locale, {
|
||||
maximumFractionDigits: 2,
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
} catch {}
|
||||
} else if (this.isPercent) {
|
||||
try {
|
||||
this.formattedValue = (this.value * 100).toLocaleString(
|
||||
@@ -78,13 +84,6 @@ export class ValueComponent implements OnChanges {
|
||||
}
|
||||
);
|
||||
} catch {}
|
||||
} else if (this.currency || this.isCurrency) {
|
||||
try {
|
||||
this.formattedValue = this.value?.toLocaleString(this.locale, {
|
||||
maximumFractionDigits: 2,
|
||||
minimumFractionDigits: 2
|
||||
});
|
||||
} catch {}
|
||||
} else if (this.precision || this.precision === 0) {
|
||||
try {
|
||||
this.formattedValue = this.value?.toLocaleString(this.locale, {
|
||||
|
Reference in New Issue
Block a user