find column menu

This commit is contained in:
Jan Prochazka 2021-10-12 21:27:05 +02:00
parent b551db8774
commit beef215394
2 changed files with 32 additions and 3 deletions

View File

@ -111,11 +111,20 @@
id: 'dataGrid.filterSelected', id: 'dataGrid.filterSelected',
category: 'Data grid', category: 'Data grid',
name: 'Filter selected value', name: 'Filter selected value',
keyText: 'Ctrl+F', keyText: 'Ctrl+Shift+F',
testEnabled: () => getCurrentDataGrid()?.getDisplay().filterable, testEnabled: () => getCurrentDataGrid()?.getDisplay().filterable,
onClick: () => getCurrentDataGrid().filterSelectedValue(), onClick: () => getCurrentDataGrid().filterSelectedValue(),
}); });
registerCommand({
id: 'dataGrid.findColumn',
category: 'Data grid',
name: 'Find colunn',
keyText: 'Ctrl+F',
testEnabled: () => getCurrentDataGrid() != null,
getSubCommands: () => getCurrentDataGrid().buildFindMenu(),
});
registerCommand({ registerCommand({
id: 'dataGrid.clearFilter', id: 'dataGrid.clearFilter',
category: 'Data grid', category: 'Data grid',
@ -347,6 +356,7 @@
}); });
const text = lines.join('\r\n'); const text = lines.join('\r\n');
copyTextToClipboard(text); copyTextToClipboard(text);
if (domFocusField) domFocusField.focus();
} }
export function loadNextDataIfNeeded() { export function loadNextDataIfNeeded() {
@ -416,6 +426,25 @@
editJsonRowDocument(grider, rowIndex); editJsonRowDocument(grider, rowIndex);
} }
export function buildFindMenu() {
const res = [];
for (const column of display.columns) {
if (column.uniquePath.length > 1) continue;
res.push({
text: column.columnName,
onClick: async () => {
const invMap = _.invert(realColumnUniqueNames);
const colIndex = invMap[column.uniqueName];
scrollIntoView([null, colIndex]);
currentCell = [currentCell[0], parseInt(colIndex)];
selectedCells = [currentCell];
},
});
}
return res;
}
$: autofillMarkerCell = $: autofillMarkerCell =
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1 selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1
? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))] ? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))]
@ -927,7 +956,7 @@
currentCell = cell; currentCell = cell;
// @ts-ignore // @ts-ignore
selectedCells = [cell]; selectedCells = [cell];
domFocusField.focus(); if (domFocusField) domFocusField.focus();
}; };
const [inplaceEditorState, dispatchInsplaceEditor] = createReducer((state, action) => { const [inplaceEditorState, dispatchInsplaceEditor] = createReducer((state, action) => {

View File

@ -88,7 +88,7 @@
id: 'dataForm.filterSelected', id: 'dataForm.filterSelected',
category: 'Data form', category: 'Data form',
name: 'Filter this value', name: 'Filter this value',
keyText: 'Ctrl+F', keyText: 'Ctrl+Shift+F',
testEnabled: () => getCurrentDataForm() != null, testEnabled: () => getCurrentDataForm() != null,
onClick: () => getCurrentDataForm().filterSelectedValue(), onClick: () => getCurrentDataForm().filterSelectedValue(),
}); });