-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-components): fdm support in rule based core (#4706)
* add a hook to get all instances from all direct connections and merge all relevant data for each instance - wip * move direct connection with properties hook and adapt the initial functions to support fdm trigger type and styling - wip * adapting styling groups accross components to support fdm styling groups also - wip * insert fdm types for rule type definitions * refactoring expression types * add datetime and boolean expressions statements * refactoring and add property trigger for numeric expression supporting fdm * add optional parameters for the fdm typing type * fix property types * fix date statement and fdm externalid for styling list * fix datetime limit type for between and notbetween * add expression safeguards * refactoring and remove duplicated timeserie ids when traversing expression to get time series * update and export fdm types and some cleanup * add fdm new conditions * stories cleanup * cleanup fdmsdk log * use isLoading flag for the spinner accuracy and some refactoring on loading and caching * reduce complexity a bit * refactoring for some small optimizations * lint fix * export fdm types for rule based * refactoring some rule type definitions to support correct typing data * fix datetimecondition definition * fix boolean condition types and export unique types list for numeric and datetime * add into index * dont request assetids from ts if it is empty * changes from cr * lint fix * use createFdmKey - cr * add createFdmKey for uniqBy
- Loading branch information
Showing
15 changed files
with
999 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
react-components/src/components/RuleBasedOutputs/core/checkBooleanExpressionStatement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*! | ||
* Copyright 2024 Cognite AS | ||
*/ | ||
|
||
import { type FdmPropertyType } from '../../Reveal3DResources/types'; | ||
import { type Expression, type TriggerTypeData } from '../types'; | ||
import { getFdmPropertyTrigger } from '../utils'; | ||
|
||
export const checkBooleanExpressionStatement = ( | ||
triggerTypeData: TriggerTypeData[], | ||
expression: Expression | ||
): boolean | undefined => { | ||
const condition = expression.type === 'booleanExpression' ? expression.condition : undefined; | ||
const trigger = expression.type === 'booleanExpression' ? expression.trigger : undefined; | ||
|
||
let expressionResult: boolean | undefined = false; | ||
|
||
if (condition === undefined || trigger === undefined) return; | ||
|
||
const currentTriggerData = triggerTypeData.find( | ||
(triggerType) => triggerType.type === trigger?.type | ||
); | ||
|
||
const isFdmTrigger = trigger?.type === 'fdm' && currentTriggerData?.type === 'fdm'; | ||
|
||
if (isFdmTrigger && currentTriggerData.instanceNode.items.length === 0) return; | ||
|
||
const fdmItemsTrigger = | ||
isFdmTrigger && currentTriggerData.instanceNode.items[0] !== undefined | ||
? currentTriggerData.instanceNode.items[0] | ||
: undefined; | ||
|
||
const fdmPropertyTrigger = isFdmTrigger | ||
? (fdmItemsTrigger?.properties as FdmPropertyType<unknown>) | ||
: undefined; | ||
|
||
const propertyTrigger = getFdmPropertyTrigger<boolean>(fdmPropertyTrigger, trigger); | ||
|
||
switch (condition.type) { | ||
case 'equals': { | ||
expressionResult = propertyTrigger === true; | ||
break; | ||
} | ||
case 'notEquals': { | ||
expressionResult = propertyTrigger === false; | ||
break; | ||
} | ||
} | ||
return expressionResult; | ||
}; |
Oops, something went wrong.