From 02cda225807a36d5623b1a12cb14b5effd9ace16 Mon Sep 17 00:00:00 2001 From: Vitalii Kiiko Date: Wed, 30 Apr 2025 11:17:14 +0200 Subject: [PATCH] - updated tables, fixed bug of not updating auto calculated total; --- .../RenderTable/components/NumericFormulaCell/index.js | 9 +++++++-- .../RenderTable/components/NumericFormulaCell/index.js | 10 ++++++++-- src/components/FormField/components/Table/index.js | 7 +------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/FormField/components/CriteriaTable/RenderTable/components/NumericFormulaCell/index.js b/src/components/FormField/components/CriteriaTable/RenderTable/components/NumericFormulaCell/index.js index 7ededbe..f7656e9 100644 --- a/src/components/FormField/components/CriteriaTable/RenderTable/components/NumericFormulaCell/index.js +++ b/src/components/FormField/components/CriteriaTable/RenderTable/components/NumericFormulaCell/index.js @@ -8,7 +8,11 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table }) e.target.select(); } - const onChange = (value) => { + /*const onChange = (value) => { + table.options.meta?.updateData(index, id, value); + };*/ + + const onBlur = (value) => { table.options.meta?.updateData(index, id, value); }; @@ -16,8 +20,9 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table }) onChange(e.value)} + /*onValueChange={(e) => onChange(e.value)}*/ onFocus={onFocus} + onBlur={(e) => onBlur(e.target.value)} minFractionDigits={0} maxFractionDigits={2} locale='it-IT' diff --git a/src/components/FormField/components/Table/RenderTable/components/NumericFormulaCell/index.js b/src/components/FormField/components/Table/RenderTable/components/NumericFormulaCell/index.js index 7ededbe..4256294 100644 --- a/src/components/FormField/components/Table/RenderTable/components/NumericFormulaCell/index.js +++ b/src/components/FormField/components/Table/RenderTable/components/NumericFormulaCell/index.js @@ -8,7 +8,12 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table }) e.target.select(); } - const onChange = (value) => { + /*const onChange = (value) => { + console.log('table.options.meta', table.options.meta) + table.options.meta?.updateData(index, id, value); + };*/ + + const onBlur = (value) => { table.options.meta?.updateData(index, id, value); }; @@ -16,8 +21,9 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table }) onChange(e.value)} + /*onValueChange={(e) => onChange(e.value)}*/ onFocus={onFocus} + onBlur={(e) => onBlur(e.target.value)} minFractionDigits={0} maxFractionDigits={2} locale='it-IT' diff --git a/src/components/FormField/components/Table/index.js b/src/components/FormField/components/Table/index.js index 8edd2d7..0edcb06 100644 --- a/src/components/FormField/components/Table/index.js +++ b/src/components/FormField/components/Table/index.js @@ -122,13 +122,8 @@ const Table = ({ useEffect(() => { const stateFieldData = pathOr([], ['stateFieldData'], tableColumns); - /*const obj = stateFieldData - .reduce((acc, cur) => { - acc[cur.name] = '' - return acc; - }, {});*/ let rowsData = pathOr([], ['rowsData'], tableColumns); - //rowsData = isEmpty(rowsData) ? [obj] : rowsData; + setColumnsCfg(stateFieldData); setRowsCfg(rowsData);