Skip to content

Latest commit

 

History

History
200 lines (126 loc) · 6.73 KB

File metadata and controls

200 lines (126 loc) · 6.73 KB

@onzag/itemize / Modules / base/Root/Module/ItemDefinition/ConditionalRuleSet / default

Class: default

base/Root/Module/ItemDefinition/ConditionalRuleSet.default

This class provides conditional rule sets that are set for an specific situation to take place, it has multiple uses like disabling an item, or making a property a certain value conditional rule sets are chainable and represents rules based on properties or items

for example say we have an item vehicle and which one is motorbike and a motorbike might have a belt, chain or shaft lets say we also decided to add a property drive-type to the vehicle class

So we make a rule for this

{
 "name": "belt",
 "excludedIf": {
   "property": "type",
   "comparator": "not-equal",
   "value": "motorbike",
   "gate": "or",
   "condition": {
     "property": "drive-type",
     "comparator": "not-equal",
     "value": {
       "exactValue": "belt-drive"
     }
   }
 }
}

Conditional rule sets are chainable and might also include components, components are the same as items, for example

{
 "name": "belt-keeper",
 "excludedIf": {
   "component": "belt",
   "isIncluded": false
 }
}

This means that the belt-keeper item is not available if there is no such thing as a belt included

Rule sets are also available for things like properties, whether they are available or not, default values, might exclusions, etc... they are very practical, but limited on purpose to avoid excessive complexity

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new default(rawJSON, parentModule, parentItemDefinition, parentPropertyDefinition, parentInclude): default

Constructor

Parameters

Name Type Description
rawJSON IConditionalRuleSetRawJSONDataType the raw data as JSON
parentModule default the module where this node is located
parentItemDefinition default the item definition that this node is
parentPropertyDefinition default the property definition that contains the rule located, it might not be available for example for condition in prop extensions
parentInclude default the item that contains this condition, such as in exclusion rules, it might not be available as well

Returns

default

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:208

Properties

conditions

Private conditions: default[]

an internal condition for nested conditions

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:195


parentInclude

parentInclude: default

a parent include, if available, might be null

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:186


parentItemDefinition

parentItemDefinition: default

the item definition where it is contained

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:178


parentModule

parentModule: default

the parent module of this condition

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:174


parentPropertyDefinition

parentPropertyDefinition: default

the property that it is contained within, might be null for prop extensions

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:182


rawData

rawData: IConditionalRuleSetRawJSONDataType

the raw data that was used to generate this conditional rule set

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:190

Methods

evaluate

evaluate(id, version): boolean

Evaluates the result of the conditional value as this current point as defined by the item defintion

Parameters

Name Type Description
id string the id to be used to retrieve values for properties during evaluation
version string the version used to retrieve values as well

Returns

boolean

a boolean on whether the conditional rule set passes or not

Defined in

base/Root/Module/ItemDefinition/ConditionalRuleSet/index.ts:243