build: Use prettier for typescript
Stop ignoring .ts files in prettier and fix existing issues.
This commit is contained in:
@@ -14,13 +14,16 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
styleUrls: ['./reports.component.scss']
|
||||
})
|
||||
export class ReportsComponent implements OnInit {
|
||||
|
||||
/** Reports data. */
|
||||
reportsData: any;
|
||||
/** Report category filter. */
|
||||
filter: string;
|
||||
/** Columns to be displayed in reports table. */
|
||||
displayedColumns: string[] = ['reportName', 'reportType', 'reportCategory'];
|
||||
displayedColumns: string[] = [
|
||||
'reportName',
|
||||
'reportType',
|
||||
'reportCategory'
|
||||
];
|
||||
/** Data source for reports table. */
|
||||
dataSource = new MatTableDataSource();
|
||||
|
||||
@@ -35,10 +38,12 @@ export class ReportsComponent implements OnInit {
|
||||
* Prevents reuse of route parameter `filter`.
|
||||
* @param {Router} router: Router.
|
||||
*/
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
) {
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.route.data.subscribe(( data: { reports: any }) => {
|
||||
this.route.data.subscribe((data: { reports: any }) => {
|
||||
this.reportsData = data.reports;
|
||||
});
|
||||
this.filter = this.route.snapshot.params['filter'];
|
||||
@@ -58,8 +63,8 @@ export class ReportsComponent implements OnInit {
|
||||
*/
|
||||
applyFilter(filterValue: string) {
|
||||
if (filterValue.length) {
|
||||
this.setCustomFilterPredicate();
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
this.setCustomFilterPredicate();
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
} else {
|
||||
this.filterReportsByCategory();
|
||||
}
|
||||
@@ -89,22 +94,23 @@ export class ReportsComponent implements OnInit {
|
||||
*/
|
||||
setCustomFilterPredicate() {
|
||||
this.dataSource.filterPredicate = (data: any, filter: string) => {
|
||||
/** Transform the data into a lowercase string of all property values. */
|
||||
const dataStr = Object.keys(data).reduce(function (currentTerm: string, key: string) {
|
||||
/** Use an obscure Unicode character to delimit the words in the concatenated string.
|
||||
* This avoids matches where the values of two columns combined will match the user's query
|
||||
*/
|
||||
return currentTerm + ((/** @type {any} */ (data)))[key] + '◬';
|
||||
}, '').toLowerCase();
|
||||
/** Transform the filter by converting it to lowercase and removing whitespace. */
|
||||
const transformedFilter = filter.trim().toLowerCase();
|
||||
/* Seperates filter for All reports page.*/
|
||||
if (this.filter) {
|
||||
return dataStr.indexOf(transformedFilter) !== -1 && data.reportCategory === this.filter;
|
||||
} else {
|
||||
return dataStr.indexOf(transformedFilter) !== -1;
|
||||
}
|
||||
/** Transform the data into a lowercase string of all property values. */
|
||||
const dataStr = Object.keys(data)
|
||||
.reduce(function (currentTerm: string, key: string) {
|
||||
/** Use an obscure Unicode character to delimit the words in the concatenated string.
|
||||
* This avoids matches where the values of two columns combined will match the user's query
|
||||
*/
|
||||
return currentTerm + /** @type {any} */ data[key] + '◬';
|
||||
}, '')
|
||||
.toLowerCase();
|
||||
/** Transform the filter by converting it to lowercase and removing whitespace. */
|
||||
const transformedFilter = filter.trim().toLowerCase();
|
||||
/* Seperates filter for All reports page.*/
|
||||
if (this.filter) {
|
||||
return dataStr.indexOf(transformedFilter) !== -1 && data.reportCategory === this.filter;
|
||||
} else {
|
||||
return dataStr.indexOf(transformedFilter) !== -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user