Add enums to select types
This commit is contained in:
parent
7c1eecd7a0
commit
d48ccfff4b
@ -1,7 +1,7 @@
|
||||
import { Action, ObjectType } from "../../../data/constants";
|
||||
import { Row, Col, Input, Button, Popover, Select } from "@douyinfe/semi-ui";
|
||||
import { IconMore, IconKeyStroked } from "@douyinfe/semi-icons";
|
||||
import { useTables, useTypes, useUndoRedo } from "../../../hooks";
|
||||
import { useEnums, useTables, useTypes, useUndoRedo } from "../../../hooks";
|
||||
import { useState } from "react";
|
||||
import FieldDetails from "./FieldDetails";
|
||||
import { useTranslation } from "react-i18next";
|
||||
@ -10,6 +10,7 @@ import { dbToTypes } from "../../../data/datatypes";
|
||||
export default function TableField({ data, tid, index }) {
|
||||
const { updateField } = useTables();
|
||||
const { types } = useTypes();
|
||||
const { enums } = useEnums();
|
||||
const { tables, database } = useTables();
|
||||
const { t } = useTranslation();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
@ -58,6 +59,10 @@ export default function TableField({ data, tid, index }) {
|
||||
label: type.name.toUpperCase(),
|
||||
value: type.name.toUpperCase(),
|
||||
})),
|
||||
...enums.map((type) => ({
|
||||
label: type.name.toUpperCase(),
|
||||
value: type.name.toUpperCase(),
|
||||
})),
|
||||
]}
|
||||
filter
|
||||
value={data.type}
|
||||
|
@ -11,12 +11,13 @@ import {
|
||||
Popover,
|
||||
} from "@douyinfe/semi-ui";
|
||||
import { IconDeleteStroked, IconMore } from "@douyinfe/semi-icons";
|
||||
import { useUndoRedo, useTypes, useTables } from "../../../hooks";
|
||||
import { useUndoRedo, useTypes, useTables, useEnums } from "../../../hooks";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { dbToTypes } from "../../../data/datatypes";
|
||||
|
||||
export default function TypeField({ data, tid, fid }) {
|
||||
const { types, updateType } = useTypes();
|
||||
const { enums } = useEnums();
|
||||
const { database } = useTables();
|
||||
const { setUndoStack, setRedoStack } = useUndoRedo();
|
||||
const [editField, setEditField] = useState({});
|
||||
@ -75,6 +76,10 @@ export default function TypeField({ data, tid, fid }) {
|
||||
label: type.name.toUpperCase(),
|
||||
value: type.name.toUpperCase(),
|
||||
})),
|
||||
...enums.map((type) => ({
|
||||
label: type.name.toUpperCase(),
|
||||
value: type.name.toUpperCase(),
|
||||
})),
|
||||
]}
|
||||
filter
|
||||
value={data.type}
|
||||
@ -118,7 +123,11 @@ export default function TypeField({ data, tid, fid }) {
|
||||
updateType(tid, {
|
||||
fields: types[tid].fields.map((e, id) =>
|
||||
id === fid
|
||||
? { ...data, type: value, size: dbToTypes[database][value].defaultSize }
|
||||
? {
|
||||
...data,
|
||||
type: value,
|
||||
size: dbToTypes[database][value].defaultSize,
|
||||
}
|
||||
: e,
|
||||
),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user