Use of Decimals to Display user setting to format numbers (#1695)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-03-06 07:56:43 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 814bb87c16
commit 99c2d4780d
48 changed files with 242 additions and 166 deletions
+24
View File
@@ -0,0 +1,24 @@
import { DecimalPipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
import { SettingsService } from 'app/settings/settings.service';
@Pipe({
name: 'formatNumber'
})
export class FormatNumberPipe implements PipeTransform {
constructor(private decimalFormat: DecimalPipe,
private settingsService: SettingsService) {
}
transform(value: string | number, ...args: unknown[]): string {
if (!value) {
return '';
}
const locale = this.settingsService.language.code;
const decimals = this.settingsService.decimals;
const format = `1.${decimals}-${decimals}`;
return this.decimalFormat.transform(value, format, locale);
}
}