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
4 changed files with 17 additions and 5 deletions

View File

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

View File

@@ -1211,6 +1211,15 @@ export default function ControlPanel({
function: resetView, function: resetView,
shortcut: "Ctrl+R", 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: { show_grid: {
state: settings.showGrid ? ( state: settings.showGrid ? (
<i className="bi bi-toggle-on" /> <i className="bi bi-toggle-on" />

View File

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

View File

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