Skip to content

Commit

Permalink
Merge pull request #626 from revolist/filter-plugin-hidden
Browse files Browse the repository at this point in the history
feat: hide filters from panel
  • Loading branch information
m2a2x authored Nov 7, 2024
2 parents 5dc9e84 + 672d8bd commit 825821b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugins/filter/filter.panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,29 +130,29 @@ export class FilterPanel {
const prop = this.changes?.prop;
if (typeof prop === 'undefined') return '';

const propFilters = this.filterItems[prop] || [];
const propFilters = this.filterItems[prop]?.filter(f => !f.hidden) || [];
const capts = Object.assign(
this.filterCaptionsInternal,
this.filterCaptions,
);
return (
<div key={this.filterId}>
{propFilters.map((d, index) => {
{propFilters.map((filter, index) => {
let andOrButton;

// hide toggle button if there is only one filter and the last one
if (index !== this.filterItems[prop].length - 1) {
andOrButton = (
<div onClick={() => this.toggleFilterAndOr(d.id)}>
<div onClick={() => this.toggleFilterAndOr(filter.id)}>
<AndOrButton
text={d.relation === 'and' ? capts.and : capts.or}
text={filter.relation === 'and' ? capts.and : capts.or}
/>
</div>
);
}

return (
<div key={d.id} class={FILTER_LIST_CLASS}>
<div key={filter.id} class={FILTER_LIST_CLASS}>
<div class={{ 'select-input': true }}>
<select
class="select-css select-filter"
Expand All @@ -164,7 +164,7 @@ export class FilterPanel {
)}
</select>
<div class={FILTER_LIST_CLASS_ACTION}>{andOrButton}</div>
<div onClick={() => this.onRemoveFilter(d.id)}>
<div onClick={() => this.onRemoveFilter(filter.id)}>
<TrashButton />
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/filter/filter.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,21 @@ export type FilterItem = {

export type FilterData = {
id: number;
/**
* Filter type
*/
type: FilterType;
/**
* Filter value
*/
value?: any;
/**
* Filter invisible in filter panel
*/
hidden?: boolean;
/**
* Filter relation
*/
relation: 'and' | 'or';
};

Expand Down

0 comments on commit 825821b

Please sign in to comment.