Skip to content

Commit 9709bb7

Browse files
committed
TableViewのbooleanの設定
1 parent 7295d70 commit 9709bb7

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

apps/mooreseditor/src/components/TableView/components/TableRow.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Table, Button, Group, ActionIcon } from "@mantine/core";
2+
import { Table, Button, Group, ActionIcon, Checkbox } from "@mantine/core";
33
import { IconTrash } from "@tabler/icons-react";
44
import { ForeignKeyDisplayCell } from "../cells/ForeignKeyDisplayCell";
55
import { EditableCell } from "../cells/EditableCell";
@@ -94,6 +94,37 @@ export const TableRow: React.FC<TableRowProps> = ({
9494
);
9595
}
9696

97+
// Handle boolean display with direct editing
98+
if (columnSchema.type === 'boolean') {
99+
return (
100+
<Table.Td
101+
key={column.key}
102+
onClick={(e: React.MouseEvent) => {
103+
e.stopPropagation();
104+
}}
105+
>
106+
<Checkbox
107+
checked={value ?? false}
108+
onChange={(e) => {
109+
if (onDataChange) {
110+
const newData = [...arrayData];
111+
newData[index] = {
112+
...newData[index],
113+
[column.key]: e.currentTarget.checked
114+
};
115+
onDataChange(newData);
116+
}
117+
}}
118+
aria-label={`${column.key} ${value ? 'true' : 'false'}`}
119+
styles={{
120+
input: { cursor: 'pointer' },
121+
root: { padding: '8px' }
122+
}}
123+
/>
124+
</Table.Td>
125+
);
126+
}
127+
97128
// Regular display for other types
98129
const displayValue = columnSchema.type === 'uuid' && value
99130
? `${String(value).slice(0, 4)}..`

apps/mooreseditor/src/components/TableView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const TableView = ({ schema, data, jsonData, onDataChange, onRowSelect }:
6262
return objectSchema.properties.filter(prop => {
6363
if (!('type' in prop)) return false;
6464
const propSchema = prop as any;
65-
const primitiveTypes = ['string', 'uuid', 'enum', 'integer', 'number'];
65+
const primitiveTypes = ['string', 'uuid', 'enum', 'integer', 'number', 'boolean'];
6666
return primitiveTypes.includes(propSchema.type);
6767
});
6868
}, [schema]);

0 commit comments

Comments
 (0)