From 4cbfa7c937a05447c0523c6d51640b4c9b2e3dc7 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Mon, 26 Aug 2024 09:32:28 +0200 Subject: [PATCH] fixes --- packages/tools/src/stringTools.ts | 40 +++++++++---------- packages/web/src/datagrid/DataGridCell.svelte | 3 -- packages/web/src/datagrid/DataGridCore.svelte | 6 +-- packages/web/src/formview/FormView.svelte | 4 +- .../web/src/modals/EditCellDataModal.svelte | 9 +++++ 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/packages/tools/src/stringTools.ts b/packages/tools/src/stringTools.ts index 3b93522d..f2eeacff 100644 --- a/packages/tools/src/stringTools.ts +++ b/packages/tools/src/stringTools.ts @@ -150,7 +150,7 @@ export function stringifyCellValue( if (value === true) return { value: 'true', gridStyle: 'valueCellStyle' }; if (value === false) return { value: 'false', gridStyle: 'valueCellStyle' }; - + if (editorTypes?.parseHexAsBuffer) { if (value?.type == 'Buffer' && _isArray(value.data)) { return { value: '0x' + arrayToHexString(value.data), gridStyle: 'valueCellStyle' }; @@ -167,28 +167,26 @@ export function stringifyCellValue( } } } - if (editorTypes?.parseJsonArray) { - if (_isArray(value)) { - switch (intent) { - case 'gridCellIntent': - return stringifyJsonToGrid(value); - case 'multilineEditorIntent': - return { value: JSON.stringify(value) }; - default: - return { value: JSON.stringify(value, null, 2), gridStyle: 'valueCellStyle' }; - } + + if (_isArray(value)) { + switch (intent) { + case 'gridCellIntent': + return stringifyJsonToGrid(value); + case 'multilineEditorIntent': + return { value: JSON.stringify(value, null, 2) }; + default: + return { value: JSON.stringify(value), gridStyle: 'valueCellStyle' }; } } - if (editorTypes?.parseJsonObject) { - if (_isPlainObject(value)) { - switch (intent) { - case 'gridCellIntent': - return stringifyJsonToGrid(value); - case 'multilineEditorIntent': - return { value: JSON.stringify(value) }; - default: - return { value: JSON.stringify(value, null, 2), gridStyle: 'valueCellStyle' }; - } + + if (_isPlainObject(value)) { + switch (intent) { + case 'gridCellIntent': + return stringifyJsonToGrid(value); + case 'multilineEditorIntent': + return { value: JSON.stringify(value, null, 2) }; + default: + return { value: JSON.stringify(value), gridStyle: 'valueCellStyle' }; } } diff --git a/packages/web/src/datagrid/DataGridCell.svelte b/packages/web/src/datagrid/DataGridCell.svelte index f6d9b80e..54825b54 100644 --- a/packages/web/src/datagrid/DataGridCell.svelte +++ b/packages/web/src/datagrid/DataGridCell.svelte @@ -3,10 +3,7 @@ import ShowFormButton from '../formview/ShowFormButton.svelte'; import { detectTypeIcon, getConvertValueMenu, isJsonLikeLongString, safeJsonParse } from 'dbgate-tools'; import { openJsonDocument } from '../tabs/JsonTab.svelte'; - import openNewTab from '../utility/openNewTab'; import CellValue from './CellValue.svelte'; - import { showModal } from '../modals/modalTools'; - import EditCellDataModal from '../modals/EditCellDataModal.svelte'; import { openJsonLinesData } from '../utility/openJsonLinesData'; import ShowFormDropDownButton from '../formview/ShowFormDropDownButton.svelte'; diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index fc503172..c8a63795 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -343,7 +343,7 @@