Merge pull request #842 from SuanmoSuanyangTechnology/feature/tool_zy
fix(web): if-else node case show
This commit is contained in:
@@ -14,7 +14,7 @@ const caculateIsSet = (item: any, type: string) => {
|
||||
case 'cases': {
|
||||
if (!item.left) return false
|
||||
if (['not_empty', 'empty'].includes(item.operator)) return true
|
||||
return !!item.left && (!!item.right || typeof item.right === 'boolean')
|
||||
return !!item.left && (!!item.right || typeof item.right === 'boolean' || typeof item.right === 'number')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ const ConditionNode: ReactShapeConfig['component'] = ({ node }) => {
|
||||
const data = node?.getData() || {};
|
||||
const { t } = useTranslation()
|
||||
const graphRef = useRef(node?.model?.graph)
|
||||
const variableList = useVariableList(node ?? null, graphRef, [])
|
||||
const variableList = useVariableList(node ?? null, graphRef, data.chatVariables ?? [])
|
||||
|
||||
const getLocaleField = (field: string, filedType: string) => {
|
||||
const key = filedType === 'boolean' ? `workflow.config.if-else..boolean.${field}` : filedType === 'number' ? `workflow.config.if-else.num.${field}` : `workflow.config.if-else.${field}`
|
||||
|
||||
@@ -106,6 +106,16 @@ export const useWorkflowGraph = ({
|
||||
const [chatVariables, setChatVariables] = useState<ChatVariable[]>([])
|
||||
const featuresRef = useRef<FeaturesConfigForm | undefined>(undefined)
|
||||
|
||||
useEffect(() => {
|
||||
if (!graphRef.current) return
|
||||
graphRef.current.getNodes().forEach(node => {
|
||||
const data = node.getData()
|
||||
if (data?.type === 'if-else' || data?.type === 'question-classifier') {
|
||||
node.setData({ ...data, chatVariables }, { silent: true })
|
||||
}
|
||||
})
|
||||
}, [chatVariables])
|
||||
|
||||
useEffect(() => {
|
||||
getConfig()
|
||||
}, [id])
|
||||
@@ -211,7 +221,7 @@ export const useWorkflowGraph = ({
|
||||
id,
|
||||
type,
|
||||
name,
|
||||
data: { ...node, ...nodeLibraryConfig},
|
||||
data: { ...node, ...nodeLibraryConfig, ...((type === 'if-else' || type === 'question-classifier') ? { chatVariables } : {}) },
|
||||
...position,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user