diff --git a/src/components/formFields/form/index.tsx b/src/components/formFields/form/index.tsx index 9b0ac4dbdc0015f2564e77ab1412809bfbfeed9f..68633432993bed15bf1035e7bf046770c487d96f 100644 --- a/src/components/formFields/form/index.tsx +++ b/src/components/formFields/form/index.tsx @@ -1,7 +1,7 @@ import React from 'react' import { FormField } from 'ccms' -import { Form, Button, Divider, Space } from 'antd' -import { PlusOutlined, MinusCircleOutlined } from '@ant-design/icons' +import { Form, Button, Divider, Collapse, Space, Row, Col } from 'antd' +import { PlusOutlined, MinusCircleOutlined, ArrowUpOutlined, ArrowDownOutlined, DeleteOutlined } from '@ant-design/icons' import { IFormField, IFormFieldItem, IFormFieldItemField } from 'ccms/dist/src/components/formFields/form' import getALLComponents from '../' import { formItemLayout } from '../common' @@ -35,20 +35,59 @@ export default class FormFieldComponent extends FormField { renderItemComponent = (props: IFormFieldItem) => { const { + title, + index, + isLastIndex, removeText, onRemove, + onSort, + canCollapse, children } = props return ( -
+ {title}
} + key={index} + forceRender={false} + showArrow={!!canCollapse} + collapsible={'header'} + extra={( + + {onSort + ? + { + e.stopPropagation() + index > 0 && onSort('up') + }} + style={{ + opacity: index === 0 ? 0.5 : 1, + cursor: index === 0 ? 'not-allowed' : 'pointer' + }} + /> + { + e.stopPropagation() + !isLastIndex && onSort('down') + }} + style={{ + opacity: isLastIndex ? 0.5 : 1, + cursor: isLastIndex ? 'not-allowed' : 'pointer' + }} + /> + + : null} + {onRemove + ? { + e.stopPropagation() + onRemove() + }} /> + : null} + )} + > {children} - { - removeText && - - - } - + ) } @@ -56,9 +95,17 @@ export default class FormFieldComponent extends FormField { const { insertText, onInsert, + canCollapse, children } = props + const collapsePaneldDefaultActiveKeys = Array.from(Array(children.length), (v,k) =>k) + const CollapseProps = canCollapse? { + accordion: true + }: { + activeKey: collapsePaneldDefaultActiveKeys + } + return ( } > - {children} - + {children} + {onInsert? - + : null} ) diff --git a/src/steps/form/index.tsx b/src/steps/form/index.tsx index 3e90fda04d45544346772910de9d8deb5c1f0dfb..0b97163eb6575e5067b4ec90f89973a8d47fe6f8 100644 --- a/src/steps/form/index.tsx +++ b/src/steps/form/index.tsx @@ -34,7 +34,8 @@ export default class FormStepComponent extends FormStep { return (
{children}