-
Notifications
You must be signed in to change notification settings - Fork 495
[CB] Ability to pin column in the Data Editor #3794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
[CB] Ability to pin column in the Data Editor #3794
Conversation
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx
Show resolved
Hide resolved
| focusSyncRef.current = { colIdx, rowIdx }; | ||
|
|
||
| this.selectCell({ colIdx, rowIdx }); | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in use anywhere. Only in the deleted piece below, so I removed it also
webapp/packages/plugin-data-spreadsheet-new/src/DataGrid/DataGridTable.tsx
Show resolved
Hide resolved
| const [dragOverElement, setDragOverElement] = useState<[number, boolean] | null>(null); | ||
|
|
||
| function getDataColIdxByKey(key: string) { | ||
| const columnIndex = columns.filter(isColumn).findIndex(col => col.key === key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const columnIndex = columns.filter(isColumn).findIndex(col => col.key === key); | |
| const columnIndex = columns.findIndex(col => isColumn(col) && col.key === key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway this part probably will be changed if we will start using column groups
| model: IDatabaseDataModel; | ||
| actions: IDataTableActions; | ||
| spreadsheetActions: IDataPresentationActions<IGridDataKey>; | ||
| spreadsheetActions: IDataPresentationActions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
| edit: (key: TKey) => void; | ||
| import type { IGridColumnKey, IGridDataKey } from '../DatabaseDataModel/Actions/Grid/IGridDataKey.js'; | ||
|
|
||
| export interface IDataPresentationActions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep generics
| const columns = new Array<ColumnOrColumnGroup<IInnerRow, unknown>>(columnsCount) | ||
| .fill(null as any) | ||
| .map((_, i): ColumnOrColumnGroup<IInnerRow, unknown> => { | ||
| const width = getHeaderWidth?.(i) ?? 'max-content'; | ||
| return { | ||
| key: getColumnKey?.(i) ?? String(i), | ||
| name: '', | ||
| resizable: getHeaderResizable?.(i) ?? true, | ||
| width, | ||
| minWidth: 26, | ||
| editable: row => getCellEditable?.(row.idx, i) ?? false, | ||
| frozen: getHeaderPinned?.(i), | ||
| renderHeaderCell: mapRenderHeaderCell(i), | ||
| renderCell: mapCellContentRenderer(i), | ||
| renderEditCell: mapEditCellRenderer(i), | ||
| }; | ||
| }); | ||
| const columns = new Array<ColumnOrColumnGroup<IInnerRow, unknown>>(columnsCount).fill(null as any).map((_, i) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
| renderEditCell: mapEditCellRenderer(i), | ||
| } as Column<IInnerRow, unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
| pinColumn, | ||
| unpinColumn, | ||
| isColumnPinned, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will suggest using a different context for pinned columns, because right now every pin will trigger the rerender of all subscribers of the IDataGridContext
| import { createAction } from '@cloudbeaver/core-view'; | ||
|
|
||
| export const ACTION_DATA_GRID_PIN_COLUMN = createAction('data-grid-pin-column', { | ||
| label: 'data_grid_table_pin_column', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use proper localization key started with plugin's name as prefix: plugin_data_spreadsheet_new_
| if (action === ACTION_DATA_GRID_PIN_COLUMN) { | ||
| return { ...action.info, label: 'data_grid_table_pin_column' }; | ||
| } | ||
|
|
||
| if (action === ACTION_DATA_GRID_UNPIN_COLUMN) { | ||
| return { ...action.info, label: 'data_grid_table_unpin_column' }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably you don't need this
closes https://github.com/dbeaver/pro/issues/6859
Changes:
columnIdlogic. Now we have two types of IDs.Visual column idrepresents the column number on the screen. AnddataColIdx, which means the column index in the initial columns array provided to the data gridvisual column ID, some need to usedataColIdx. So used it respectively where required