Skip to content

Commit 4691329

Browse files
committed
Feature:Expanded ArrayField component to support arrays of numbers and booleans
1 parent f4ef08a commit 4691329

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

cyclops-ui/src/components/form/fields/array/ArrayField.tsx

+39-14
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
Input,
99
Row,
1010
Tooltip,
11+
Checkbox,
12+
InputNumber,
1113
} from "antd";
1214
import {
1315
InfoCircleOutlined,
@@ -117,15 +119,9 @@ export const ArrayField = ({
117119
onClick={() => remove(arrField.name)}
118120
/>
119121
</Row>
120-
{arrFields !== null &&
121-
arrFields !== undefined &&
122-
index + 1 === arrFields.length ? (
123-
<Divider
124-
style={{ marginTop: "4px", marginBottom: "12px" }}
125-
/>
126-
) : (
127-
<></>
128-
)}
122+
{index + 1 === arrFields.length ? (
123+
<Divider style={{ marginTop: "4px", marginBottom: "12px" }} />
124+
) : null}
129125
</Col>
130126
))}
131127
<Form.Item style={{ marginBottom: "0" }}>
@@ -144,6 +140,35 @@ export const ArrayField = ({
144140
</Form.Item>
145141
);
146142
}
143+
144+
if (field.items.type === "number") {
145+
return (
146+
<Form.Item
147+
wrapperCol={{ span: 16 }}
148+
name={fieldName}
149+
label={field.display_name}
150+
style={{ marginBottom: "12px" }}
151+
>
152+
<InputNumber disabled={field.immutable && isModuleEdit} />
153+
</Form.Item>
154+
);
155+
}
156+
157+
if (field.items.type === "boolean") {
158+
return (
159+
<Form.Item
160+
wrapperCol={{ span: 16 }}
161+
name={fieldName}
162+
valuePropName="checked"
163+
style={{ marginBottom: "12px" }}
164+
>
165+
<Checkbox disabled={field.immutable && isModuleEdit}>
166+
{field.display_name}
167+
</Checkbox>
168+
</Form.Item>
169+
);
170+
}
171+
147172
if (field.items.type === "object") {
148173
return (
149174
<Collapse
@@ -162,11 +187,11 @@ export const ArrayField = ({
162187
}}
163188
forceRender={true}
164189
>
165-
<Form.Item
166-
wrapperCol={{ span: 16 }}
167-
style={{
168-
paddingTop: "8px",
169-
marginBottom: "0",
190+
<Form.Item
191+
wrapperCol={{ span: 16 }}
192+
style={{
193+
paddingTop: "8px",
194+
marginBottom: "0",
170195
}}
171196
>
172197
<Form.List name={formItemName}>

0 commit comments

Comments
 (0)