mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Merge remote-tracking branch 'origin/devel' into devel
This commit is contained in:
@@ -13,9 +13,9 @@ import {
|
||||
import { useImperativeHandle } from 'react';
|
||||
import styled, { use } from 'reshadow';
|
||||
|
||||
import { Icon } from '@cloudbeaver/core-blocks';
|
||||
import { Icon, useObjectRef } from '@cloudbeaver/core-blocks';
|
||||
import { useService } from '@cloudbeaver/core-di';
|
||||
import { CommonDialogService } from '@cloudbeaver/core-dialogs';
|
||||
import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs';
|
||||
import { useStyles } from '@cloudbeaver/core-theming';
|
||||
|
||||
import { EditorDialog } from './EditorDialog';
|
||||
@@ -64,33 +64,39 @@ export const InlineEditor = observer<InlineEditorProps, HTMLInputElement | null>
|
||||
onReject,
|
||||
className,
|
||||
}, ref) {
|
||||
const props = useObjectRef({
|
||||
onChange,
|
||||
onReject,
|
||||
onSave,
|
||||
value,
|
||||
});
|
||||
|
||||
const commonDialogService = useService(CommonDialogService);
|
||||
|
||||
const handleChange = useCallback((event: ChangeEvent<HTMLInputElement>| string) => {
|
||||
const newValue = typeof event === 'string' ? event : event.target.value;
|
||||
onChange(newValue);
|
||||
}, [onChange]);
|
||||
const handleChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {
|
||||
props.onChange(event.target.value);
|
||||
}, []);
|
||||
|
||||
const handlePopup = useCallback(async () => {
|
||||
const newValue = await commonDialogService.open(EditorDialog, value);
|
||||
if (typeof newValue === 'string') {
|
||||
handleChange(newValue);
|
||||
onSave();
|
||||
} else if (onReject) {
|
||||
onReject();
|
||||
const newValue = await commonDialogService.open(EditorDialog, props.value);
|
||||
if (newValue === DialogueStateResult.Rejected || newValue === DialogueStateResult.Resolved) {
|
||||
props.onReject?.();
|
||||
} else {
|
||||
props.onChange(newValue);
|
||||
props.onSave();
|
||||
}
|
||||
}, [value, commonDialogService, onSave, onReject, handleChange]);
|
||||
}, []);
|
||||
|
||||
const handleKeyDown = useCallback((event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
switch (event.key) {
|
||||
case 'Enter':
|
||||
onSave();
|
||||
props.onSave();
|
||||
break;
|
||||
case 'Escape':
|
||||
onReject?.();
|
||||
props.onReject?.();
|
||||
break;
|
||||
}
|
||||
}, [onSave, onReject]);
|
||||
}, []);
|
||||
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
|
||||
+1
-7
@@ -62,13 +62,7 @@ export const PublicConnectionForm: React.FC = observer(function PublicConnection
|
||||
const service = useService(PublicConnectionFormService);
|
||||
|
||||
const close = useCallback(() => service.close(), []);
|
||||
const save = useCallback((config: ConnectionConfig) => {
|
||||
if (config.connectionId) {
|
||||
service.change({ connectionId: config.connectionId });
|
||||
} else {
|
||||
service.close(true);
|
||||
}
|
||||
}, []);
|
||||
const save = useCallback(() => service.close(true), []);
|
||||
|
||||
return styled(styles)(
|
||||
<Loader loading={service.dataOptions !== null}>
|
||||
|
||||
@@ -89,8 +89,10 @@ export const CellEditor = observer<Pick<EditorProps<any, any>, 'rowIdx' | 'row'
|
||||
const type = typeof tableDataContext?.getCellValue(rowIdx, column.key) === 'number' ? 'number' : 'text';
|
||||
|
||||
const handleSave = () => {
|
||||
dataGridContext.model.source.getEditor(dataGridContext.resultIndex)
|
||||
.setCell(rowIdx, Number(column.key), Number(value));
|
||||
if (type === 'number') {
|
||||
const editor = dataGridContext.model.source.getEditor(dataGridContext.resultIndex);
|
||||
editor.setCell(rowIdx, Number(column.key), Number(editor.getCell(rowIdx, Number(column.key))));
|
||||
}
|
||||
onClose(false);
|
||||
};
|
||||
const handleReject = () => {
|
||||
|
||||
@@ -69,7 +69,7 @@ export class DatabaseDataEditor<TResult extends IDatabaseDataResult> implements
|
||||
set: this.set.bind(this, result),
|
||||
setCell: this.setCell.bind(this, result),
|
||||
get: this.get.bind(this, result),
|
||||
getCell: this.get.bind(this, result),
|
||||
getCell: this.getCell.bind(this, result),
|
||||
isCellEdited: this.isCellEdited.bind(this, result),
|
||||
isEdited: this.isResultEdited.bind(this, result),
|
||||
isRowEdited: this.isRowEdited.bind(this, result),
|
||||
|
||||
Reference in New Issue
Block a user