From b145a923c479835eaa5f04e017efffd4157935e5 Mon Sep 17 00:00:00 2001 From: Jack Anderson Date: Wed, 7 Aug 2024 16:03:02 +0100 Subject: [PATCH] Fix #478 - currency losing format after conversion --- .../currency-conversion/update-currency.action.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/app/core/src/lib/fields/field-logic/currency-conversion/update-currency.action.ts b/core/app/core/src/lib/fields/field-logic/currency-conversion/update-currency.action.ts index f3181cdfb..9a2f9ac6c 100644 --- a/core/app/core/src/lib/fields/field-logic/currency-conversion/update-currency.action.ts +++ b/core/app/core/src/lib/fields/field-logic/currency-conversion/update-currency.action.ts @@ -31,6 +31,7 @@ import {Record} from '../../../common/record/record.model'; import {ViewMode} from '../../../common/views/view.model'; import {FieldLogicActionData, FieldLogicActionHandler} from '../field-logic.action'; import {CurrencyService} from '../../../services/currency/currency.service'; +import {CurrencyFormatter} from "../../../services/formatters/currency/currency-formatter.service"; @Injectable({ providedIn: 'root' @@ -40,7 +41,7 @@ export class UpdateCurrencyAction extends FieldLogicActionHandler { key = 'update-currency'; modes = ['edit', 'create', 'massupdate', 'filter'] as ViewMode[]; - constructor(protected currencyService: CurrencyService) { + constructor(protected currencyService: CurrencyService, protected currencyFormatter: CurrencyFormatter) { super(); } @@ -74,8 +75,12 @@ export class UpdateCurrencyAction extends FieldLogicActionHandler { } protected updateValue(field: Field, value: number, record: Record): void { - field.value = value.toString(); - field.formControl.setValue(value.toString()); + const options = { + mode: 'edit' as ViewMode + } + const formattedValue = this.currencyFormatter.toUserFormat(value.toString(), options) + field.value = formattedValue; + field.formControl.setValue(formattedValue); // re-validate the parent form-control after value update record.formGroup.updateValueAndValidity({onlySelf: true, emitEvent: true}); }