Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
BSekula committed Dec 18, 2024
1 parent 36de42d commit 44beb7c
Showing 1 changed file with 0 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatDividerModule } from '@angular/material/divider';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { TranslationService } from '../../../translation';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { clone } from 'lodash-es';
import { ColumnsSearchFilterPipe } from './columns-search-filter.pipe';
Expand All @@ -49,8 +48,6 @@ import { ColumnsSearchFilterPipe } from './columns-search-filter.pipe';
encapsulation: ViewEncapsulation.None
})
export class ColumnsSelectorComponent implements OnInit {
private translationService = inject(TranslationService);

@Input()
columns: DataColumn[] = [];

Expand Down Expand Up @@ -110,39 +107,10 @@ export class ColumnsSelectorComponent implements OnInit {

private updateColumnItems(): void {
let columns = clone(this.columns);
columns = this.filterColumnItems(columns, this.searchQuery);
columns = this.sortColumns(columns);
this.columnItems = columns;
}

private filterString(value: string = '', filterBy: string = ''): string {
const testResult = filterBy ? value.toLowerCase().indexOf(filterBy.toLowerCase()) > -1 : true;
return testResult ? value : '';
}

private filterColumnItems(columns: DataColumn[], query: string): DataColumn[] {
const result = [];

for (const column of columns) {
if (!column.title) {
continue;
}

if (!query) {
result.push(column);
continue;
}

const title = this.translationService.instant(column.title);

if (this.filterString(title, query)) {
result.push(column);
}
}

return result;
}

private sortColumns(columns: DataColumn[]): DataColumn[] {
if (this.columnsSorting) {
const shownColumns = columns.filter((column) => !column.isHidden);
Expand Down

0 comments on commit 44beb7c

Please sign in to comment.