Skip to content

Commit

Permalink
feat: Node execution conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
shaohuzhang1 committed Dec 23, 2024
1 parent a00af1e commit 83db0da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
14 changes: 11 additions & 3 deletions apps/application/flow/workflow_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,17 @@ def get_next_node_list(self, current_node, current_node_result):
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
else:
for edge in self.flow.edges:
if edge.sourceNodeId == current_node.id and self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
if edge.sourceNodeId == current_node.id:
next_node = [node for node in self.flow.nodes if node.id == edge.targetNodeId]
if len(next_node) == 0:
continue
if next_node[0].properties.get('condition', "AND") == 'AND':
if self.dependent_node_been_executed(edge.targetNodeId):
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
else:
node_list.append(
self.get_node_cls_by_id(edge.targetNodeId, self.get_up_node_id_list(edge.targetNodeId)))
return node_list

def get_reference_field(self, node_id: str, fields: List[str]):
Expand Down
17 changes: 14 additions & 3 deletions ui/src/workflow/common/NodeContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
placement="bottom-start"
>
<el-button text>
<img src="@/assets/icon_or.svg" alt="" v-if="condition==='OR'">
<img src="@/assets/icon_and.svg" alt="" v-if="condition==='AND'">
<img src="@/assets/icon_or.svg" alt="" v-if="condition === 'OR'" />
<img src="@/assets/icon_and.svg" alt="" v-if="condition === 'AND'" />
</el-button>
<template #dropdown>
<div style="width: 280px" class="p-12-16">
Expand Down Expand Up @@ -152,8 +152,19 @@ const height = ref<{
})
const showAnchor = ref<boolean>(false)
const anchorData = ref<any>()
const condition = ref('AND')
const condition = computed({
set: (v) => {
set(props.nodeModel.properties, 'condition', v)
},
get: () => {
if (props.nodeModel.properties.condition) {
return props.nodeModel.properties.condition
}
set(props.nodeModel.properties, 'condition', 'AND')
return true
}
})
const showNode = computed({
set: (v) => {
set(props.nodeModel.properties, 'showNode', v)
Expand Down

0 comments on commit 83db0da

Please sign in to comment.