Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide filters from panel #626

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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