@@ -24,7 +24,7 @@ import {
24
24
TypedSimpleChanges
25
25
} from '@hypertrace/common' ;
26
26
import { without } from 'lodash-es' ;
27
- import { BehaviorSubject , combineLatest , Observable } from 'rxjs' ;
27
+ import { BehaviorSubject , combineLatest , merge , Observable , Subject } from 'rxjs' ;
28
28
import { filter , map } from 'rxjs/operators' ;
29
29
import { FilterAttribute } from '../filtering/filter/filter-attribute' ;
30
30
import { PageEvent } from '../paginator/page.event' ;
@@ -144,7 +144,11 @@ import { TableColumnConfigExtended, TableService } from './table.service';
144
144
*cdkRowDef="let row; columns: this.visibleColumnIds$ | async"
145
145
(mouseenter)="this.onDataRowMouseEnter(row)"
146
146
(mouseleave)="this.onDataRowMouseLeave()"
147
- [ngClass]="{ 'selected-row': this.shouldHighlightRowAsSelection(row), 'hovered-row': this.isHoveredRow(row) }"
147
+ [ngClass]="{
148
+ 'selected-row': this.shouldHighlightRowAsSelection(row),
149
+ 'hovered-row': this.isHoveredRow(row),
150
+ selectable: this.supportsRowSelection()
151
+ }"
148
152
class="data-row"
149
153
></cdk-row>
150
154
@@ -168,7 +172,7 @@ import { TableColumnConfigExtended, TableService } from './table.service';
168
172
[style.position]="this.isTableFullPage ? 'fixed' : 'sticky'"
169
173
>
170
174
<ht-paginator
171
- *htLetAsync="this.pagination $ as pagination"
175
+ *htLetAsync="this.currentPage $ as pagination"
172
176
(pageChange)="this.onPageChange($event)"
173
177
[pageSizeOptions]="this.pageSizeOptions"
174
178
[pageSize]="pagination?.pageSize"
@@ -335,9 +339,15 @@ export class TableComponent
335
339
/*
336
340
* Pagination
337
341
*/
338
- public readonly pagination$ : Observable < Partial < PageEvent > | undefined > = this . activatedRoute . queryParamMap . pipe (
339
- map ( params => this . getPagination ( params ) )
340
- ) ;
342
+ // For pushing changes to the page explicitly
343
+ private readonly pageSubject : Subject < Partial < PageEvent > > = new Subject ( ) ;
344
+ // When route, sort or filters change, reset pagination
345
+ public readonly paginationReset$ : Observable < Partial < PageEvent > > = combineLatest ( [
346
+ this . activatedRoute . queryParamMap ,
347
+ this . columnState$ ,
348
+ this . filters$
349
+ ] ) . pipe ( map ( ( [ params ] ) => this . calculateDefaultPagination ( params ) ) ) ;
350
+ public readonly currentPage$ : Observable < Partial < PageEvent > > = merge ( this . pageSubject , this . paginationReset$ ) ;
341
351
342
352
public dataSource ?: TableCdkDataSource ;
343
353
public isTableFullPage : boolean = false ;
@@ -691,11 +701,16 @@ export class TableComponent
691
701
return this . selectionMode === TableSelectionMode . Multiple ;
692
702
}
693
703
704
+ public supportsRowSelection ( ) : boolean {
705
+ return this . hasMultiSelect ( ) || this . hasSingleSelect ( ) ;
706
+ }
707
+
694
708
public isRowExpanded ( row : StatefulTableRow ) : boolean {
695
709
return this . hasExpandableRows ( ) && row . $$state . expanded ;
696
710
}
697
711
698
712
public onPageChange ( pageEvent : PageEvent ) : void {
713
+ this . pageSubject . next ( pageEvent ) ;
699
714
if ( this . syncWithUrl ) {
700
715
this . navigationService . addQueryParametersToUrl ( {
701
716
[ TableComponent . PAGE_INDEX_URL_PARAM ] : pageEvent . pageIndex ,
@@ -711,7 +726,7 @@ export class TableComponent
711
726
this . pageChange . emit ( pageEvent ) ;
712
727
}
713
728
714
- private getPagination ( params : ParamMap ) : Partial < PageEvent > {
729
+ private calculateDefaultPagination ( params : ParamMap ) : Partial < PageEvent > {
715
730
return this . syncWithUrl
716
731
? {
717
732
pageSize : new NumberCoercer ( { defaultValue : this . pageSize } ) . coerce (
0 commit comments