Add number percentage pipe. Add format field in indicatorPath
This commit is contained in:
parent
e88bb206dc
commit
a49970aca6
|
@ -12,6 +12,7 @@ export type IndicatorType = 'number' | 'chart';
|
|||
export type IndicatorSize = 'small' | 'medium' | 'large';
|
||||
export type IndicatorPathType = 'table' | 'bar' | 'column' | 'pie' | 'line' | 'other';
|
||||
export type SourceType = 'statistics' | 'search' |'stats-tool' | 'old' | 'image';
|
||||
export type Format = 'NUMBER' | 'PERCENTAGE';
|
||||
export type Visibility = 'PUBLIC' | 'PRIVATE' | 'RESTRICTED';
|
||||
|
||||
export class Stakeholder {
|
||||
|
@ -193,8 +194,9 @@ export class IndicatorPath {
|
|||
parameters: any;
|
||||
filters: any;
|
||||
filtersApplied: number = 0;
|
||||
format: Format;
|
||||
|
||||
constructor(type: IndicatorPathType, source: SourceType, url: string, chartObject: string, jsonPath: string[]) {
|
||||
constructor(type: IndicatorPathType, source: SourceType, url: string, chartObject: string, jsonPath: string[], format: Format = 'NUMBER') {
|
||||
this.type = type;
|
||||
this.url = url;
|
||||
this.source = source;
|
||||
|
@ -203,6 +205,7 @@ export class IndicatorPath {
|
|||
this.parameters = {};
|
||||
this.filters = {};
|
||||
this.filtersApplied = 0;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
static createParameters(funderName: string = null, title: string = null, chartType: string = null): any {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import {Pipe, PipeTransform} from "@angular/core";
|
||||
import {Level, NumberSize, NumberUtils} from "../number-utils.class";
|
||||
import {DecimalPipe} from "@angular/common";
|
||||
|
||||
@Pipe({name: 'numberPercentage'})
|
||||
export class NumberPercentagePipe implements PipeTransform {
|
||||
decimalPipe: DecimalPipe = new DecimalPipe("en");
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* */
|
||||
transform(value: number | string, ...args: any[]): any {
|
||||
value = Number.parseFloat(value.toString()) * 100;
|
||||
return this.decimalPipe.transform(value) + '<span class="number-size">%</span>';
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
import {NgModule} from "@angular/core";
|
||||
import {NumberRoundPipe} from "./number-round.pipe";
|
||||
import {NumberPercentagePipe} from "./number-percentage.pipe";
|
||||
|
||||
@NgModule({
|
||||
declarations: [NumberRoundPipe],
|
||||
exports: [NumberRoundPipe]
|
||||
declarations: [NumberRoundPipe, NumberPercentagePipe],
|
||||
exports: [NumberRoundPipe, NumberPercentagePipe]
|
||||
|
||||
})
|
||||
export class NumberRoundModule {
|
||||
|
|
Loading…
Reference in New Issue