Skip to content

Commit

Permalink
Change: Allow to set a filter type to create in withFilterDialog
Browse files Browse the repository at this point in the history
With this change it is possible to define the filter type to use when a
new filter is created directly when writing a filter dialog component.
Before it was required to pass it via a prop. Passing via a prop is
still optional.

Example usage now (implicitly):
```
createFilterDialog({
  createFilterType: 'portlist',
  sortFields: SORT_FIELDS,
});
```
  • Loading branch information
bjoernricks committed Apr 4, 2024
1 parent c9cb7e0 commit 3d0dd12
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/web/components/powerfilter/withFilterDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ import React from 'react';

import FilterDialog from './filterdialog';

const withFilterDialog = (options = {}) => FilterDialogComponent => props => (
<FilterDialog {...props}>
{dialogProps => <FilterDialogComponent {...options} {...dialogProps} />}
</FilterDialog>
);
const withFilterDialog =
({createFilterType, ...options} = {}) =>
FilterDialogComponent =>
(
{createFilterType: createFilterTypeProp = createFilterType, ...props}, // eslint-disable-line react/prop-types
) => (
<FilterDialog {...props} createFilterType={createFilterTypeProp}>
{dialogProps => <FilterDialogComponent {...options} {...dialogProps} />}
</FilterDialog>
);

export default withFilterDialog;

Expand Down

0 comments on commit 3d0dd12

Please sign in to comment.