mirror of
https://github.com/drawdb-io/drawdb.git
synced 2025-05-24 02:09:17 +00:00
Fix inputs
This commit is contained in:
parent
75e3d4c8cc
commit
ac15627237
@ -11,7 +11,6 @@ export default function SearchBar({ tables }) {
|
||||
|
||||
const treeData = useMemo(() => {
|
||||
return tables.map(({ id, name: parentName, fields }, i) => {
|
||||
console.log(fields)
|
||||
const children = fields?.map(({ name }, j) => ({
|
||||
tableId: id,
|
||||
id: `${j}`,
|
||||
|
@ -18,11 +18,13 @@ export default function TableField({ data, tid, index }) {
|
||||
const [editField, setEditField] = useState({});
|
||||
|
||||
return (
|
||||
<div className="hover-1 my-2 flex gap-2 items-center" >
|
||||
<div
|
||||
id={`scroll_table_${tid}_input_${index}`}
|
||||
className="hover-1 my-2 flex gap-2 items-center"
|
||||
>
|
||||
<DragHandle id={data.id} />
|
||||
<div className="min-w-20 flex-1/3">
|
||||
<Input
|
||||
id={`scroll_table_${tid}_input_${index}`}
|
||||
value={data.name}
|
||||
validateStatus={data.name.trim() === "" ? "error" : "default"}
|
||||
placeholder="Name"
|
||||
|
@ -65,13 +65,8 @@ export default function TableInfo({ data }) {
|
||||
});
|
||||
}}
|
||||
afterChange={() => setSaveState(State.SAVING)}
|
||||
renderItem={(item) => (
|
||||
<TableField
|
||||
key={"field_" + item.id}
|
||||
data={item}
|
||||
tid={data.id}
|
||||
index={item.id}
|
||||
/>
|
||||
renderItem={(item, i) => (
|
||||
<TableField data={item} tid={data.id} index={i} />
|
||||
)}
|
||||
/>
|
||||
{data.indices.length > 0 && (
|
||||
|
@ -47,8 +47,9 @@ export default function TablesTab() {
|
||||
accordion
|
||||
>
|
||||
<SortableList
|
||||
type="table"
|
||||
items={tables}
|
||||
onChange={setTables}
|
||||
onChange={(newTables) => setTables(newTables)}
|
||||
afterChange={() => setSaveState(State.SAVING)}
|
||||
renderItem={(item) => <TableListItem table={item} />}
|
||||
/>
|
||||
|
@ -12,7 +12,13 @@ import {
|
||||
} from "@dnd-kit/sortable";
|
||||
import { SortableItem } from "./SortableItem";
|
||||
|
||||
export function SortableList({ items, onChange, afterChange, renderItem }) {
|
||||
export function SortableList({
|
||||
items,
|
||||
onChange,
|
||||
afterChange,
|
||||
renderItem,
|
||||
type = "",
|
||||
}) {
|
||||
const sensors = useSensors(useSensor(PointerSensor));
|
||||
|
||||
const handleDragEnd = (event) => {
|
||||
@ -34,12 +40,9 @@ export function SortableList({ items, onChange, afterChange, renderItem }) {
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<SortableContext items={items} strategy={verticalListSortingStrategy}>
|
||||
{items.map((item) => (
|
||||
<SortableItem
|
||||
key={`sortable-item-${item.name ?? ""}-${item.id}`}
|
||||
id={item.id}
|
||||
>
|
||||
{renderItem(item)}
|
||||
{items.map((item, i) => (
|
||||
<SortableItem id={item.id} key={`sortable-item-${type}-${item.id}`}>
|
||||
{renderItem(item, i)}
|
||||
</SortableItem>
|
||||
))}
|
||||
</SortableContext>
|
||||
|
Loading…
Reference in New Issue
Block a user