File

projects/netgrif-components-core/src/lib/search/models/predicate/editable-clause-predicate-with-generators.ts

Extends

EditableClausePredicate

Index

Properties
Methods

Constructor

constructor(operator: BooleanOperator, parentNotifier?: Subject, initiallyVisible, bracketSubPredicateText)
Parameters :
Name Type Optional
operator BooleanOperator No
parentNotifier Subject<void> Yes
initiallyVisible No
bracketSubPredicateText No

Properties

Protected _predicates
Type : Map<number | PredicateWithGenerator>
Inherited from EditableClausePredicate
Protected _childCounter
Type : IncrementingCounter
Inherited from EditableClausePredicate
Protected _childUpdated$
Type : Subject<void>
Inherited from EditableClausePredicate
Protected _query
Type : Query
Inherited from EditableClausePredicate
Protected _parentNotifier
Type : Subject<void>
Inherited from EditablePredicate
Protected _filterTextSegmentsGenerator
Type : function
Inherited from Predicate
Defined in Predicate:16
Protected _metadataGenerator
Type : function
Inherited from Predicate
Defined in Predicate:15
Protected _visible
Type : boolean
Inherited from Predicate
Defined in Predicate:14

Methods

addNewClausePredicate
addNewClausePredicate(operator: BooleanOperator, initiallyVisible)
Inherited from EditableClausePredicate
Parameters :
Name Type Optional Default value
operator BooleanOperator No
initiallyVisible No true
Returns : number
addNewPredicateFromGenerator
addNewPredicateFromGenerator(generator: Category<any>, initiallyVisible)

Creates a new editable predicate from the provided generator Category instance, connects it to the update notifications stream and adds it to the predicate subtree.

Parameters :
Name Type Optional Default value
generator Category<any> No
initiallyVisible No true
Returns : number
addPredicate
addPredicate(predicate: Predicate, initiallyVisible)
Inherited from EditableClausePredicate
Parameters :
Name Type Optional Default value
predicate Predicate No
initiallyVisible No true
Returns : number
destroy
destroy()
Inherited from EditablePredicate

Cleans-up the inner state of this object

Returns : void
getPredicateMap
getPredicateMap()
Inherited from EditableClausePredicate
Returns : Map<number, PredicateWithGenerator>
addNewElementaryPredicate
addNewElementaryPredicate(initiallyVisible)
Inherited from EditableClausePredicate

Adds new child predicate of type EditableElementaryPredicate

Parameters :
Name Optional Default value Description
initiallyVisible No true

whether the new predicate should be initially visible

Returns : number
removePredicate
removePredicate(id: number)
Inherited from EditableClausePredicate
Parameters :
Name Type Optional
id number No
Returns : boolean
Public show
show()
Inherited from Predicate
Defined in Predicate:46
Returns : void
Protected showAll
showAll()
Inherited from EditableClausePredicate

Sets this predicate and all its sub-predicates to visible.

Returns : void
Public showPredicates
showPredicates(predicateIds: Array)
Inherited from EditableClausePredicate

Shows the predicates with the given ids. Skips ids that don't exist.

Parameters :
Name Type Optional Description
predicateIds Array<number> No

the ids of the predicates that should be shown.

Returns : void
Protected updateQuery
updateQuery()
Inherited from EditableClausePredicate

Updates the value of the _query attribute.

See combineQueries() for more information.

Returns : void
Protected updateQueryAndNotify
updateQueryAndNotify()
Inherited from EditableClausePredicate

Updates the Query and notifies the parent.

Returns : void
Protected notifyParentPredicate
notifyParentPredicate()
Inherited from EditablePredicate

Notify the parent Predicate that this Predicate updated its Query

Returns : void
Static combineTextSegmentsWithBooleanOperator
combineTextSegmentsWithBooleanOperator(predicates: IterableIterator<Predicate> | Array<Predicate>, operator: BooleanOperator, wrapWithBrackets)
Inherited from Predicate
Defined in Predicate:51

Combines the text segments of the predicates with the given operator and wraps the individual predicates in brackets optionaly (if only one predicate is provided it is never wrapped)

Parameters :
Name Type Optional Default value Description
predicates IterableIterator<Predicate> | Array<Predicate> No

sources of text segments that are to be combined with a boolean operator

operator BooleanOperator No

boolean operator used to combine the individual predicate text segments

wrapWithBrackets No false

whether the individual predicate text segments should be wrapped in braces or not (if only one predicate is provided it is never wrapped)

Public createFilterTextSegments
createFilterTextSegments()
Inherited from Predicate
Defined in Predicate:110

The default implementation returns an empty array.

an Array containing text segments representing the content of this predicate. The default implementation returns an empty array.

Public createGeneratorMetadata
createGeneratorMetadata()
Inherited from Predicate
Defined in Predicate:98

Returns undefined if the predicate tree rooted at this node is incomplete and would evaluate into an empty filter.

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.

Public setFilterTextSegmentsGenerator
setFilterTextSegmentsGenerator(filterTextSegmentsGenerator: () => void)
Inherited from Predicate
Defined in Predicate:102
Parameters :
Name Type Optional
filterTextSegmentsGenerator function No
Returns : void
Public setMetadataGenerator
setMetadataGenerator(metadataGenerator: () => void)
Inherited from Predicate
Defined in Predicate:90
Parameters :
Name Type Optional
metadataGenerator function No
Returns : void
import {EditableClausePredicate} from './editable-clause-predicate';
import {BooleanOperator} from '../boolean-operator';
import {Subject} from 'rxjs';
import {PredicateWithGenerator} from './predicate-with-generator';
import {Predicate} from './predicate';
import {Category} from '../category/category';
import {EditablePredicateWithGenerator} from './editable-predicate-with-generator';

export class EditableClausePredicateWithGenerators extends EditableClausePredicate {

    protected _predicates: Map<number, PredicateWithGenerator>;

    constructor(operator: BooleanOperator, parentNotifier?: Subject<void>, initiallyVisible = true, bracketSubPredicateText = false) {
        super(operator, parentNotifier, initiallyVisible, bracketSubPredicateText);
        this._metadataGenerator = () => {
            const result = [];
            for (const predicate of this._predicates.values()) {
                const metadata = predicate.createGeneratorMetadata();
                if (metadata !== undefined) {
                    result.push(metadata);
                }
            }
            return result.length > 0 ? result : undefined;
        };
    }

    addNewClausePredicate(operator: BooleanOperator, initiallyVisible = true): number {
        return this.addPredicate(new EditableClausePredicateWithGenerators(operator, this._childUpdated$, initiallyVisible));
    }

    addPredicate(predicate: Predicate, initiallyVisible = true): number {
        return super.addPredicate(new PredicateWithGenerator(predicate, undefined, initiallyVisible));
    }

    /**
     * Creates a new editable predicate from the provided generator {@link Category} instance,
     * connects it to the update notifications stream and adds it to the predicate subtree.
     * @param generator
     * @param initiallyVisible
     */
    addNewPredicateFromGenerator(generator: Category<any>, initiallyVisible = true): number {
        const predicate = new EditablePredicateWithGenerator(generator, initiallyVisible);
        predicate.parentNotifier = this._childUpdated$;
        return super.addPredicate(predicate);
    }

    getPredicateMap(): Map<number, PredicateWithGenerator> {
        return this._predicates;
    }

    /**
     * Cleans-up the inner state of this object
     */
    destroy(): void {
        super.destroy();
        for (const predicate of this._predicates.values()) {
            predicate.destroy();
        }
    }
}

result-matching ""

    No results matching ""