Toggle datatypes visibility (#366)

* showDatatype setting added in view control panel

* removed shortcut

can be discussed later

* fixed linting issue and made sure the condition check is above div element

in table.jsx code
in the else part im directly returning the element by keeping a check  for settings.showDataTypes?
which helps to not add empty element

for setSetting issue
I used the similar code used just above the snippet and modified it
This commit is contained in:
Kratik 2025-03-17 03:20:59 +05:30 committed by GitHub
parent 2a03298d29
commit 3e7d1ac6f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 5 deletions

View File

@ -354,7 +354,7 @@ export default function Table(props) {
icon={<IconMinus />}
onClick={() => deleteField(fieldData, tableData.id)}
/>
) : (
) : settings.showDataTypes ? (
<div className="flex gap-1 items-center">
{fieldData.primary && <IconKeyStroked />}
{!fieldData.notNull && <span>?</span>}
@ -362,13 +362,14 @@ export default function Table(props) {
{fieldData.type +
((dbToTypes[database][fieldData.type].isSized ||
dbToTypes[database][fieldData.type].hasPrecision) &&
fieldData.size &&
fieldData.size !== ""
? "(" + fieldData.size + ")"
fieldData.size &&
fieldData.size !== ""
? `(${fieldData.size})`
: "")}
</span>
</div>
)}
) : null
}
</div>
</div>
);

View File

@ -1211,6 +1211,15 @@ export default function ControlPanel({
function: resetView,
shortcut: "Ctrl+R",
},
show_datatype: {
state: settings.showDataTypes ? (
<i className="bi bi-toggle-on" />
) : (
<i className="bi bi-toggle-off" />
),
function: () =>
setSettings((prev) => ({ ...prev, showDataTypes: !prev.showDataTypes })),
},
show_grid: {
state: settings.showGrid ? (
<i className="bi bi-toggle-on" />

View File

@ -5,6 +5,7 @@ const defaultSettings = {
strictMode: false,
showFieldSummary: true,
showGrid: true,
showDataTypes: true,
mode: "light",
autosave: true,
panning: true,

View File

@ -49,6 +49,7 @@ const en = {
field_details: "Field details",
reset_view: "Reset view",
show_grid: "Show grid",
show_datatype: "Show datatype",
show_cardinality: "Show cardinality",
theme: "Theme",
light: "Light",