Filter options

This commit is contained in:
Adina Țeudan 2022-02-28 17:58:00 +02:00
parent dd87dd6821
commit 17008f4475
3 changed files with 9 additions and 3 deletions

View File

@ -24,11 +24,11 @@ function copySettings(oldFilters: INestedFilter[], newFilters: INestedFilter[])
export function handleCheckedValue(filter: INestedFilter): void {
if (filter.children && filter.children.length) {
filter.checked = filter.children.reduce<boolean>((acc, next) => acc && !!next.checked, true);
filter.checked = filter.children.reduce<boolean>((acc, next) => acc && next.checked, true);
if (filter.checked) {
filter.indeterminate = false;
} else {
filter.indeterminate = filter.children.reduce<boolean>((acc, next) => acc || !!next.checked, false);
filter.indeterminate = filter.children.reduce<boolean>((acc, next) => acc || next.checked, false);
}
} else {
filter.indeterminate = false;

View File

@ -1,6 +1,7 @@
export interface IFilter {
checked?: boolean;
matches?: number;
readonly skipTranslation?: boolean;
readonly id: string;
readonly label: string;
readonly icon?: string;
@ -9,4 +10,5 @@ export interface IFilter {
readonly required?: boolean;
readonly disabled?: boolean;
readonly helpModeKey?: string;
readonly color?: string;
}

View File

@ -1,4 +1,4 @@
import { IListable } from '../../listing/models/listable';
import { IListable } from '../../listing';
import { Filter } from './filter';
import { INestedFilter } from './nested-filter.model';
@ -8,6 +8,8 @@ export class NestedFilter extends Filter implements INestedFilter, IListable {
disabled?: boolean;
helpModeKey?: string;
readonly children: Filter[];
readonly skipTranslation?: boolean;
readonly color?: string;
constructor(nestedFilter: INestedFilter) {
super(nestedFilter);
@ -16,5 +18,7 @@ export class NestedFilter extends Filter implements INestedFilter, IListable {
this.disabled = !!nestedFilter.disabled;
this.helpModeKey = nestedFilter.helpModeKey;
this.children = nestedFilter.children ?? [];
this.skipTranslation = nestedFilter.skipTranslation;
this.color = nestedFilter.color;
}
}