mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 08:13:57 +00:00
filterfocus
This commit is contained in:
@@ -18,10 +18,16 @@
|
|||||||
export let filter;
|
export let filter;
|
||||||
export let setFilter;
|
export let setFilter;
|
||||||
export let showResizeSplitter = false;
|
export let showResizeSplitter = false;
|
||||||
|
export let onFocusGrid;
|
||||||
|
|
||||||
let value;
|
let value;
|
||||||
let isError;
|
let isError;
|
||||||
let isOk;
|
let isOk;
|
||||||
|
let domInput;
|
||||||
|
|
||||||
|
export function focus() {
|
||||||
|
domInput.focus();
|
||||||
|
}
|
||||||
|
|
||||||
function openFilterWindow(condition1) {
|
function openFilterWindow(condition1) {
|
||||||
showModal(SetFilterModal, { condition1, filterType, onFilter: setFilter });
|
showModal(SetFilterModal, { condition1, filterType, onFilter: setFilter });
|
||||||
@@ -136,11 +142,11 @@
|
|||||||
if (ev.keyCode == keycodes.escape) {
|
if (ev.keyCode == keycodes.escape) {
|
||||||
setFilter('');
|
setFilter('');
|
||||||
}
|
}
|
||||||
// if (ev.keyCode == keycodes.downArrow) {
|
if (ev.keyCode == keycodes.downArrow) {
|
||||||
// if (onFocusGrid) onFocusGrid();
|
if (onFocusGrid) onFocusGrid();
|
||||||
// // ev.stopPropagation();
|
// ev.stopPropagation();
|
||||||
// ev.preventDefault();
|
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);
|
||||||
// }
|
// }
|
||||||
@@ -178,6 +184,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyFilter() {
|
function applyFilter() {
|
||||||
|
if ((filter || '') == (value || '')) return;
|
||||||
setFilter(value);
|
setFilter(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +200,7 @@
|
|||||||
on:keydown={handleKeyDown}
|
on:keydown={handleKeyDown}
|
||||||
on:blur={applyFilter}
|
on:blur={applyFilter}
|
||||||
on:paste={handlePaste}
|
on:paste={handlePaste}
|
||||||
|
bind:this={domInput}
|
||||||
class:isError
|
class:isError
|
||||||
class:isOk
|
class:isOk
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -290,6 +290,7 @@
|
|||||||
let shiftDragStartCell = nullCell;
|
let shiftDragStartCell = nullCell;
|
||||||
let autofillDragStartCell = nullCell;
|
let autofillDragStartCell = nullCell;
|
||||||
let autofillSelectedCells = emptyCellArray;
|
let autofillSelectedCells = emptyCellArray;
|
||||||
|
const domFilterControls = {};
|
||||||
|
|
||||||
export function refresh() {
|
export function refresh() {
|
||||||
display.reload();
|
display.reload();
|
||||||
@@ -830,7 +831,7 @@
|
|||||||
} else {
|
} else {
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
case keycodes.upArrow:
|
case keycodes.upArrow:
|
||||||
// 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:
|
case keycodes.enter:
|
||||||
@@ -950,6 +951,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectTopmostCell = uniquePath => {
|
||||||
|
const modelIndex = columns.findIndex(x => x.uniquePath == uniquePath);
|
||||||
|
const realIndex = columnSizes.modelToReal(modelIndex);
|
||||||
|
let cell = [firstVisibleRowScrollIndex, realIndex];
|
||||||
|
// @ts-ignore
|
||||||
|
currentCell = cell;
|
||||||
|
// @ts-ignore
|
||||||
|
selectedCells = [cell];
|
||||||
|
domFocusField.focus();
|
||||||
|
};
|
||||||
|
|
||||||
const [inplaceEditorState, dispatchInsplaceEditor] = createReducer((state, action) => {
|
const [inplaceEditorState, dispatchInsplaceEditor] = createReducer((state, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'show':
|
case 'show':
|
||||||
@@ -977,6 +989,13 @@
|
|||||||
return {};
|
return {};
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
function focusFilterEditor(columnRealIndex) {
|
||||||
|
let modelIndex = columnSizes.realToModel(columnRealIndex);
|
||||||
|
const domFilter = domFilterControls[columns[modelIndex].uniqueName];
|
||||||
|
if (domFilter) domFilter.focus();
|
||||||
|
return ['filter', columnRealIndex];
|
||||||
|
}
|
||||||
|
|
||||||
function createMenu() {
|
function createMenu() {
|
||||||
return [
|
return [
|
||||||
{ command: 'dataGrid.refresh' },
|
{ command: 'dataGrid.refresh' },
|
||||||
@@ -1094,6 +1113,7 @@
|
|||||||
style={`width:${col.width}px; min-width:${col.width}px; max-width:${col.width}px`}
|
style={`width:${col.width}px; min-width:${col.width}px; max-width:${col.width}px`}
|
||||||
>
|
>
|
||||||
<DataFilterControl
|
<DataFilterControl
|
||||||
|
bind:this={domFilterControls[col.uniqueName]}
|
||||||
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)}
|
||||||
@@ -1102,6 +1122,9 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
display.resizeColumn(col.uniqueName, col.width, e.detail);
|
display.resizeColumn(col.uniqueName, col.width, e.detail);
|
||||||
}}
|
}}
|
||||||
|
onFocusGrid={() => {
|
||||||
|
selectTopmostCell(col.uniqueName);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user