|
|
@ -26,8 +26,8 @@ export interface LogicGroupProps { |
|
|
export interface DataConditionProps { |
|
|
export interface DataConditionProps { |
|
|
type: typeof DataConditionType; |
|
|
type: typeof DataConditionType; |
|
|
condition: ConditionProps; |
|
|
condition: ConditionProps; |
|
|
ifTrue: any; |
|
|
ifTrue?: any; |
|
|
ifFalse: any; |
|
|
ifFalse?: any; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
interface DataConditionPropsDefined extends Omit<DataConditionProps, 'condition'> { |
|
|
interface DataConditionPropsDefined extends Omit<DataConditionProps, 'condition'> { |
|
|
@ -42,8 +42,8 @@ export class DataCondition extends Model<DataConditionPropsDefined> { |
|
|
constructor( |
|
|
constructor( |
|
|
props: { |
|
|
props: { |
|
|
condition: ConditionProps; |
|
|
condition: ConditionProps; |
|
|
ifTrue: any; |
|
|
ifTrue?: any; |
|
|
ifFalse: any; |
|
|
ifFalse?: any; |
|
|
}, |
|
|
}, |
|
|
opts: { em: EditorModel; onValueChange?: () => void }, |
|
|
opts: { em: EditorModel; onValueChange?: () => void }, |
|
|
) { |
|
|
) { |
|
|
@ -62,7 +62,7 @@ export class DataCondition extends Model<DataConditionPropsDefined> { |
|
|
this.listenToDataVariables(); |
|
|
this.listenToDataVariables(); |
|
|
this._onValueChange = opts.onValueChange; |
|
|
this._onValueChange = opts.onValueChange; |
|
|
|
|
|
|
|
|
this.on('change:condition change:ifTrue change:ifFalse', () => { |
|
|
this.listenTo(this, 'change:condition change:ifTrue change:ifFalse', () => { |
|
|
this.listenToDataVariables(); |
|
|
this.listenToDataVariables(); |
|
|
this._onValueChange?.(); |
|
|
this._onValueChange?.(); |
|
|
}); |
|
|
}); |
|
|
@ -89,8 +89,8 @@ export class DataCondition extends Model<DataConditionPropsDefined> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getDataValue(skipDynamicValueResolution: boolean = false): any { |
|
|
getDataValue(skipDynamicValueResolution: boolean = false): any { |
|
|
const ifTrue = this.get('ifTrue'); |
|
|
const ifTrue = this.getIfTrue(); |
|
|
const ifFalse = this.get('ifFalse'); |
|
|
const ifFalse = this.getIfFalse(); |
|
|
|
|
|
|
|
|
const isConditionTrue = this.isTrue(); |
|
|
const isConditionTrue = this.isTrue(); |
|
|
if (skipDynamicValueResolution) { |
|
|
if (skipDynamicValueResolution) { |
|
|
@ -141,8 +141,8 @@ export class DataCondition extends Model<DataConditionPropsDefined> { |
|
|
|
|
|
|
|
|
getDependentDataVariables() { |
|
|
getDependentDataVariables() { |
|
|
const dataVariables: DataVariableProps[] = this.conditionEvaluator.getDependentDataVariables(); |
|
|
const dataVariables: DataVariableProps[] = this.conditionEvaluator.getDependentDataVariables(); |
|
|
const ifTrue = this.get('ifTrue'); |
|
|
const ifTrue = this.getIfTrue(); |
|
|
const ifFalse = this.get('ifFalse'); |
|
|
const ifFalse = this.getIfFalse(); |
|
|
if (isDataVariable(ifTrue)) dataVariables.push(ifTrue); |
|
|
if (isDataVariable(ifTrue)) dataVariables.push(ifTrue); |
|
|
if (isDataVariable(ifFalse)) dataVariables.push(ifFalse); |
|
|
if (isDataVariable(ifFalse)) dataVariables.push(ifFalse); |
|
|
|
|
|
|
|
|
@ -155,12 +155,12 @@ export class DataCondition extends Model<DataConditionPropsDefined> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
toJSON() { |
|
|
toJSON() { |
|
|
const ifTrue = this.get('ifTrue'); |
|
|
const ifTrue = this.getIfTrue(); |
|
|
const ifFalse = this.get('ifFalse'); |
|
|
const ifFalse = this.getIfFalse(); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
type: DataConditionType, |
|
|
type: DataConditionType, |
|
|
condition: this.conditionEvaluator, |
|
|
condition: this.conditionEvaluator.toJSON(), |
|
|
ifTrue, |
|
|
ifTrue, |
|
|
ifFalse, |
|
|
ifFalse, |
|
|
}; |
|
|
}; |
|
|
|