Skip to content

Commit

Permalink
feat show form fields descriptions (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
codev99 authored Oct 14, 2024
1 parent 40ce1e6 commit 418878c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ Copy content of _/build_ folder in your web server
title?: string,
description?: string,
fieldsEndpoint?: string,
descriptionTooltip: boolean,
prefix?: string,
}
```
Expand All @@ -489,6 +490,7 @@ Copy content of _/build_ folder in your web server
title: "lorem ipsum dolor sit amet",
description: "lorem ipsum dolor sit amet",
fieldsEndpoint: "/lorem/ipsum",
descriptionTooltip: true,
prefix: "filtersCompositions",
}
```
Expand Down
8 changes: 4 additions & 4 deletions public/config/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"api": {
"AUTHN_API_BASE_URL": "http://4.207.39.182:8082",
"BFF_API_BASE_URL": "http://4.207.39.183:8081",
"EVENTS_API_BASE_URL": "http://172.205.78.36:8083",
"EVENTS_PUSH_API_BASE_URL": "http://172.205.78.36:8083",
"AUTHN_API_BASE_URL": "http://135.236.145.79:8082",
"BFF_API_BASE_URL": "http://135.236.149.62:8081",
"EVENTS_API_BASE_URL": "http://48.209.179.60:8083",
"EVENTS_PUSH_API_BASE_URL": "http://48.209.179.60:8083",
"TERMINAL_SOCKET_URL": "http://localhost:8084"
},
"params": {
Expand Down
18 changes: 13 additions & 5 deletions src/components/Widgets/FormGenerator/FormGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import SelectWithFilters from "./SelectWithFilters";
type FormGeneratorType = {
title?: string,
description?: string,
descriptionTooltip: boolean,
fieldsEndpoint?: string,
form: FormInstance<any>,
prefix?: string,
onClose: () => void,
disableButtons: (value: boolean) => void
}

const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClose, disableButtons }: FormGeneratorType) => {
const FormGenerator = ({title, description, descriptionTooltip = false, fieldsEndpoint, form, prefix, onClose, disableButtons }: FormGeneratorType) => {

const [postContent, { data: postData, isLoading: postLoading, isSuccess: isPostSuccess, isError: isPostError, error: postError }] = usePostContentMutation();
const { message } = App.useApp();
Expand Down Expand Up @@ -138,21 +139,20 @@ const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClos
label={renderLabel(name, label)}
name={name.split(".")}
rules={rules}
tooltip={descriptionTooltip && node.description ? node.description : undefined}
extra={!descriptionTooltip && node.description ? node.description : undefined}
>
{node.enum ? (
node.enum.length > 4 ? (
<Select
placeholder={node.description ? node.description : undefined}
options={node.enum.map(opt => ({value: opt, label: opt}))}
allowClear
/>
)
:
<Radio.Group>{node.enum.map((el) => <Radio key={`radio_${el}`} value={el}>{el}</Radio>)}</Radio.Group>
) :
<Input
placeholder={node.description ? node.description : undefined}
/>
<Input />
}
</Form.Item>
</div>
Expand All @@ -169,6 +169,8 @@ const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClos
name={name.split(".")}
valuePropName="checked"
rules={rules}
tooltip={descriptionTooltip && node.description ? node.description : undefined}
extra={!descriptionTooltip && node.description ? node.description : undefined}
>
<Switch />
</Form.Item>
Expand All @@ -184,6 +186,8 @@ const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClos
label={renderLabel(name, label)}
name={name.split(".")}
rules={rules}
tooltip={descriptionTooltip && node.description ? node.description : undefined}
extra={!descriptionTooltip && node.description ? node.description : undefined}
>
<ListEditor onChange={(values) => {form.setFieldValue(name, values)}} />
</Form.Item>
Expand All @@ -201,6 +205,8 @@ const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClos
label={renderLabel(name, label)}
name={name.split(".")}
rules={rules}
tooltip={descriptionTooltip && node.description ? node.description : undefined}
extra={!descriptionTooltip && node.description ? node.description : undefined}
>
{
min && max && (max - min < 100) ?
Expand All @@ -220,6 +226,8 @@ const FormGenerator = ({title, description, fieldsEndpoint, form, prefix, onClos
label={renderLabel(name, label)}
name={name.split(".")}
rules={rules}
tooltip={descriptionTooltip && node.description ? node.description : undefined}
extra={!descriptionTooltip && node.description ? node.description : undefined}
>
<SelectWithFilters node={node} />
</Form.Item>
Expand Down

0 comments on commit 418878c

Please sign in to comment.