From d562b910cadf028af89e5a4d72dbaa721ed2f515 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Thu, 7 Oct 2021 10:48:26 +0500 Subject: [PATCH] CF2-49: Added values to table inputs while 'Measures' table update --- src/pages/Measure/MeasureTable.jsx | 26 ++++++++++++++------------ src/pages/Measure/View.jsx | 9 ++------- src/styles/measure.css | 4 ++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index eb4714c..5cb1c45 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { Button, Form, Timeline } from 'antd' +import { Button, Form, Input, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' @@ -44,12 +44,18 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update useEffect(() => { let switchableColumns = [] + isTableEditing && editingActionName !== 'Удалить' - ? switchableColumns = createEditingColumns(columns, () => ) + ? switchableColumns = createEditingColumns(columns, () => ) : switchableColumns = createEditingColumns(columns, null) + if(editingActionName === 'Редактировать') + measuresForm.setFieldsValue(displayedValues.data); + else if(editingActionName === 'Добавить') + measuresForm.resetFields() + setEditingColumns(switchableColumns) - }, [isTableEditing, columns, editingActionName]) + }, [isTableEditing, columns, editingActionName, displayedValues.data, measuresForm]) const buttonsConfig = [ {name:'Добавить', key:'add'}, @@ -60,14 +66,14 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const createButtons = (config, onClickDelegate) => { return (
- {config.map(c => { + {config.map(conf => { return ( ) })} @@ -75,7 +81,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update ) } - const crudButtons = createButtons(buttonsConfig, (e)=> { + const crudButtons = createButtons(buttonsConfig, (e) => { setEditingActionName(e.target.innerText) setIsTableEditing(true) }) @@ -103,10 +109,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
let handleSubmitMeasuresForm = async (formData) => { - // if(isTableEditing) - // measuresForm.setFieldsValue({ - // ...displayedValues - // }); measuresForm.validateFields() const measureParams = { @@ -162,7 +164,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update onFinish={handleSubmitMeasuresForm} > diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 419caad..16a9c80 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -31,10 +31,7 @@ export const View = ({columns, item}) => { {column.title} @@ -42,9 +39,7 @@ export const View = ({columns, item}) => {