mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[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:
parent
be867b0c0c
commit
1cb4dfc1b8
@ -7,7 +7,7 @@
|
|||||||
type="text"
|
type="text"
|
||||||
[id]="field.id"
|
[id]="field.id"
|
||||||
[required]="isRequired()"
|
[required]="isRequired()"
|
||||||
[placeholder]="field.placeholder"
|
[placeholder]="placeholder"
|
||||||
[value]="field.value"
|
[value]="field.value"
|
||||||
[(ngModel)]="field.value"
|
[(ngModel)]="field.value"
|
||||||
(ngModelChange)="onFieldChanged(field)"
|
(ngModelChange)="onFieldChanged(field)"
|
||||||
|
@ -56,4 +56,24 @@ describe('AmountWidgetComponent', () => {
|
|||||||
expect(widget.currency).toBe(AmountWidgetComponent.DEFAULT_CURRENCY);
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -34,6 +34,10 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit {
|
|||||||
|
|
||||||
currency: string = AmountWidgetComponent.DEFAULT_CURRENCY;
|
currency: string = AmountWidgetComponent.DEFAULT_CURRENCY;
|
||||||
|
|
||||||
|
get placeholder(): string {
|
||||||
|
return !this.field.readOnly ? this.field.placeholder : '';
|
||||||
|
}
|
||||||
|
|
||||||
constructor(public formService: FormService) {
|
constructor(public formService: FormService) {
|
||||||
super(formService);
|
super(formService);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user