Skip to content

Commit

Permalink
MOSIP:32390 - sonar duplication. (#726)
Browse files Browse the repository at this point in the history
Signed-off-by: sudeep <[email protected]>
  • Loading branch information
Sudeep7353 committed Apr 15, 2024
1 parent e7d972b commit 8d376cc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
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

0 comments on commit 8d376cc

Please sign in to comment.