Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#148array validation expanded #630

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 136 additions & 6 deletions cyclops-ui/src/components/form/fields/array/ArrayField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
Input,
Row,
Tooltip,
Checkbox,
InputNumber,
} from "antd";
import {
InfoCircleOutlined,
Expand Down Expand Up @@ -117,15 +119,11 @@ export const ArrayField = ({
onClick={() => remove(arrField.name)}
/>
</Row>
{arrFields !== null &&
arrFields !== undefined &&
index + 1 === arrFields.length ? (
{index + 1 === arrFields.length ? (
<Divider
style={{ marginTop: "4px", marginBottom: "12px" }}
/>
) : (
<></>
)}
) : null}
</Col>
))}
<Form.Item style={{ marginBottom: "0" }}>
Expand All @@ -144,6 +142,138 @@ export const ArrayField = ({
</Form.Item>
);
}

if (field.items.type === "number") {
return (
<Form.Item
wrapperCol={{ span: 16 }}
name={fieldName}
label={field.display_name}
style={{ marginBottom: "12px" }}
>
<Form.List name={formItemName}>
{(arrFields, { add, remove }) => (
<div
style={{
border: "solid 1px #d3d3d3",
borderRadius: "7px",
padding: "12px",
width: "100%",
backgroundColor: "#fafafa",
}}
>
{arrFields.map((arrField, index) => (
<Col key={arrField.key}>
<Row>
<Form.Item
style={{
paddingBottom: "8px",
marginBottom: "0px",
width: "80%",
}}
wrapperCol={{ span: 24 }}
{...arrField}
name={[arrField.name]}
>
<InputNumber
disabled={field.immutable && isModuleEdit}
/>
</Form.Item>
<MinusCircleOutlined
style={{ fontSize: "16px", paddingLeft: "10px" }}
onClick={() => remove(arrField.name)}
/>
</Row>
{index + 1 === arrFields.length ? (
<Divider
style={{ marginTop: "4px", marginBottom: "12px" }}
/>
) : null}
</Col>
))}
<Form.Item style={{ marginBottom: "0" }}>
<Button
type="dashed"
onClick={() => add()}
block
icon={<PlusOutlined />}
>
Add
</Button>
</Form.Item>
</div>
)}
</Form.List>
</Form.Item>
);
}

if (field.items.type === "boolean") {
Ujj1225 marked this conversation as resolved.
Show resolved Hide resolved
return (
<Form.Item
wrapperCol={{ span: 16 }}
name={fieldName}
label={field.display_name}
style={{ marginBottom: "12px" }}
>
<Form.List name={formItemName}>
{(arrFields, { add, remove }) => (
<div
style={{
border: "solid 1px #d3d3d3",
borderRadius: "7px",
padding: "12px",
width: "100%",
backgroundColor: "#fafafa",
}}
>
{arrFields.map((arrField, index) => (
<Col key={arrField.key}>
<Row>
<Form.Item
style={{
paddingBottom: "8px",
marginBottom: "0px",
width: "80%",
}}
wrapperCol={{ span: 24 }}
{...arrField}
name={[arrField.name]}
valuePropName="checked"
>
<Checkbox disabled={field.immutable && isModuleEdit}>
{field.display_name}
</Checkbox>
</Form.Item>
<MinusCircleOutlined
style={{ fontSize: "16px", paddingLeft: "10px" }}
onClick={() => remove(arrField.name)}
/>
</Row>
{index + 1 === arrFields.length ? (
<Divider
style={{ marginTop: "4px", marginBottom: "12px" }}
/>
) : null}
</Col>
))}
<Form.Item style={{ marginBottom: "0" }}>
<Button
type="dashed"
onClick={() => add()}
block
icon={<PlusOutlined />}
>
Add
</Button>
</Form.Item>
</div>
)}
</Form.List>
</Form.Item>
);
}

if (field.items.type === "object") {
return (
<Collapse
Expand Down
Loading