-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: Error displaying execution details for assigning loop node variables #4093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,13 +56,15 @@ | |
| v-model="item.type" | ||
| style="max-width: 85px" | ||
| class="mr-8" | ||
| @change="(val: string) => { | ||
| if (val === 'bool') { | ||
| form_data.variable_list[index].value = true; | ||
| } else { | ||
| form_data.variable_list[index].value = null; | ||
| @change=" | ||
| (val: string) => { | ||
| if (val === 'bool') { | ||
| form_data.variable_list[index].value = true | ||
| } else { | ||
| form_data.variable_list[index].value = null | ||
| } | ||
| } | ||
| }" | ||
| " | ||
| > | ||
| <el-option v-for="item in typeOptions" :key="item" :label="item" :value="item" /> | ||
| </el-select> | ||
|
|
@@ -166,11 +168,12 @@ | |
| import { cloneDeep, set } from 'lodash' | ||
| import NodeContainer from '@/workflow/common/NodeContainer.vue' | ||
| import NodeCascader from '@/workflow/common/NodeCascader.vue' | ||
| import { computed, nextTick, onMounted, ref } from 'vue' | ||
| import { computed, nextTick, onMounted, ref, inject } from 'vue' | ||
| import { isLastNode } from '@/workflow/common/data' | ||
| import { randomId } from '@/utils/common' | ||
| import { t } from '@/locales' | ||
|
|
||
| import { WorkflowMode } from '@/enums/application' | ||
| const workflowMode = inject('workflowMode') as WorkflowMode | ||
| const props = defineProps<{ nodeModel: any }>() | ||
|
|
||
| const typeOptions = ['string', 'num', 'json', 'bool'] | ||
|
|
@@ -257,7 +260,10 @@ function deleteVariable(index: number) { | |
| } | ||
|
|
||
| function variableChange(item: any) { | ||
| props.nodeModel.graphModel.nodes.map((node: any) => { | ||
| ;(workflowMode == WorkflowMode.ApplicationLoop | ||
| ? [...props.nodeModel.graphModel.nodes, ...props.nodeModel.graphModel.get_parent_nodes()] | ||
| : props.nodeModel.graphModel.nodes | ||
| ).map((node: any) => { | ||
| if (node.id === 'start-node') { | ||
| node.properties.config.globalFields.forEach((field: any) => { | ||
| if (field.value === item.fields[1]) { | ||
|
|
@@ -270,6 +276,13 @@ function variableChange(item: any) { | |
| } | ||
| }) | ||
| } | ||
| if (node.id === 'loop-start-node') { | ||
| node.properties.loop_input_field_list.forEach((field: any) => { | ||
| if (field.field === item.fields[1]) { | ||
| item.name = field.label | ||
| } | ||
| }) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few improvements and corrections you can make to the code:
Here's the revised code with these improvements: // Check node model to see if it belongs to application loop mode
const nodesToCheck =
workflowMode === WorkflowMode.ApplicationLoop
? [...props.nodeModel.graphModel.nodes, ...props.nodeModel.graphModel.get_parent_nodes()]
: props.nodeModel.graphModel.nodes;
nodesToCheck.forEach((node) => {
// Handle start-node properties
if (node.id === 'start-node') {
node.properties.config.globalFields.forEach((field) => {
if (field.value === item.fields[1]) {
set(node.properties.config.global_fields, item.key, true);
}
});
}
// Handle loop-start-node properties
if (node.id === 'loop-start-node') {
node.properties.loop_input_field_list.forEach((field) => {
if (field.field === item.fields[1]) {
item.name = field.label;
}
});
}
});Key Changes:
These changes should address any irregularities or issues present in the original code while maintaining clarity and robustness. Make sure to review the updates and test them thoroughly in your specific environment. |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few improvements that can be made to this code snippet:
Typo Correction: Corrected the method signature for
get_parent_nodesfrom() => [nodes]to() => props.nodeModel.graphModel.nodes. This ensures that it correctly references the parent nodes from the providedprops.Simplify Refresh Loop Fields: The way you're updating
refresh_loop_fieldsmight not fully reflect the current state ofdata, especially if it's an object with dynamic properties.Code Readability and Maintainability:
lf.value.graphModel.refresh_loop_fields = refresh_loop_fields) to improve readability.With these changes, here is the revised code snippet:
Key Changes Made:
get_parent_nodes.props.nodeModel.graphModel.nodes.freshLoopFields()which demonstrates how you might update therefresh_loop_fields.