mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-4713] Add new DecimalNumber Pipe to transform and localize numbers (#4926)
* [ADF-4713] Add new DecimalNumber Pipe to transform and localize numbers * Unsubscribe from userPreference service * Make Pipe impure * Add documentation in localization page
This commit is contained in:
committed by
Eugenio Romano
parent
8ee5cd1908
commit
a0d4160c11
@@ -8,7 +8,7 @@
|
||||
pattern="-?[0-9]*(\.[0-9]+)?"
|
||||
[id]="field.id"
|
||||
[required]="isRequired()"
|
||||
[value]="field.value"
|
||||
[value]="displayValue"
|
||||
[(ngModel)]="field.value"
|
||||
(ngModelChange)="onFieldChanged(field)"
|
||||
[disabled]="field.readOnly"
|
||||
|
@@ -22,7 +22,7 @@ describe('NumberWidgetComponent', () => {
|
||||
let widget: NumberWidgetComponent;
|
||||
|
||||
beforeEach(() => {
|
||||
widget = new NumberWidgetComponent(null);
|
||||
widget = new NumberWidgetComponent(null, null);
|
||||
});
|
||||
|
||||
it('should exist', () => {
|
||||
|
@@ -17,9 +17,10 @@
|
||||
|
||||
/* tslint:disable:component-selector no-input-rename */
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
|
||||
import { FormService } from './../../../services/form.service';
|
||||
import { baseHost , WidgetComponent } from './../widget.component';
|
||||
import { DecimalNumberPipe } from '../../../../pipes/decimal-number.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'number-widget',
|
||||
@@ -28,10 +29,21 @@ import { baseHost , WidgetComponent } from './../widget.component';
|
||||
host: baseHost,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class NumberWidgetComponent extends WidgetComponent {
|
||||
export class NumberWidgetComponent extends WidgetComponent implements OnInit {
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
displayValue: number;
|
||||
|
||||
constructor(public formService: FormService,
|
||||
private decimalNumberPipe: DecimalNumberPipe) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field.readOnly) {
|
||||
this.displayValue = this.decimalNumberPipe.transform(this.field.value);
|
||||
} else {
|
||||
this.displayValue = this.field.value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user