@ -1,5 +1,6 @@
import { SelectionModel } from '@angular/cdk/collections' ;
import {
AfterViewInit ,
ChangeDetectionStrategy ,
Component ,
EventEmitter ,
@ -11,6 +12,7 @@ import {
ViewChild
} from '@angular/core' ;
import { MatPaginator , PageEvent } from '@angular/material/paginator' ;
import { MatSort , Sort , SortDirection } from '@angular/material/sort' ;
import { MatTableDataSource } from '@angular/material/table' ;
import { Router } from '@angular/router' ;
import { Activity } from '@ghostfolio/api/app/order/interfaces/activities.interface' ;
@ -29,7 +31,7 @@ import { Subject, Subscription, takeUntil } from 'rxjs';
templateUrl : './activities-table-lazy.component.html'
} )
export class ActivitiesTableLazyComponent
implements OnChanges, OnDestroy , OnInit
implements AfterViewInit, OnChanges, OnDestroy , OnInit
{
@Input ( ) baseCurrency : string ;
@Input ( ) dataSource : MatTableDataSource < Activity > ;
@ -44,6 +46,8 @@ export class ActivitiesTableLazyComponent
@Input ( ) showCheckbox = false ;
@Input ( ) showFooter = true ;
@Input ( ) showNameColumn = true ;
@Input ( ) sortColumn : string ;
@Input ( ) sortDirection : SortDirection ;
@Input ( ) totalItems = Number . MAX_SAFE_INTEGER ;
@Output ( ) activityDeleted = new EventEmitter < string > ( ) ;
@ -56,8 +60,10 @@ export class ActivitiesTableLazyComponent
@Output ( ) importDividends = new EventEmitter < UniqueAsset > ( ) ;
@Output ( ) pageChanged = new EventEmitter < PageEvent > ( ) ;
@Output ( ) selectedActivities = new EventEmitter < Activity [ ] > ( ) ;
@Output ( ) sortChanged = new EventEmitter < Sort > ( ) ;
@ViewChild ( MatPaginator ) paginator : MatPaginator ;
@ViewChild ( MatSort ) sort : MatSort ;
public defaultDateFormat : string ;
public displayedColumns = [ ] ;
@ -86,6 +92,12 @@ export class ActivitiesTableLazyComponent
}
}
public ngAfterViewInit() {
this . sort . sortChange . subscribe ( ( value : Sort ) = > {
this . sortChanged . emit ( value ) ;
} ) ;
}
public areAllRowsSelected() {
const numSelectedRows = this . selectedRows . selected . length ;
const numTotalRows = this . dataSource . data . length ;