UNPKG

@netgrif/components-core

Version:

Netgrif Application engine frontend core Angular library

53 lines (52 loc) 2.71 kB
import { Query } from '../query/query'; import { GeneratorMetadata } from '../persistance/generator-metadata'; import { FilterTextSegment } from '../persistance/filter-text-segment'; import { BooleanOperator } from '../boolean-operator'; /** * Building block of search queries. Represents any node in a tree of predicates, that are combined with {@link BooleanOperator}s to create * a search query. * * See {@link SearchService} for more information. */ export declare abstract class Predicate { protected _visible: boolean; protected _metadataGenerator: () => GeneratorMetadata | undefined; protected _filterTextSegmentsGenerator: () => Array<FilterTextSegment>; /** * @param initiallyVisible whether the predicate should be initially displayed or not */ protected constructor(initiallyVisible?: boolean); /** * @returns whether the Predicate should be displayed, or not */ get isVisible(): boolean; /** * @returns the {@link Query} object that corresponds to the `Query` for the entire subtree of Predicates, with * this Predicate as it's root node. */ abstract get query(): Query; /** * Combines the text segments of the predicates with the given operator and wraps the individual predicates in brackets optionaly * @param predicates sources of text segments that are to be combined with a boolean operator * @param operator boolean operator used to combine the individual predicate text segments * @param wrapWithBrackets whether the individual predicate text segments should be wrapped in braces or not * (if only one predicate is provided it is never wrapped) */ static combineTextSegmentsWithBooleanOperator(predicates: IterableIterator<Predicate> | Array<Predicate>, operator: BooleanOperator, wrapWithBrackets?: boolean): Array<FilterTextSegment>; /** * Sets the predicates state to `visible` */ show(): void; setMetadataGenerator(metadataGenerator: () => GeneratorMetadata | undefined): void; /** * @returns an object containing the necessary information for the reconstruction of the entire predicate tree in serializable form. * Returns `undefined` if the predicate tree rooted at this node is incomplete and would evaluate into an empty filter. */ createGeneratorMetadata(): GeneratorMetadata | undefined; setFilterTextSegmentsGenerator(filterTextSegmentsGenerator: () => Array<FilterTextSegment>): void; /** * @returns an Array containing text segments representing the content of this predicate. * The default implementation returns an empty array. */ createFilterTextSegments(): Array<FilterTextSegment>; }