fix(plugin-data-spreadsheet): CB-527 cell editing

This commit is contained in:
Wroud
2020-11-24 21:11:20 +03:00
parent 5e6334d0b5
commit 90f6df3de9
3 changed files with 22 additions and 4 deletions
@@ -20,7 +20,8 @@ import {
GridOptions,
CellClassParams,
SortChangedEvent,
RowNode
RowNode,
CellEditingStoppedEvent
} from '@ag-grid-community/core';
import { injectable, IInitializableController, IDestructibleController } from '@cloudbeaver/core-di';
import {
@@ -75,6 +76,7 @@ export class AgGridTableController implements IInitializableController, IDestruc
onBodyScroll: this.handleBodyScroll.bind(this),
onSortChanged: this.handleSortChanged.bind(this),
onCellEditingStopped: this.handleCellEditingStopped.bind(this),
};
@observable columns: ColDef[] = [];
@@ -129,7 +131,6 @@ export class AgGridTableController implements IInitializableController, IDestruc
startRow,
endRow,
successCallback,
sortModel,
failCallback,
} = params;
@@ -232,6 +233,10 @@ export class AgGridTableController implements IInitializableController, IDestruc
}
}
private handleCellEditingStopped(event: CellEditingStoppedEvent) {
this.gridModel.onCellEditingStopped(event.rowIndex, event.column.getId(), event.value, false);
}
/* Actions */
private resetData(): void {
@@ -50,8 +50,6 @@ export const PlainTextEditor = forwardRef<Partial<ICellEditorComp>, ICellEditorP
getValue: () => value.current,
}), []);
useEffect(() => inputRef.current?.focus(), []);
const context: AgGridContext = props.context;
const handleSave = useCallback(() => props.stopEditing(), [props.stopEditing]);
@@ -75,6 +73,14 @@ export const PlainTextEditor = forwardRef<Partial<ICellEditorComp>, ICellEditorP
forceUpdate(value.current);
}, []);
useEffect(() => {
inputRef.current?.focus();
if (initValue !== props.value) {
handleChange(initValue);
}
}, []);
const isLastColumn = props.columnApi?.getAllGridColumns().slice(-1)[0] === props.column;
const isLastRow = props.rowIndex > 0 && ((props.api?.getInfiniteRowCount() || -1) - 1 === props.rowIndex);
let controlsPosition: InlineEditorControls = 'right';