From 61049d6b8b19164738dda635425b938cf22c1b48 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Thu, 7 Oct 2021 15:05:59 +0500 Subject: [PATCH] CF2-49: Fixed 'Measures' table in editing view --- src/pages/Measure/MeasureTable.jsx | 45 ++++++++++++++++++++---------- src/pages/Measure/View.jsx | 10 +++++-- src/pages/Measure/columnsCommon.js | 8 +++++- src/pages/Measure/index.jsx | 10 +++++-- src/styles/measure.css | 13 +++------ 5 files changed, 56 insertions(+), 30 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 9ce6710..103ada1 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react' import { Button, Form, Input, Timeline } from 'antd' import moment from 'moment' -import { ExclamationCircleOutlined } from '@ant-design/icons' +import { CheckSquareOutlined } from '@ant-design/icons' import { View } from './View' import LoaderPortal from '../../components/LoaderPortal' import { MeasureService } from '../../services/api' @@ -22,10 +22,10 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const [measuresForm] = Form.useForm(); const createEditingColumns = (cols, renderDelegate) => - cols.map(col => - ({ render: renderDelegate, - ...col - }) + cols.map(col => + ({ render: renderDelegate, + ...col + }) ) useEffect(() => { @@ -93,7 +93,10 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update

{editingActionName} данные?

- - +
@@ -122,7 +131,15 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update } setShowLoader(true) - await MeasureService.insert(idWell, measureParams) + + if(editingActionName === 'Добавить') { + await MeasureService.insert(idWell, measureParams) + } else if (editingActionName === 'Редактировать') { + measureParams.id = displayedValues.id + measureParams.timestamp = displayedValues.timestamp + await MeasureService.update(idWell, measureParams) + } + setIsTableEditing(false) updateMeasuresFunc() setShowLoader(false) @@ -145,16 +162,16 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update {values.map((item, index) => setSelectedTimeLineId(item.id)} dot={item?.id === displayedValues?.id - ? + ? : null} > - {moment.utc(item.timestamp).local().format(format)} + + {moment.utc(item.timestamp).local().format(format)} + )} diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 16a9c80..0763514 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -6,6 +6,7 @@ const renderSwitchableColumn = (column, itm) => { if(column.render) { return ( { ) } - return

{itm[column.dataIndex]}

+ return

{itm[column.dataIndex]}

} export const View = ({columns, item}) => { if (!item || !columns?.length) - return + return const colsCount = 3 const viewItems = columns.map( (column, i) => { @@ -29,6 +30,7 @@ export const View = ({columns, item}) => { return <> { {renderSwitchableColumn(column, item)} diff --git a/src/pages/Measure/columnsCommon.js b/src/pages/Measure/columnsCommon.js index 7d458b5..5e7a616 100644 --- a/src/pages/Measure/columnsCommon.js +++ b/src/pages/Measure/columnsCommon.js @@ -42,4 +42,10 @@ export const numericColumnOptions = { export const textColumnOptions = { editable:true, input: