Options
All
  • Public
  • Public/Protected
  • All
Menu

Example usage:


import { PredicateFormulaEditorFactory, TPredicateProperties } from "../src";
import { EXAMPLE_JSON_BLUE_SKIES } from "../src";

const { predicateTreeJson } = EXAMPLE_JSON_BLUE_SKIES;
const { predicateSubjectsDictionaryJson: subjectDictionaryJson } =
  EXAMPLE_JSON_BLUE_SKIES;

export const predicateFormula = PredicateFormulaEditorFactory.fromJson({
  predicateTreeJson: predicateTreeJson,
  // predicateTreeJson is optional.
  // if undefined tree will be empty (like new document, start from scratch)

  subjectDictionaryJson: subjectDictionaryJson,
});

const newPredicate: TPredicateProperties = {
  operator: "$eq",
  subjectId: "firstName",
  value: "Barney",
};

const newPredicateId = predicateFormula.predicatesAppend(
  predicateFormula.rootNodeId,
  newPredicate
);

const toBeUpdatedPredicate = predicateFormula.predicatesGetPropertiesById(newPredicateId);
toBeUpdatedPredicate.value = "Betty";

predicateFormula.predicatesReplace(newPredicateId, toBeUpdatedPredicate);
console.log(JSON.stringify(predicateFormula.toJson(), null, 2));

Hierarchy

  • PredicateFormulaEditor

Implements

Index

Constructors

Private constructor

Properties

Private _predicateSubjectDictionary

_predicateSubjectDictionary: IPredicateSubjectDictionary

Private _predicateTree

_predicateTree: IPredicateTree

Accessors

predicateTree

rootNodeId

  • get rootNodeId(): string

subjectDictionary

Methods

makeEmptyPredicate

predicatesAcceptVisitor

predicatesAppend

predicatesGetById

predicatesGetChildrenIds

  • predicatesGetChildrenIds(predicateId: string): string[]

predicatesGetJunctionById

predicatesGetPropertiesById

predicatesIsBranch

  • predicatesIsBranch(predicateId: string): boolean

predicatesRemove

  • predicatesRemove(predicateId: string): void

predicatesReplace

  • predicatesReplace(predicateId: string, predicate: TPredicateNode): void

predicatesToJsonTree

subjectGetColumns

subjectsGetAllIds

  • subjectsGetAllIds(): string[]

subjectsGetById

subjectsGetDefault

subjectsGetOptionsList

toJson

Static fromEmpty

Static fromJson

Generated using TypeDoc