Browse Source

Refactor isInteger

pull/351/head
Thomas 4 years ago
parent
commit
510551c115
  1. 2
      apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html
  2. 7
      libs/ui/src/lib/value/value.component.stories.ts
  3. 16
      libs/ui/src/lib/value/value.component.ts

2
apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html

@ -104,8 +104,6 @@
<div class="col-6 mb-3">
<gf-value
size="medium"
[isCurrency]="false"
[isInteger]="true"
[label]="transactionCount === 1 ? 'Transaction' : 'Transactions'"
[locale]="data.locale"
[value]="transactionCount"

7
libs/ui/src/lib/value/value.component.stories.ts

@ -29,13 +29,6 @@ Currency.args = {
value: 7
};
export const Integer = Template.bind({});
Integer.args = {
isInteger: true,
locale: 'en-US',
value: 7
};
export const Label = Template.bind({});
Label.args = {
label: 'Label',

16
libs/ui/src/lib/value/value.component.ts

@ -18,12 +18,11 @@ export class ValueComponent implements OnChanges {
@Input() colorizeSign = false;
@Input() currency = '';
@Input() isCurrency = false;
@Input() isInteger = false;
@Input() isPercent = false;
@Input() label = '';
@Input() locale = '';
@Input() position = '';
@Input() precision = 0;
@Input() precision: number | undefined;
@Input() size = '';
@Input() value: number | string = '';
@ -83,20 +82,15 @@ export class ValueComponent implements OnChanges {
minimumFractionDigits: 2
});
} catch {}
} else if (this.isInteger) {
} else if (this.precision || this.precision === 0) {
try {
this.formattedValue = this.value?.toLocaleString(this.locale, {
maximumFractionDigits: 0,
minimumFractionDigits: 0
maximumFractionDigits: this.precision,
minimumFractionDigits: this.precision
});
} catch {}
} else if (this.precision) {
this.formattedValue = this.value?.toLocaleString(this.locale, {
maximumFractionDigits: this.precision,
minimumFractionDigits: this.precision
});
} else {
this.formattedValue = this.value.toString();
this.formattedValue = this.value?.toString();
}
} else {
try {

Loading…
Cancel
Save