Skip to content

Commit

Permalink
fix(platform): table filter toolbar
Browse files Browse the repository at this point in the history
closes [#11783](#11783)

Fixed formatting
  • Loading branch information
khotcholava committed Dec 11, 2024
1 parent 1db00cb commit 4a08c25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 3 additions & 2 deletions libs/platform/table-helpers/services/table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { skip } from 'rxjs/operators';
import { DEFAULT_TABLE_STATE } from '../constants';

import { toSignal } from '@angular/core/rxjs-interop';
import { Nullable } from '@fundamental-ngx/cdk/utils';
import { CollectionFilter, CollectionGroup, CollectionPage, CollectionSort, TableState } from '../interfaces';
import {
ColumnsChange,
Expand All @@ -17,7 +18,6 @@ import {
SortChange
} from '../models';
import { TableColumn } from '../table-column';
import { Nullable } from '@fundamental-ngx/cdk/utils';

export type TableStateChange =
| TableStateProperty<'sort', SortChange>
Expand Down Expand Up @@ -485,7 +485,8 @@ export class TableService {
/** @hidden */
private _getFieldName(field: string, fieldName: Nullable<string>): string {
const column = this.tableColumns$.getValue().find((col) => col.key === field);
return column ? column.name : fieldName ?? field; }
return column ? column.name : fieldName ?? field;
}
}

/** @hidden */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@
>
<label fd-toolbar-label>
{{ 'platformTable.filteredBy' | fdTranslate }}:
@for (filter of appliedFilters(); track filter.columnName; let i = $index) {
{{ filter.columnName }} ({{ filter.params }})@if (i < appliedFilters().length - 1){,}
}
{{_formatAppliedFilters(appliedFilters())}}
</label>
<fd-toolbar-spacer></fd-toolbar-spacer>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,16 @@ export class TableToolbarComponent implements TableToolbarInterface {
this._table.cancelEditing();
}

/** @hidden */
_formatAppliedFilters(appliedFilters: { columnName: string; params: string }[]): string {
return appliedFilters
.map((filter, index) => {
const separator = index < appliedFilters.length - 1 ? ', ' : '';
return `${filter.columnName} (${filter.params})${separator}`;
})
.join('');
}

/** @hidden */
_expandAll(): void {
this._table.expandAll();
Expand Down

0 comments on commit 4a08c25

Please sign in to comment.