|
@ -6,6 +6,7 @@ import { |
|
|
Input, |
|
|
Input, |
|
|
OnChanges, |
|
|
OnChanges, |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
|
|
|
OnInit, |
|
|
Output, |
|
|
Output, |
|
|
ViewChild |
|
|
ViewChild |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
@ -33,7 +34,7 @@ import { Subject, Subscription, distinctUntilChanged, takeUntil } from 'rxjs'; |
|
|
styleUrls: ['./activities-table.component.scss'], |
|
|
styleUrls: ['./activities-table.component.scss'], |
|
|
templateUrl: './activities-table.component.html' |
|
|
templateUrl: './activities-table.component.html' |
|
|
}) |
|
|
}) |
|
|
export class ActivitiesTableComponent implements OnChanges, OnDestroy { |
|
|
export class ActivitiesTableComponent implements OnChanges, OnDestroy, OnInit { |
|
|
@Input() activities: Activity[]; |
|
|
@Input() activities: Activity[]; |
|
|
@Input() baseCurrency: string; |
|
|
@Input() baseCurrency: string; |
|
|
@Input() deviceType: string; |
|
|
@Input() deviceType: string; |
|
@ -89,6 +90,17 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ngOnInit() { |
|
|
|
|
|
if (this.showCheckbox) { |
|
|
|
|
|
this.toggleAllRows(); |
|
|
|
|
|
this.selectedRows.changed |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((selectedRows) => { |
|
|
|
|
|
this.selectedActivities.emit(selectedRows.source.selected); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public areAllRowsSelected() { |
|
|
public areAllRowsSelected() { |
|
|
const numSelectedRows = this.selectedRows.selected.length; |
|
|
const numSelectedRows = this.selectedRows.selected.length; |
|
|
const numTotalRows = this.dataSource.data.length; |
|
|
const numTotalRows = this.dataSource.data.length; |
|
@ -136,19 +148,19 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy { |
|
|
|
|
|
|
|
|
this.dataSource = new MatTableDataSource(this.activities); |
|
|
this.dataSource = new MatTableDataSource(this.activities); |
|
|
this.dataSource.filterPredicate = (data, filter) => { |
|
|
this.dataSource.filterPredicate = (data, filter) => { |
|
|
const dataString = this.getFilterableValues(data) |
|
|
const filterableLabels = this.getFilterableValues(data).map( |
|
|
.map((currentFilter) => { |
|
|
({ label }) => { |
|
|
return currentFilter.label; |
|
|
return label.toLowerCase(); |
|
|
}) |
|
|
} |
|
|
.join(' ') |
|
|
); |
|
|
.toLowerCase(); |
|
|
|
|
|
|
|
|
let includes = true; |
|
|
let contains = true; |
|
|
|
|
|
for (const singleFilter of filter.split(this.SEARCH_STRING_SEPARATOR)) { |
|
|
for (const singleFilter of filter.split(this.SEARCH_STRING_SEPARATOR)) { |
|
|
contains = |
|
|
includes = |
|
|
contains && dataString.includes(singleFilter.trim().toLowerCase()); |
|
|
includes && |
|
|
|
|
|
filterableLabels.includes(singleFilter.trim().toLowerCase()); |
|
|
} |
|
|
} |
|
|
return contains; |
|
|
return includes; |
|
|
}; |
|
|
}; |
|
|
this.dataSource.paginator = this.paginator; |
|
|
this.dataSource.paginator = this.paginator; |
|
|
this.dataSource.sort = this.sort; |
|
|
this.dataSource.sort = this.sort; |
|
@ -158,17 +170,6 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
|
|
if (this.showCheckbox) { |
|
|
|
|
|
this.toggleAllRows(); |
|
|
|
|
|
this.selectedRows.changed |
|
|
|
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
|
|
|
.subscribe((selectedRows) => { |
|
|
|
|
|
this.selectedActivities.emit(selectedRows.source.selected); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onChangePage(page: PageEvent) { |
|
|
public onChangePage(page: PageEvent) { |
|
|
this.pageIndex = page.pageIndex; |
|
|
this.pageIndex = page.pageIndex; |
|
|
|
|
|
|
|
|