mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 19:36:00 +00:00
imrpoved editing data with keyboard #331
This commit is contained in:
@@ -1194,7 +1194,7 @@
|
|||||||
// console.log('event', event.nativeEvent);
|
// console.log('event', event.nativeEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.keyCode == keycodes.f2) {
|
if (event.keyCode == keycodes.f2 || event.keyCode == keycodes.enter) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
dispatchInsplaceEditor({ type: 'show', cell: currentCell, selectAll: true });
|
dispatchInsplaceEditor({ type: 'show', cell: currentCell, selectAll: true });
|
||||||
}
|
}
|
||||||
@@ -1257,8 +1257,10 @@
|
|||||||
if (currentCell[0] == 0) return focusFilterEditor(currentCell[1]);
|
if (currentCell[0] == 0) return focusFilterEditor(currentCell[1]);
|
||||||
return moveCurrentCell(currentCell[0] - 1, currentCell[1], event);
|
return moveCurrentCell(currentCell[0] - 1, currentCell[1], event);
|
||||||
case keycodes.downArrow:
|
case keycodes.downArrow:
|
||||||
case keycodes.enter:
|
|
||||||
return moveCurrentCell(currentCell[0] + 1, currentCell[1], event);
|
return moveCurrentCell(currentCell[0] + 1, currentCell[1], event);
|
||||||
|
case keycodes.enter:
|
||||||
|
if (!grider.editable) return moveCurrentCell(currentCell[0] + 1, currentCell[1], event);
|
||||||
|
break;
|
||||||
case keycodes.leftArrow:
|
case keycodes.leftArrow:
|
||||||
return moveCurrentCell(currentCell[0], currentCell[1] - 1, event);
|
return moveCurrentCell(currentCell[0], currentCell[1] - 1, event);
|
||||||
case keycodes.rightArrow:
|
case keycodes.rightArrow:
|
||||||
@@ -1272,7 +1274,17 @@
|
|||||||
case keycodes.pageDown:
|
case keycodes.pageDown:
|
||||||
return moveCurrentCell(currentCell[0] + visibleRowCountLowerBound, currentCell[1], event);
|
return moveCurrentCell(currentCell[0] + visibleRowCountLowerBound, currentCell[1], event);
|
||||||
case keycodes.tab: {
|
case keycodes.tab: {
|
||||||
if (event.shiftKey) {
|
return moveCurrentCellWithTabKey(event.shiftKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveCurrentCellWithTabKey(isShift) {
|
||||||
|
if (!isRegularCell(currentCell)) return null;
|
||||||
|
|
||||||
|
if (isShift) {
|
||||||
if (currentCell[1] > 0) {
|
if (currentCell[1] > 0) {
|
||||||
return moveCurrentCell(currentCell[0], currentCell[1] - 1, event);
|
return moveCurrentCell(currentCell[0], currentCell[1] - 1, event);
|
||||||
} else {
|
} else {
|
||||||
@@ -1286,10 +1298,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setCellValue(cell, value) {
|
function setCellValue(cell, value) {
|
||||||
grider.setCellValue(cell[0], realColumnUniqueNames[cell[1]], value);
|
grider.setCellValue(cell[0], realColumnUniqueNames[cell[1]], value);
|
||||||
@@ -1431,10 +1439,24 @@
|
|||||||
selectAll: action.selectAll,
|
selectAll: action.selectAll,
|
||||||
};
|
};
|
||||||
case 'close': {
|
case 'close': {
|
||||||
const [row, col] = currentCell || [];
|
|
||||||
if (domFocusField) domFocusField.focus();
|
if (domFocusField) domFocusField.focus();
|
||||||
// @ts-ignore
|
if (action.mode == 'enter' || action.mode == 'tab' || action.mode == 'shiftTab') {
|
||||||
if (action.mode == 'enter' && row) setTimeout(() => moveCurrentCell(row + 1, col), 0);
|
setTimeout(() => {
|
||||||
|
if (isRegularCell(currentCell)) {
|
||||||
|
switch (action.mode) {
|
||||||
|
case 'enter':
|
||||||
|
moveCurrentCell(currentCell[0] + 1, currentCell[1]);
|
||||||
|
break;
|
||||||
|
case 'tab':
|
||||||
|
moveCurrentCellWithTabKey(false);
|
||||||
|
break;
|
||||||
|
case 'shiftTab':
|
||||||
|
moveCurrentCellWithTabKey(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
// if (action.mode == 'save') setTimeout(handleSave, 0);
|
// if (action.mode == 'save') setTimeout(handleSave, 0);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,18 +36,26 @@
|
|||||||
break;
|
break;
|
||||||
case keycodes.enter:
|
case keycodes.enter:
|
||||||
if (isChangedRef.get()) {
|
if (isChangedRef.get()) {
|
||||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
|
||||||
onSetValue(parseCellValue(domEditor.value));
|
onSetValue(parseCellValue(domEditor.value));
|
||||||
isChangedRef.set(false);
|
isChangedRef.set(false);
|
||||||
}
|
}
|
||||||
domEditor.blur();
|
domEditor.blur();
|
||||||
|
event.preventDefault();
|
||||||
dispatchInsplaceEditor({ type: 'close', mode: 'enter' });
|
dispatchInsplaceEditor({ type: 'close', mode: 'enter' });
|
||||||
break;
|
break;
|
||||||
|
case keycodes.tab:
|
||||||
|
if (isChangedRef.get()) {
|
||||||
|
onSetValue(parseCellValue(domEditor.value));
|
||||||
|
isChangedRef.set(false);
|
||||||
|
}
|
||||||
|
domEditor.blur();
|
||||||
|
event.preventDefault();
|
||||||
|
dispatchInsplaceEditor({ type: 'close', mode: event.shiftKey ? 'shiftTab' : 'tab' });
|
||||||
|
break;
|
||||||
case keycodes.s:
|
case keycodes.s:
|
||||||
if (isCtrlOrCommandKey(event)) {
|
if (isCtrlOrCommandKey(event)) {
|
||||||
if (isChangedRef.get()) {
|
if (isChangedRef.get()) {
|
||||||
onSetValue(parseCellValue(domEditor.value));
|
onSetValue(parseCellValue(domEditor.value));
|
||||||
// grider.setCellValue(rowIndex, uniqueName, editor.value);
|
|
||||||
isChangedRef.set(false);
|
isChangedRef.set(false);
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user