mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 00:06:50 +00:00
fix(grid): display JSONB values as JSON string in edit mode and detail panel (#152)
String() on objects produces [object Object]. Use JSON.stringify() consistently wherever cell values are converted to strings.
This commit is contained in:
@@ -428,7 +428,7 @@ const activeCellDetail = computed(() => {
|
||||
if (!item || !column) return null;
|
||||
const value = item.data[cell.col] ?? null;
|
||||
const rawValue = formatCell(value);
|
||||
const valueText = value === null ? "" : String(value);
|
||||
const valueText = value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
|
||||
const trimmed = valueText.trim();
|
||||
const maybeJson = typeof value === "string" && (trimmed.startsWith("{") || trimmed.startsWith("["));
|
||||
let formattedJson = "";
|
||||
@@ -578,7 +578,7 @@ function startEdit(rowId: number, colIdx: number) {
|
||||
isCancelling = false;
|
||||
editingCell.value = { rowId, col: colIdx };
|
||||
const val = item?.data[colIdx] ?? null;
|
||||
editValue.value = val === null ? "" : String(val);
|
||||
editValue.value = val === null ? "" : typeof val === "object" ? JSON.stringify(val) : String(val);
|
||||
nextTick(() => {
|
||||
const input = document.querySelector(".cell-edit-input") as HTMLInputElement;
|
||||
input?.focus();
|
||||
|
||||
@@ -51,6 +51,7 @@ export function extractSelection(
|
||||
function displayValue(value: GridCellValue): string {
|
||||
if (value === null) return "NULL";
|
||||
if (typeof value === "boolean") return value ? "true" : "false";
|
||||
if (typeof value === "object") return JSON.stringify(value);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user