Skip to content

Commit

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

Fixed filter dialog filtering
  • Loading branch information
khotcholava committed Dec 11, 2024
1 parent 748ed9e commit 117f058
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
12 changes: 6 additions & 6 deletions libs/platform/table-helpers/services/table.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ 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 @@ -191,7 +192,7 @@ export class TableService {
const newFilterRules: CollectionFilter[] = filterRules
? filterRules.map((rule) => ({
...rule,
fieldName: this._getFieldName(rule.field)
fieldName: this._getFieldName(rule.field, rule.fieldName)
}))
: [];
const state: TableState = { ...prevState, filterBy: newFilterRules };
Expand All @@ -216,7 +217,7 @@ export class TableService {
...prevFilterRules.filter((existing) => !rulesToAdd.find(({ field }) => field === existing.field)),
...rulesToAdd.map((rule) => ({
...rule,
fieldName: this._getFieldName(rule.field)
fieldName: this._getFieldName(rule.field, rule.fieldName)
}))
];
const state: TableState = { ...prevState, filterBy: newFilterRules };
Expand Down Expand Up @@ -435,7 +436,7 @@ export class TableService {
buildFilterRulesMap(state = this.getTableState()): void {
const filterRulesWithFieldNames = state.filterBy.map((rule) => ({
...rule,
fieldName: this._getFieldName(rule.field)
fieldName: this._getFieldName(rule.field, rule.fieldName)
}));

this.filterRules$.set(
Expand Down Expand Up @@ -482,10 +483,9 @@ export class TableService {
}

/** @hidden */
private _getFieldName(field: string): string {
private _getFieldName(field: string, fieldName: Nullable<string>): string {
const column = this.tableColumns$.getValue().find((col) => col.key === field);
return column ? column.name : field;
}
return column ? column.name : fieldName ?? field; }
}

/** @hidden */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export class FilterStepComponent implements FiltersViewStep {
/** @hidden */
_onFilterValueChange(filterValue: any): void {
const filterBy: CollectionFilter = this._filterBy || {
field: this.columnName,
field: this.columnKey,
fieldName: this.columnName,
value: null,
strategy: FILTER_STRATEGY.EQ,
exclude: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
></fdp-filters-list-step>
} @else if (activeStep === ACTIVE_STEP.FILTER) {
<fdp-filter-step
[columnKey]="activeFilter!.column"
[columnKey]="activeFilterColumnKey!"
[columnName]="activeFilter!.label"
[filter]="activeFilter!"
[filterBy]="filterBy"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class FiltersComponent implements Resettable, AfterViewInit {
this.activeFilter = filter as TableViewSettingsFilterComponent;
this.activeFilterColumnKey = this.columns.find(
({ name }) => name === (<TableViewSettingsFilterComponent>filter).column
)?.label;
)?.key;
this._cd.detectChanges();
}

Expand Down

0 comments on commit 117f058

Please sign in to comment.