Skip to content

Commit

Permalink
Merge pull request #644 from revolist/filter-hooks
Browse files Browse the repository at this point in the history
filter updates
  • Loading branch information
revolist authored Nov 28, 2024
2 parents 10e2104 + bbd2289 commit 78d14b7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
29 changes: 17 additions & 12 deletions src/plugins/filter/filter.panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,18 +459,23 @@ export class FilterPanel {
>
<slot slot="header" />
{ this.changes.extraContent?.(this.changes) || '' }
<label>{capts.title}</label>
<div class="filter-holder">{this.getFilterItemsList()}</div>

<div class="add-filter">
<select
id={FILTER_ID}
class="select-css"
onChange={e => this.onAddNewFilter(e)}
>
{this.renderSelectOptions(this.currentFilterType)}
</select>
</div>

{ this.changes?.hideDefaultFilters !== true && (
[
<label>{capts.title}</label>,
<div class="filter-holder">{this.getFilterItemsList()}</div>,
<div class="add-filter">
<select
id={FILTER_ID}
class="select-css"
onChange={e => this.onAddNewFilter(e)}
>
{this.renderSelectOptions(this.currentFilterType)}
</select>
</div>
]
)}

<slot />
<div class="filter-actions">
{this.disableDynamicFiltering && [
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/filter/filter.plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export class FilterPlugin extends BasePlugin {
);
}

beforeshow(_: ShowData) {
// used as hook for filter panel
}

extraContent(): any {
return null;
}
Expand Down Expand Up @@ -254,11 +258,10 @@ export class FilterPlugin extends BasePlugin {
autoCorrect: true,
filterTypes: this.getColumnFilter(e.detail.filter),
filterItems: this.multiFilterItems,
};
this.pop.show({
...data,
extraContent: this.extraHyperContent,
});
};
this.beforeshow?.(data);
this.pop.show(data);
}

getColumnFilter(
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/filter/filter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export type ShowData = {
autoCorrect?: boolean;
filterTypes?: Record<string, string[]>;
filterItems?: MultiFilterItem;
// hide default filters
hideDefaultFilters?: boolean;
// pass vnodes from plugins
extraContent?: (data: ShowData) => any;
} & FilterItem & Omit<ColumnRegular, 'filter'>;

0 comments on commit 78d14b7

Please sign in to comment.