Skip to content
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

fix: Do not show Group column for tree-tables #1851

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions __mocks__/dh-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,16 @@ class Table extends DeephavenObject {
}
}

// TreeTable and Table are different in actual implementation, but should be okay for the mock
class TreeTable extends Table {
constructor(props) {
super(props);

const { groupedColumns = [] } = props;
this.groupedColumns = groupedColumns;
}
}

Table.EVENT_CUSTOMCOLUMNSCHANGED = 'customcolumnschanged';
Table.EVENT_FILTERCHANGED = 'filterchanged';
Table.EVENT_ROWADDED = 'rowadded';
Expand Down Expand Up @@ -1991,8 +2001,7 @@ const dh = {
TotalsTableConfig: TotalsTableConfig,
TableViewportSubscription,
TableSubscription,
// TreeTable and Table are different in actual implementation, but should be okay for the mock
TreeTable: Table,
TreeTable: TreeTable,
Column: Column,
RangeSet,
Row: Row,
Expand Down
8 changes: 7 additions & 1 deletion packages/iris-grid/src/IrisGridTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ class IrisGridTestUtils {

makeTreeTable(
columns = this.makeColumns(),
groupedColumns: DhType.Column[] = [],
size = 1000000000,
sort = []
): DhType.TreeTable {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const table = new (this.dh as any).TreeTable({ columns, size, sort });
const table = new (this.dh as any).TreeTable({
columns,
groupedColumns,
size,
sort,
});
table.copy = jest.fn(() => Promise.resolve(table));
return table;
}
Expand Down
29 changes: 29 additions & 0 deletions packages/iris-grid/src/IrisGridTreeTableModel.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import dh from '@deephaven/jsapi-shim';
import IrisGridTestUtils from './IrisGridTestUtils';
import IrisGridTreeTableModel from './IrisGridTreeTableModel';

const irisGridTestUtils = new IrisGridTestUtils(dh);

describe('IrisGridTreeTableModel', () => {
const expectedVirtualColumn = expect.objectContaining({
name: '__DH_UI_GROUP__',
displayName: 'Group',
isProxy: true,
});
const columns = irisGridTestUtils.makeColumns();

test.each([
[0, columns, columns],
[1, columns, columns],
[2, columns, [expectedVirtualColumn, ...columns]],
[columns.length, columns, [expectedVirtualColumn, ...columns]],
])(
`create virtual columns with group length %`,
(groupedLength, allColumns, expected) => {
const groupedColumns = allColumns.slice(0, groupedLength);
const table = irisGridTestUtils.makeTreeTable(allColumns, groupedColumns);
const model = new IrisGridTreeTableModel(dh, table);
expect(model.columns).toEqual(expected);
}
);
});
62 changes: 41 additions & 21 deletions packages/iris-grid/src/IrisGridTreeTableModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,47 @@ class IrisGridTreeTableModel extends IrisGridTableModelTemplate<
inputTable: DhType.InputTable | null = null
) {
super(dh, table, formatter, inputTable);
this.virtualColumns = [
{
name: '__DH_UI_GROUP__',
displayName: 'Group',
type: TableUtils.dataType.STRING,
constituentType: TableUtils.dataType.STRING,
isPartitionColumn: false,
isSortable: false,
isProxy: true,
description: 'Key column',
filter: () => {
throw new Error('Filter not implemented for virtual column');
},
sort: () => {
throw new Error('Sort not implemented virtual column');
},
formatColor: () => {
throw new Error('Color not implemented for virtual column');
},
} as unknown as DisplayColumn,
];
this.virtualColumns =
table.groupedColumns.length > 1
? [
{
name: '__DH_UI_GROUP__',
displayName: 'Group',
type: TableUtils.dataType.STRING,
constituentType: TableUtils.dataType.STRING,
isPartitionColumn: false,
isSortable: false,
isProxy: true,
description: 'Key column',
index: -1,
filter: () => {
throw new Error('Filter not implemented for virtual column');
},
sort: () => {
throw new Error('Sort not implemented virtual column');
},
formatColor: () => {
throw new Error('Color not implemented for virtual column');
},
get: () => {
throw new Error('get not implemented for virtual column');
},
getFormat: () => {
throw new Error('getFormat not implemented for virtual column');
},
formatNumber: () => {
throw new Error(
'formatNumber not implemented for virtual column'
);
},
formatDate: () => {
throw new Error(
'formatDate not implemented for virtual column'
);
},
},
]
: [];
}

applyBufferedViewport(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading