AAE-39923 Placeholder transformed with currency based on locale (#11342)

* [AAE-39923] placeholder transformed with currency based on locale

* [AAE-39923] applied pr comments
This commit is contained in:
Tomek Hanaj
2025-11-18 12:05:16 +01:00
committed by GitHub
parent 9af4b7a4b6
commit 2ebe4ccfb0
2 changed files with 16 additions and 1 deletions

View File

@@ -105,6 +105,18 @@ describe('AmountWidgetComponent', () => {
expect(widget.placeholder).toBe('1234');
});
it('should setup placeholder when enableDisplayBasedOnLocale is true', () => {
widget.enableDisplayBasedOnLocale = true;
widget.field = new FormFieldModel(null, {
readOnly: false,
placeholder: '1234',
currency: 'USD'
});
widget.ngOnInit();
expect(widget.placeholder).toBe('$1,234');
});
it('it should return locale based on browser', () => {
const expectedLanguage = 'en-US';
widget.enableDisplayBasedOnLocale = true;

View File

@@ -75,7 +75,10 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit {
valueAsNumber: number;
get placeholder(): string {
return this.showPlaceholder ? this.field.placeholder : '';
if (!this.showPlaceholder) return '';
return this.enableDisplayBasedOnLocale
? this.currencyPipe.transform(this.field.placeholder, this.currency, this.currencyDisplay, this.decimalProperty, this.locale)
: this.field.placeholder;
}
constructor(