mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 02:43:59 +00:00
#39 navigation between grid and filters
This commit is contained in:
@@ -166,7 +166,14 @@ function DropDownContent({ filterType, setFilter, filterMultipleValues, openFilt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DataFilterControl({ isReadOnly = false, filterType, filter, setFilter }) {
|
export default function DataFilterControl({
|
||||||
|
isReadOnly = false,
|
||||||
|
filterType,
|
||||||
|
filter,
|
||||||
|
setFilter,
|
||||||
|
focusIndex,
|
||||||
|
onFocusGrid,
|
||||||
|
}) {
|
||||||
const showModal = useShowModal();
|
const showModal = useShowModal();
|
||||||
const [filterState, setFilterState] = React.useState('empty');
|
const [filterState, setFilterState] = React.useState('empty');
|
||||||
const setFilterText = (filter) => {
|
const setFilterText = (filter) => {
|
||||||
@@ -199,6 +206,10 @@ export default function DataFilterControl({ isReadOnly = false, filterType, filt
|
|||||||
const buttonRef = React.useRef();
|
const buttonRef = React.useRef();
|
||||||
const editorRef = React.useRef();
|
const editorRef = React.useRef();
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (focusIndex) editorRef.current.focus();
|
||||||
|
}, [focusIndex]);
|
||||||
|
|
||||||
const handleKeyDown = (ev) => {
|
const handleKeyDown = (ev) => {
|
||||||
if (isReadOnly) return;
|
if (isReadOnly) return;
|
||||||
if (ev.keyCode == keycodes.enter) {
|
if (ev.keyCode == keycodes.enter) {
|
||||||
@@ -207,6 +218,11 @@ export default function DataFilterControl({ isReadOnly = false, filterType, filt
|
|||||||
if (ev.keyCode == keycodes.escape) {
|
if (ev.keyCode == keycodes.escape) {
|
||||||
setFilterText('');
|
setFilterText('');
|
||||||
}
|
}
|
||||||
|
if (ev.keyCode == keycodes.downArrow) {
|
||||||
|
onFocusGrid();
|
||||||
|
// ev.stopPropagation();
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
// if (ev.keyCode == KeyCodes.DownArrow || ev.keyCode == KeyCodes.UpArrow) {
|
// if (ev.keyCode == KeyCodes.DownArrow || ev.keyCode == KeyCodes.UpArrow) {
|
||||||
// if (this.props.onControlKey) this.props.onControlKey(ev.keyCode);
|
// if (this.props.onControlKey) this.props.onControlKey(ev.keyCode);
|
||||||
// }
|
// }
|
||||||
@@ -272,6 +288,7 @@ export default function DataFilterControl({ isReadOnly = false, filterType, filt
|
|||||||
state={filterState}
|
state={filterState}
|
||||||
onBlur={applyFilter}
|
onBlur={applyFilter}
|
||||||
onPaste={handlePaste}
|
onPaste={handlePaste}
|
||||||
|
autocomplete="off"
|
||||||
/>
|
/>
|
||||||
<InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square>
|
<InlineButton buttonRef={buttonRef} onClick={handleShowMenu} square>
|
||||||
<i className="fas fa-filter" />
|
<i className="fas fa-filter" />
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ export default function DataGridCore(props) {
|
|||||||
const { isLoading, loadedRows, isLoadedAll, loadedTime, allRowCount, errorMessage } = loadProps;
|
const { isLoading, loadedRows, isLoadedAll, loadedTime, allRowCount, errorMessage } = loadProps;
|
||||||
|
|
||||||
const loadedTimeRef = React.useRef(0);
|
const loadedTimeRef = React.useRef(0);
|
||||||
const focusFieldRef = React.useRef();
|
const focusFieldRef = React.useRef(null);
|
||||||
|
|
||||||
const [vScrollValueToSet, setvScrollValueToSet] = React.useState();
|
const [vScrollValueToSet, setvScrollValueToSet] = React.useState();
|
||||||
const [vScrollValueToSetDate, setvScrollValueToSetDate] = React.useState(new Date());
|
const [vScrollValueToSetDate, setvScrollValueToSetDate] = React.useState(new Date());
|
||||||
@@ -230,6 +230,7 @@ export default function DataGridCore(props) {
|
|||||||
const [shiftDragStartCell, setShiftDragStartCell] = React.useState(nullCell);
|
const [shiftDragStartCell, setShiftDragStartCell] = React.useState(nullCell);
|
||||||
const [autofillDragStartCell, setAutofillDragStartCell] = React.useState(nullCell);
|
const [autofillDragStartCell, setAutofillDragStartCell] = React.useState(nullCell);
|
||||||
const [autofillSelectedCells, setAutofillSelectedCells] = React.useState(emptyCellArray);
|
const [autofillSelectedCells, setAutofillSelectedCells] = React.useState(emptyCellArray);
|
||||||
|
const [focusFilterInputs, setFocusFilterInputs] = React.useState({});
|
||||||
|
|
||||||
// const [inplaceEditorCell, setInplaceEditorCell] = React.useState(nullCell);
|
// const [inplaceEditorCell, setInplaceEditorCell] = React.useState(nullCell);
|
||||||
// const [inplaceEditorInitText, setInplaceEditorInitText] = React.useState('');
|
// const [inplaceEditorInitText, setInplaceEditorInitText] = React.useState('');
|
||||||
@@ -333,7 +334,6 @@ export default function DataGridCore(props) {
|
|||||||
};
|
};
|
||||||
case 'close': {
|
case 'close': {
|
||||||
const [row, col] = currentCell || [];
|
const [row, col] = currentCell || [];
|
||||||
// @ts-ignore
|
|
||||||
if (focusFieldRef.current) focusFieldRef.current.focus();
|
if (focusFieldRef.current) focusFieldRef.current.focus();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (action.mode == 'enter' && row) setTimeout(() => moveCurrentCell(row + 1, col), 0);
|
if (action.mode == 'enter' && row) setTimeout(() => moveCurrentCell(row + 1, col), 0);
|
||||||
@@ -412,7 +412,6 @@ export default function DataGridCore(props) {
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (tabVisible) {
|
if (tabVisible) {
|
||||||
// @ts-ignore
|
|
||||||
if (focusFieldRef.current) focusFieldRef.current.focus();
|
if (focusFieldRef.current) focusFieldRef.current.focus();
|
||||||
}
|
}
|
||||||
}, [tabVisible, focusFieldRef.current]);
|
}, [tabVisible, focusFieldRef.current]);
|
||||||
@@ -572,7 +571,6 @@ export default function DataGridCore(props) {
|
|||||||
|
|
||||||
// event.target.closest('table').focus();
|
// event.target.closest('table').focus();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// @ts-ignore
|
|
||||||
if (focusFieldRef.current) focusFieldRef.current.focus();
|
if (focusFieldRef.current) focusFieldRef.current.focus();
|
||||||
const cell = cellFromEvent(event);
|
const cell = cellFromEvent(event);
|
||||||
|
|
||||||
@@ -930,6 +928,17 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectTopmostCell = (uniquePath) => {
|
||||||
|
const modelIndex = columns.findIndex((x) => x.uniquePath == uniquePath);
|
||||||
|
const realIndex = columnSizes.modelToReal(modelIndex);
|
||||||
|
let cell = [firstVisibleRowScrollIndex, realIndex];
|
||||||
|
// @ts-ignore
|
||||||
|
setCurrentCell(cell);
|
||||||
|
// @ts-ignore
|
||||||
|
setSelectedCells([cell]);
|
||||||
|
focusFieldRef.current.focus();
|
||||||
|
};
|
||||||
|
|
||||||
function handleGridKeyDown(event) {
|
function handleGridKeyDown(event) {
|
||||||
if (event.keyCode == keycodes.f5) {
|
if (event.keyCode == keycodes.f5) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1072,7 +1081,11 @@ export default function DataGridCore(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function focusFilterEditor(columnRealIndex) {
|
function focusFilterEditor(columnRealIndex) {
|
||||||
// let modelIndex = this.columnSizes.realToModel(columnRealIndex);
|
let modelIndex = columnSizes.realToModel(columnRealIndex);
|
||||||
|
setFocusFilterInputs((cols) => ({
|
||||||
|
...cols,
|
||||||
|
[columns[modelIndex].uniqueName]: (cols[columns[modelIndex].uniqueName] || 0) + 1,
|
||||||
|
}));
|
||||||
// this.headerFilters[this.columns[modelIndex].uniquePath].focus();
|
// this.headerFilters[this.columns[modelIndex].uniquePath].focus();
|
||||||
return ['filter', columnRealIndex];
|
return ['filter', columnRealIndex];
|
||||||
}
|
}
|
||||||
@@ -1230,6 +1243,11 @@ export default function DataGridCore(props) {
|
|||||||
filterType={getFilterType(col.dataType)}
|
filterType={getFilterType(col.dataType)}
|
||||||
filter={display.getFilter(col.uniqueName)}
|
filter={display.getFilter(col.uniqueName)}
|
||||||
setFilter={(value) => display.setFilter(col.uniqueName, value)}
|
setFilter={(value) => display.setFilter(col.uniqueName, value)}
|
||||||
|
focusIndex={focusFilterInputs[col.uniqueName]}
|
||||||
|
onFocusGrid={() => {
|
||||||
|
selectTopmostCell(col.uniqueName);
|
||||||
|
// focusFieldRef.current.focus();
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</TableFilterCell>
|
</TableFilterCell>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user