Add locale in number pipes and stakeholder.
This commit is contained in:
parent
0f265f435b
commit
aa54090c5a
|
@ -23,6 +23,7 @@ export class Stakeholder {
|
||||||
index_name: string;
|
index_name: string;
|
||||||
index_shortName: string;
|
index_shortName: string;
|
||||||
statsProfile: string = "monitor";
|
statsProfile: string = "monitor";
|
||||||
|
locale: string = 'eu';
|
||||||
alias: string;
|
alias: string;
|
||||||
defaultId: string;
|
defaultId: string;
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
|
|
|
@ -12,6 +12,13 @@ export class NumberPercentagePipe implements PipeTransform {
|
||||||
/**
|
/**
|
||||||
* */
|
* */
|
||||||
transform(value: number | string, ...args: any[]): any {
|
transform(value: number | string, ...args: any[]): any {
|
||||||
|
let locale: string = 'en';
|
||||||
|
if (args[0]) {
|
||||||
|
locale = args[0];
|
||||||
|
this.decimalPipe = new DecimalPipe(locale);
|
||||||
|
} else {
|
||||||
|
this.decimalPipe = new DecimalPipe('en');
|
||||||
|
}
|
||||||
value = Number.parseFloat(value.toString()) * 100;
|
value = Number.parseFloat(value.toString()) * 100;
|
||||||
return this.decimalPipe.transform(value) + '<span class="number-size">%</span>';
|
return this.decimalPipe.transform(value) + '<span class="number-size">%</span>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
import {Pipe, PipeTransform} from "@angular/core";
|
import {Pipe, PipeTransform} from "@angular/core";
|
||||||
import {Level, NumberSize, NumberUtils} from "../number-utils.class";
|
import {Level, NumberSize, NumberUtils} from "../number-utils.class";
|
||||||
import {DecimalPipe} from "@angular/common";
|
import {DecimalPipe, registerLocaleData} from "@angular/common";
|
||||||
|
import l from '@angular/common/locales/eu';
|
||||||
|
import e from '@angular/common/locales/extra/eu';
|
||||||
|
|
||||||
@Pipe({name: 'numberRound'})
|
@Pipe({name: 'numberRound'})
|
||||||
export class NumberRoundPipe implements PipeTransform {
|
export class NumberRoundPipe implements PipeTransform {
|
||||||
decimalPipe: DecimalPipe = new DecimalPipe("en");
|
decimalPipe: DecimalPipe = new DecimalPipe("en");
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
registerLocaleData(l, 'eu', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,12 +19,19 @@ export class NumberRoundPipe implements PipeTransform {
|
||||||
transform(value: number | string, ...args: any[]): any {
|
transform(value: number | string, ...args: any[]): any {
|
||||||
let level = Level.ALL;
|
let level = Level.ALL;
|
||||||
let decimal = 0;
|
let decimal = 0;
|
||||||
|
let locale: string = 'en';
|
||||||
if (args[0]) {
|
if (args[0]) {
|
||||||
level = args[0];
|
level = args[0];
|
||||||
}
|
}
|
||||||
if (args[1]) {
|
if (args[1]) {
|
||||||
decimal = args[1];
|
decimal = args[1];
|
||||||
}
|
}
|
||||||
|
if (args[2]) {
|
||||||
|
locale = args[2];
|
||||||
|
this.decimalPipe = new DecimalPipe(locale);
|
||||||
|
} else {
|
||||||
|
this.decimalPipe = new DecimalPipe('en');
|
||||||
|
}
|
||||||
let size: NumberSize = NumberUtils.roundNumber(value, level, decimal);
|
let size: NumberSize = NumberUtils.roundNumber(value, level, decimal);
|
||||||
return this.decimalPipe.transform(size.number) + (size.size ? '<span class="number-size">' + size.size + '</span>' : '');
|
return this.decimalPipe.transform(size.number) + (size.size ? '<span class="number-size">' + size.size + '</span>' : '');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue