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': {
|
case 'cases': {
|
||||||
if (!item.left) return false
|
if (!item.left) return false
|
||||||
if (['not_empty', 'empty'].includes(item.operator)) return true
|
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 data = node?.getData() || {};
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const graphRef = useRef(node?.model?.graph)
|
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 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}`
|
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 [chatVariables, setChatVariables] = useState<ChatVariable[]>([])
|
||||||
const featuresRef = useRef<FeaturesConfigForm | undefined>(undefined)
|
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(() => {
|
useEffect(() => {
|
||||||
getConfig()
|
getConfig()
|
||||||
}, [id])
|
}, [id])
|
||||||
@@ -211,7 +221,7 @@ export const useWorkflowGraph = ({
|
|||||||
id,
|
id,
|
||||||
type,
|
type,
|
||||||
name,
|
name,
|
||||||
data: { ...node, ...nodeLibraryConfig},
|
data: { ...node, ...nodeLibraryConfig, ...((type === 'if-else' || type === 'question-classifier') ? { chatVariables } : {}) },
|
||||||
...position,
|
...position,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user