mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 17:36:01 +00:00
multiline dialog fixes
This commit is contained in:
@@ -343,7 +343,13 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { GridDisplay } from 'dbgate-datalib';
|
||||
import { driverBase, parseCellValue, detectSqlFilterBehaviour, stringifyCellValue } from 'dbgate-tools';
|
||||
import {
|
||||
driverBase,
|
||||
parseCellValue,
|
||||
detectSqlFilterBehaviour,
|
||||
stringifyCellValue,
|
||||
shouldOpenMultilineDialog,
|
||||
} from 'dbgate-tools';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import _, { map } from 'lodash';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
@@ -397,7 +403,7 @@
|
||||
import { isCtrlOrCommandKey, isMac } from '../utility/common';
|
||||
import { createGeoJsonFromSelection, selectionCouldBeShownOnMap } from '../elements/SelectionMapView.svelte';
|
||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||
import EditCellDataModal, { shouldOpenMultilineDialog } from '../modals/EditCellDataModal.svelte';
|
||||
import EditCellDataModal from '../modals/EditCellDataModal.svelte';
|
||||
import { getDatabaseInfo, useDatabaseStatus } from '../utility/metadataLoaders';
|
||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||
import { openJsonLinesData } from '../utility/openJsonLinesData';
|
||||
@@ -811,7 +817,8 @@
|
||||
const cellData = rowData[realColumnUniqueNames[currentCell[1]]];
|
||||
|
||||
showModal(EditCellDataModal, {
|
||||
value: stringifyCellValue(cellData, 'multilineEditorIntent').value,
|
||||
value: cellData,
|
||||
dataEditorTypesBehaviour: display?.driver?.dataEditorTypesBehaviour,
|
||||
onSave: value => grider.setCellValue(currentCell[0], realColumnUniqueNames[currentCell[1]], value),
|
||||
});
|
||||
}
|
||||
@@ -1246,7 +1253,8 @@
|
||||
const cellData = rowData[realColumnUniqueNames[cell[1]]];
|
||||
if (shouldOpenMultilineDialog(cellData)) {
|
||||
showModal(EditCellDataModal, {
|
||||
value: stringifyCellValue(cellData, 'multilineEditorIntent').value,
|
||||
dataEditorTypesBehaviour: display?.driver?.dataEditorTypesBehaviour,
|
||||
value: cellData,
|
||||
onSave: value => grider.setCellValue(cell[0], realColumnUniqueNames[cell[1]], value),
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -105,7 +105,8 @@
|
||||
dispatchInsplaceEditor({ type: 'close' });
|
||||
|
||||
showModal(EditCellDataModal, {
|
||||
value: stringifyCellValue(cellValue, 'multilineEditorIntent', editorTypes).value,
|
||||
value: cellValue,
|
||||
dataEditorTypesBehaviour: editorTypes,
|
||||
onSave: onSetValue,
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -157,7 +157,7 @@
|
||||
<script lang="ts">
|
||||
import { getFilterValueExpression } from 'dbgate-filterparser';
|
||||
|
||||
import { filterName, stringifyCellValue } from 'dbgate-tools';
|
||||
import { filterName, shouldOpenMultilineDialog, stringifyCellValue } from 'dbgate-tools';
|
||||
|
||||
import _ from 'lodash';
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
import { plusExpandIcon } from '../icons/expandIcons';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import DictionaryLookupModal from '../modals/DictionaryLookupModal.svelte';
|
||||
import EditCellDataModal, { shouldOpenMultilineDialog } from '../modals/EditCellDataModal.svelte';
|
||||
import EditCellDataModal from '../modals/EditCellDataModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import { apiCall } from '../utility/api';
|
||||
|
||||
@@ -490,7 +490,8 @@
|
||||
const cellData = rowData[column.uniqueName];
|
||||
if (shouldOpenMultilineDialog(cellData)) {
|
||||
showModal(EditCellDataModal, {
|
||||
value: stringifyCellValue(cellData, 'multilineEditorIntent').value,
|
||||
value: cellData,
|
||||
dataEditorTypesBehaviour: display?.driver?.dataEditorTypesBehaviour,
|
||||
onSave: value => grider.setCellValue(0, column.uniqueName, value),
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -1,27 +1,3 @@
|
||||
<script lang="ts" context="module">
|
||||
export function shouldOpenMultilineDialog(value) {
|
||||
if (_.isString(value)) {
|
||||
if (value.includes('\n')) {
|
||||
return true;
|
||||
}
|
||||
const parsed = safeJsonParse(value);
|
||||
if (parsed && (_.isPlainObject(parsed) || _.isArray(parsed))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (value?.$oid) {
|
||||
return false;
|
||||
}
|
||||
if (value?.$date) {
|
||||
return false;
|
||||
}
|
||||
if (_.isPlainObject(value) || _.isArray(value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
@@ -34,17 +10,20 @@
|
||||
import ModalBase from './ModalBase.svelte';
|
||||
import { closeCurrentModal, showModal } from './modalTools';
|
||||
import SelectField from '../forms/SelectField.svelte';
|
||||
import { safeJsonParse } from 'dbgate-tools';
|
||||
import { parseCellValue, safeJsonParse, stringifyCellValue } from 'dbgate-tools';
|
||||
import { showSnackbarError } from '../utility/snackbar';
|
||||
import ErrorMessageModal from './ErrorMessageModal.svelte';
|
||||
import da from 'date-fns/locale/da';
|
||||
|
||||
export let onSave;
|
||||
export let value;
|
||||
|
||||
export let dataEditorTypesBehaviour;
|
||||
|
||||
let editor;
|
||||
let syntaxMode = 'text';
|
||||
|
||||
let textValue = value?.toString() || '';
|
||||
let textValue = stringifyCellValue(value, 'multilineEditorIntent', dataEditorTypesBehaviour).value;
|
||||
|
||||
onMount(() => {
|
||||
editor.getEditor().focus();
|
||||
@@ -61,7 +40,7 @@
|
||||
|
||||
function handleKeyDown(ev) {
|
||||
if (ev.keyCode == keycodes.enter && ev.ctrlKey) {
|
||||
onSave(textValue);
|
||||
onSave(parseCellValue(textValue, dataEditorTypesBehaviour));
|
||||
closeCurrentModal();
|
||||
}
|
||||
}
|
||||
@@ -90,7 +69,7 @@
|
||||
value="OK"
|
||||
title="Ctrl+Enter"
|
||||
on:click={() => {
|
||||
onSave(textValue);
|
||||
onSave(parseCellValue(textValue, dataEditorTypesBehaviour));
|
||||
closeCurrentModal();
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user