mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
revert row changes command
This commit is contained in:
parent
03550f1d27
commit
54976ca21f
@ -179,3 +179,13 @@ export function changeSetToSql(changeSet: ChangeSet): Command[] {
|
|||||||
...changeSet.deletes.map(deleteToSql),
|
...changeSet.deletes.map(deleteToSql),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function revertChangeSetRowChanges(changeSet: ChangeSet, definition: ChangeSetRowDefinition): ChangeSet {
|
||||||
|
const [field, item] = findExistingChangeSetItem(changeSet, definition);
|
||||||
|
if (item)
|
||||||
|
return {
|
||||||
|
...changeSet,
|
||||||
|
[field]: changeSet[field].filter(x => x != item),
|
||||||
|
};
|
||||||
|
return changeSet;
|
||||||
|
}
|
||||||
|
@ -26,7 +26,7 @@ import DataGridRow from './DataGridRow';
|
|||||||
import { countColumnSizes, countVisibleRealColumns } from './gridutil';
|
import { countColumnSizes, countVisibleRealColumns } from './gridutil';
|
||||||
import useModalState from '../modals/useModalState';
|
import useModalState from '../modals/useModalState';
|
||||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal';
|
import ConfirmSqlModal from '../modals/ConfirmSqlModal';
|
||||||
import { changeSetToSql, createChangeSet } from '@dbgate/datalib';
|
import { changeSetToSql, createChangeSet, revertChangeSetRowChanges } from '@dbgate/datalib';
|
||||||
import { scriptToSql } from '@dbgate/sqltree';
|
import { scriptToSql } from '@dbgate/sqltree';
|
||||||
import { sleep } from '../utility/common';
|
import { sleep } from '../utility/common';
|
||||||
|
|
||||||
@ -327,6 +327,12 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function revertRowChanges() {
|
||||||
|
if (loadedRows && currentCell && loadedRows[currentCell[0]]) {
|
||||||
|
setChangeSet(revertChangeSetRowChanges(changeSet, display.getChangeSetRow(loadedRows[currentCell[0]])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleGridWheel(event) {
|
function handleGridWheel(event) {
|
||||||
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex;
|
let newFirstVisibleRowScrollIndex = firstVisibleRowScrollIndex;
|
||||||
if (event.deltaY > 0) {
|
if (event.deltaY > 0) {
|
||||||
@ -391,7 +397,7 @@ export default function DataGridCore(props) {
|
|||||||
|
|
||||||
if (event.keyCode == keycodes.r && event.ctrlKey) {
|
if (event.keyCode == keycodes.r && event.ctrlKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// revertRowChanges();
|
revertRowChanges();
|
||||||
// this.saveAndFocus();
|
// this.saveAndFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user