Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TableRowState } from '../../table-api';
import { StatefulTableRow, TableRowState } from '../../table-api';
import { TableCellParser } from '../table-cell-parser';
import { TableCellParserBase } from '../table-cell-parser-base';
import { CoreTableCellParserType } from '../types/core-table-cell-parser-type';
Expand All @@ -7,8 +7,8 @@ import { CoreTableCellParserType } from '../types/core-table-cell-parser-type';
type: CoreTableCellParserType.State
})
export class TableCellStateParser extends TableCellParserBase<TableRowState, TableRowState, undefined> {
public parseValue(cellData: TableRowState): TableRowState {
return cellData;
public parseValue(_: TableRowState, rowData: StatefulTableRow): TableRowState {
return rowData.$$state;
}

public parseFilterValue(): undefined {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const enum CoreTableCellParserType {
State = 'state',
Boolean = 'boolean',
Number = 'number',
State = 'state',
String = 'string',
Timestamp = 'timestamp',
Icon = 'icon',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class TableCdkDataSource implements DataSource<TableRow> {
.pipe(
tap(() => this.loadingStateSubject.next({ loading$: NEVER })),
/**
* Below debouce is needed to handle multiple emission from buildChangeObservable.
* Below debounce is needed to handle multiple emission from buildChangeObservable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is the real reason for the PR and all this other stuff is just because you were working in the area.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Totally

*/
debounceTime(100),
mergeMap(([columnConfigs, pageEvent, filters, queryProperties, changedColumn, changedRow]) =>
Expand Down
11 changes: 8 additions & 3 deletions projects/components/src/table/table.component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe('Table component', () => {
expectObservable(spectator.component.columnConfigs$).toBe('x', {
x: [
expect.objectContaining({
id: '$$state',
id: '$$selected',
display: CoreTableCellRendererType.Checkbox,
visible: true
}),
Expand Down Expand Up @@ -371,16 +371,21 @@ describe('Table component', () => {
map(columnConfigs => columnConfigs.map(columnConfig => spectator.component.isExpanderColumn(columnConfig)))
)
).toBe('x', {
x: [true, false, false]
x: [true, false, false, false]
});

expectObservable(spectator.component.columnConfigs$).toBe('x', {
x: [
expect.objectContaining({
id: '$$state',
id: '$$expanded',
display: CoreTableCellRendererType.RowExpander,
visible: true
}),
expect.objectContaining({
id: '$$selected',
display: CoreTableCellRendererType.Checkbox,
visible: true
}),
expect.objectContaining({
id: 'firstId'
}),
Expand Down
18 changes: 11 additions & 7 deletions projects/components/src/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ export class TableComponent
private static readonly SORT_DIRECTION_URL_PARAM: string = 'sort-direction';

private readonly expandableToggleColumnConfig: TableColumnConfig = {
id: '$$state',
id: '$$expanded',
width: '32px',
visible: true,
display: CoreTableCellRendererType.RowExpander,
onClick: (row: StatefulTableRow) => this.toggleRowExpanded(row)
};

private readonly multiSelectRowColumnConfig: TableColumnConfig = {
id: '$$state',
id: '$$selected',
width: '32px',
visible: true,
display: CoreTableCellRendererType.Checkbox,
Expand Down Expand Up @@ -569,11 +569,15 @@ export class TableComponent
}

private buildColumnConfigExtendeds(columnConfigs: TableColumnConfig[]): TableColumnConfigExtended[] {
const stateColumns = this.hasExpandableRows()
? [this.expandableToggleColumnConfig]
: this.hasMultiSelect()
? [this.multiSelectRowColumnConfig]
: [];
const stateColumns = [];

if (this.hasExpandableRows()) {
stateColumns.push(this.expandableToggleColumnConfig);
}

if (this.hasMultiSelect()) {
stateColumns.push(this.multiSelectRowColumnConfig);
}

return this.tableService.buildExtendedColumnConfigs(
[...stateColumns, ...columnConfigs],
Expand Down