Skip to content

Commit

Permalink
feat: add data path support in detailform and editform
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Jul 25, 2023
1 parent a4996b2 commit b47c0b7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/tushan/client/components/detail/DetailForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Form } from '@arco-design/web-react';
import { get } from 'lodash-es';
import React, { useMemo } from 'react';
import type { BasicRecord } from '../../api/types';
import { RecordContextProvider } from '../../context/record';
Expand All @@ -22,7 +23,7 @@ export const DetailForm: React.FC<DetailFormProps> = React.memo((props) => {
<Form>
{items.map((item) => (
<Form.Item key={item.source} label={item.title}>
{item.render(props.record[item.source])}
{item.render(get(props.record, item.source))}
</Form.Item>
))}
</Form>
Expand Down
3 changes: 2 additions & 1 deletion packages/tushan/client/components/edit/EditForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button, Form, Message, Space } from '@arco-design/web-react';
import { get } from 'lodash-es';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { BasicRecord, useRefreshList } from '../../api';
Expand Down Expand Up @@ -97,7 +98,7 @@ export const EditForm: React.FC<EditFormProps> = React.memo((props) => {
rules={item.rules}
>
{(formData, form) =>
item.render(formData[item.source], (val) => {
item.render(get(formData, item.source), (val) => {
form.setFieldValue(item.source, val);
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tushan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tushan",
"version": "0.3.1",
"version": "0.3.2",
"description": "",
"main": "./index.ts",
"scripts": {
Expand Down

0 comments on commit b47c0b7

Please sign in to comment.