diff --git a/src/components/Table/DatePickerWrapper.tsx b/src/components/Table/DatePickerWrapper.tsx index f042a4a..b1735b8 100644 --- a/src/components/Table/DatePickerWrapper.tsx +++ b/src/components/Table/DatePickerWrapper.tsx @@ -1,6 +1,6 @@ import { DatePicker } from 'antd' import moment from 'moment' -import { formatDate } from './index' +import { defaultFormat } from '../../utils' export type DatePickerWrapperProps = { value: moment.Moment, @@ -13,7 +13,7 @@ export const DatePickerWrapper: React.FC = ({value, onCh allowClear={false} defaultValue={moment()} value={moment.utc(value).local()} - format={formatDate} + format={defaultFormat} showTime onChange={(date) => onChange(date)} {...other} diff --git a/src/components/Table/EditableTable.jsx b/src/components/Table/EditableTable.jsx index 1d1a2eb..af84287 100644 --- a/src/components/Table/EditableTable.jsx +++ b/src/components/Table/EditableTable.jsx @@ -6,17 +6,25 @@ import { invokeWebApiWrapperAsync } from '../factory' const newRowKeyValue = 'newRow' -export const makeActionHandler = (action, { service, setLoader, errorMsg, onComplete }) => service && action && ( +export const makeActionHandler = (action, { idWell, service, setLoader, errorMsg, onComplete }, recordParser) => service && action && ( (record) => invokeWebApiWrapperAsync( async () => { + const addIdWell = (...params) => idWell ? [idWell, ...params] : params + if (typeof recordParser === 'function') + record = recordParser(record) + if (action === 'insert') { record.key = Date.now() - await service.insert(record) + await service.insert(...addIdWell(record)) + } else if (action === 'insertRange') { + if (!Array.isArray(record)) + record = [record] + await service.insertRange(...addIdWell(record)) } else if (record.id) { if (action === 'update') - await service.put(record.id, record) + await service.put(...addIdWell(record.id, record)) else if (action === 'delete') - await service.delete(record.id) + await service.delete(...addIdWell(record.id)) } onComplete?.() }, diff --git a/src/components/Table/index.tsx b/src/components/Table/index.tsx index 8f6b439..57b57e1 100644 --- a/src/components/Table/index.tsx +++ b/src/components/Table/index.tsx @@ -10,7 +10,6 @@ export { DatePickerWrapper } from './DatePickerWrapper' export { SelectFromDictionary } from './SelectFromDictionary' export const RegExpIsFloat = /^[-+]?\d+\.?\d*$/ -export const formatDate = 'YYYY.MM.DD HH:mm' export const makeNumericRender = (fixed?: number) => (value: any, row: object): ReactNode => { let val = '-' @@ -209,7 +208,7 @@ export const makeSelectColumn = ( other?: columnPropsOther ) => makeColumn(title, dataIndex, { input: { - setStep(e) - }} - value={step}> - {periodOptions} - +