Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP:32390 - sonar duplication. #726

Merged
merged 1 commit into from
Apr 15, 2024
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
10 changes: 9 additions & 1 deletion src/app/app.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SbiProjectModel } from './core/models/sbi-project';
import { Directory, Filesystem } from '@capacitor/filesystem';
import { Toast } from '@capacitor/toast';
import { sha256 } from 'js-sha256';

import { MatTableDataSource } from '@angular/material/table';
export default class Utils {
static getCurrentDate() {
let now = new Date();
Expand Down Expand Up @@ -1030,4 +1030,12 @@ export default class Utils {
});
return dialogRef;
}

static applyFilter<T>(event: Event, dataSource: MatTableDataSource<T>): void {
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
dataSource.filter = filterValue;
if (dataSource.paginator) {
dataSource.paginator.firstPage();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,7 @@ export class BiometricDashboardComponent implements OnInit {
}

applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
console.log(filterValue);
this.dataSource.filter = filterValue.trim().toLowerCase();
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
Utils.applyFilter(event, this.dataSource);
}
ngOnDestroy(): void {
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ export class MyReportsComponent implements OnInit {
this.dataSource.sort = this.sort;
}
applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
this.dataSource.filter = filterValue;
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
Utils.applyFilter(event, this.dataSource);
this.dataSource.filterPredicate = this.customFilterPredicate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,7 @@ export class PartnerReportsComponent implements OnInit {
}

applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value
.trim()
.toLowerCase();
this.dataSource.filter = filterValue;
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
Utils.applyFilter(event, this.dataSource);
this.dataSource.filterPredicate = this.customFilterPredicate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,7 @@ export class ProjectsDashboardComponent implements OnInit {
}

applyFilter(event: Event) {
const filterValue = (event.target as HTMLInputElement).value.trim().toLowerCase();
this.dataSource.filter = filterValue;
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
Utils.applyFilter(event, this.dataSource);
this.dataSource.filterPredicate = this.customFilterPredicate;
}

Expand Down
Loading