make overview functional
This commit is contained in:
parent
52ed3a88b7
commit
1dc2c4d3d3
@ -169,6 +169,7 @@ export default function Canvas(props) {
|
|||||||
{
|
{
|
||||||
name: "id",
|
name: "id",
|
||||||
type: "UUID",
|
type: "UUID",
|
||||||
|
check: "",
|
||||||
default: "",
|
default: "",
|
||||||
primary: true,
|
primary: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
@ -42,7 +42,17 @@ export default function DiagramOverview(props) {
|
|||||||
itemKey={`${i}`}
|
itemKey={`${i}`}
|
||||||
>
|
>
|
||||||
{t.fields.map((f, j) => (
|
{t.fields.map((f, j) => (
|
||||||
<Form key={j}>
|
<Form
|
||||||
|
key={j}
|
||||||
|
onChange={(value) => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = updatedTables[i].fields.map(
|
||||||
|
(field, index) =>
|
||||||
|
index === j ? { ...field, ...value.values } : field
|
||||||
|
);
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Row
|
<Row
|
||||||
type="flex"
|
type="flex"
|
||||||
justify="start"
|
justify="start"
|
||||||
@ -52,7 +62,7 @@ export default function DiagramOverview(props) {
|
|||||||
>
|
>
|
||||||
<Col span={7}>
|
<Col span={7}>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field={`name-${j}`}
|
field="name"
|
||||||
noLabel={true}
|
noLabel={true}
|
||||||
initValue={f.name}
|
initValue={f.name}
|
||||||
className="m-0"
|
className="m-0"
|
||||||
@ -62,7 +72,7 @@ export default function DiagramOverview(props) {
|
|||||||
<Col span={8}>
|
<Col span={8}>
|
||||||
<Form.Select
|
<Form.Select
|
||||||
className="w-full"
|
className="w-full"
|
||||||
field={`type-${j}`}
|
field="type"
|
||||||
noLabel={true}
|
noLabel={true}
|
||||||
optionList={sqlDataTypes.map((value, index) => {
|
optionList={sqlDataTypes.map((value, index) => {
|
||||||
return {
|
return {
|
||||||
@ -75,18 +85,61 @@ export default function DiagramOverview(props) {
|
|||||||
></Form.Select>
|
></Form.Select>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={3}>
|
<Col span={3}>
|
||||||
<Button type="tertiary" title="Nullable">
|
<Button
|
||||||
|
type={f.notNull ? "primary" : "tertiary"}
|
||||||
|
title="Nullable"
|
||||||
|
theme={f.notNull ? "solid" : "light"}
|
||||||
|
onClick={() => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = updatedTables[i].fields.map(
|
||||||
|
(field, index) =>
|
||||||
|
index === j
|
||||||
|
? { ...field, notNull: !f.notNull }
|
||||||
|
: field
|
||||||
|
);
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
>
|
||||||
?
|
?
|
||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={3}>
|
<Col span={3}>
|
||||||
<Button type="tertiary" icon={<IconKeyStroked />}></Button>
|
<Button
|
||||||
|
type={f.primary ? "primary" : "tertiary"}
|
||||||
|
title="Nullable"
|
||||||
|
theme={f.primary ? "solid" : "light"}
|
||||||
|
onClick={() => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = updatedTables[i].fields.map(
|
||||||
|
(field, index) =>
|
||||||
|
index === j
|
||||||
|
? { ...field, primary: !f.primary }
|
||||||
|
: field
|
||||||
|
);
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
icon={<IconKeyStroked />}
|
||||||
|
></Button>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={3}>
|
<Col span={3}>
|
||||||
<Popover
|
<Popover
|
||||||
content={
|
content={
|
||||||
<div className="px-1">
|
<div className="px-1">
|
||||||
<Form>
|
<Form
|
||||||
|
onChange={(value) => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i] = {
|
||||||
|
...updatedTables[i],
|
||||||
|
fields: updatedTables[i].fields.map(
|
||||||
|
(field, index) =>
|
||||||
|
index === j
|
||||||
|
? { ...field, ...value.values }
|
||||||
|
: field
|
||||||
|
),
|
||||||
|
};
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Form.Input
|
<Form.Input
|
||||||
field="default"
|
field="default"
|
||||||
label="Default"
|
label="Default"
|
||||||
@ -99,7 +152,32 @@ export default function DiagramOverview(props) {
|
|||||||
label="Check Expression"
|
label="Check Expression"
|
||||||
trigger="blur"
|
trigger="blur"
|
||||||
placeholder="Set constraint"
|
placeholder="Set constraint"
|
||||||
|
initValue={f.check}
|
||||||
/>
|
/>
|
||||||
|
<div className="flex justify-between items-center my-3">
|
||||||
|
<label htmlFor="unique" className="font-medium">
|
||||||
|
Unique
|
||||||
|
</label>
|
||||||
|
<Checkbox
|
||||||
|
value="unique"
|
||||||
|
defaultChecked={f.unique}
|
||||||
|
onChange={(checkedValues) => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = updatedTables[
|
||||||
|
i
|
||||||
|
].fields.map((field, index) =>
|
||||||
|
index === j
|
||||||
|
? {
|
||||||
|
...field,
|
||||||
|
[checkedValues.target.value]:
|
||||||
|
checkedValues.target.checked,
|
||||||
|
}
|
||||||
|
: field
|
||||||
|
);
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
></Checkbox>
|
||||||
|
</div>
|
||||||
<div className="flex justify-between items-center my-3">
|
<div className="flex justify-between items-center my-3">
|
||||||
<label htmlFor="increment" className="font-medium">
|
<label htmlFor="increment" className="font-medium">
|
||||||
Autoincrement
|
Autoincrement
|
||||||
@ -107,6 +185,21 @@ export default function DiagramOverview(props) {
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
value="increment"
|
value="increment"
|
||||||
defaultChecked={f.increment}
|
defaultChecked={f.increment}
|
||||||
|
onChange={(checkedValues) => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = updatedTables[
|
||||||
|
i
|
||||||
|
].fields.map((field, index) =>
|
||||||
|
index === j
|
||||||
|
? {
|
||||||
|
...field,
|
||||||
|
[checkedValues.target.value]:
|
||||||
|
checkedValues.target.checked,
|
||||||
|
}
|
||||||
|
: field
|
||||||
|
);
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
></Checkbox>
|
></Checkbox>
|
||||||
</div>
|
</div>
|
||||||
<Form.TextArea
|
<Form.TextArea
|
||||||
@ -122,6 +215,16 @@ export default function DiagramOverview(props) {
|
|||||||
icon={<IconDeleteStroked />}
|
icon={<IconDeleteStroked />}
|
||||||
type="danger"
|
type="danger"
|
||||||
block
|
block
|
||||||
|
onClick={() => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
const updatedFields = [...t.fields];
|
||||||
|
updatedFields.splice(j, 1);
|
||||||
|
updatedTables[i] = {
|
||||||
|
...t,
|
||||||
|
fields: [...updatedFields],
|
||||||
|
};
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
@ -326,7 +429,28 @@ export default function DiagramOverview(props) {
|
|||||||
</Button>
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={8}>
|
<Col span={8}>
|
||||||
<Button block>Add field</Button>
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
const updatedTables = [...props.tables];
|
||||||
|
updatedTables[i].fields = [
|
||||||
|
...updatedTables[i].fields,
|
||||||
|
{
|
||||||
|
name: "",
|
||||||
|
type: "",
|
||||||
|
default: "",
|
||||||
|
primary: false,
|
||||||
|
unique: false,
|
||||||
|
notNull: false,
|
||||||
|
increment: false,
|
||||||
|
comment: "",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
props.setTables(updatedTables);
|
||||||
|
}}
|
||||||
|
block
|
||||||
|
>
|
||||||
|
Add field
|
||||||
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Collapse.Panel>
|
</Collapse.Panel>
|
||||||
|
@ -89,6 +89,7 @@ export default function EditorPanel(props) {
|
|||||||
name: "id",
|
name: "id",
|
||||||
type: "UUID",
|
type: "UUID",
|
||||||
default: "",
|
default: "",
|
||||||
|
check: "",
|
||||||
primary: true,
|
primary: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
notNull: true,
|
notNull: true,
|
||||||
@ -148,6 +149,7 @@ export default function EditorPanel(props) {
|
|||||||
name: "id",
|
name: "id",
|
||||||
type: "UUID",
|
type: "UUID",
|
||||||
default: "",
|
default: "",
|
||||||
|
check: "",
|
||||||
primary: true,
|
primary: true,
|
||||||
unique: true,
|
unique: true,
|
||||||
notNull: true,
|
notNull: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user