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',
category: 'Data grid',
name: 'Filter selected value',
keyText: 'Ctrl+F',
keyText: 'Ctrl+Shift+F',
testEnabled: () => getCurrentDataGrid()?.getDisplay().filterable,
onClick: () => getCurrentDataGrid().filterSelectedValue(),
});
registerCommand({
id: 'dataGrid.findColumn',
category: 'Data grid',
name: 'Find colunn',
keyText: 'Ctrl+F',
testEnabled: () => getCurrentDataGrid() != null,
getSubCommands: () => getCurrentDataGrid().buildFindMenu(),
});
registerCommand({
id: 'dataGrid.clearFilter',
category: 'Data grid',
@ -347,6 +356,7 @@
});
const text = lines.join('\r\n');
copyTextToClipboard(text);
if (domFocusField) domFocusField.focus();
}
export function loadNextDataIfNeeded() {
@ -416,6 +426,25 @@
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 =
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1
? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))]
@ -927,7 +956,7 @@
currentCell = cell;
// @ts-ignore
selectedCells = [cell];
domFocusField.focus();
if (domFocusField) domFocusField.focus();
};
const [inplaceEditorState, dispatchInsplaceEditor] = createReducer((state, action) => {

View File

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