[ADF-4764] Hide placeholder in Amount Widget in readOnly mode (#5035)

* [ADF-4764] Hide placeholder in Amount Widget in readOnly mode

* add missing return type
This commit is contained in:
davidcanonieto 2019-08-31 00:30:13 +01:00 committed by Eugenio Romano
parent be867b0c0c
commit 1cb4dfc1b8
3 changed files with 25 additions and 1 deletions

View File

@ -7,7 +7,7 @@
type="text"
[id]="field.id"
[required]="isRequired()"
[placeholder]="field.placeholder"
[placeholder]="placeholder"
[value]="field.value"
[(ngModel)]="field.value"
(ngModelChange)="onFieldChanged(field)"

View File

@ -56,4 +56,24 @@ describe('AmountWidgetComponent', () => {
expect(widget.currency).toBe(AmountWidgetComponent.DEFAULT_CURRENCY);
});
it('should setup empty placeholder in readOnly mode', () => {
widget.field = new FormFieldModel(null, {
readOnly: true,
placeholder: '1234'
});
widget.ngOnInit();
expect(widget.placeholder).toBe('');
});
it('should setup placeholder when readOnly is false', () => {
widget.field = new FormFieldModel(null, {
readOnly: false,
placeholder: '1234'
});
widget.ngOnInit();
expect(widget.placeholder).toBe('1234');
});
});

View File

@ -34,6 +34,10 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit {
currency: string = AmountWidgetComponent.DEFAULT_CURRENCY;
get placeholder(): string {
return !this.field.readOnly ? this.field.placeholder : '';
}
constructor(public formService: FormService) {
super(formService);
}