-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: The data source Tree uses fetc_list_function #4440
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 |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ | |
| </DynamicsForm> | ||
| </template> | ||
| <script setup lang="ts"> | ||
| import { computed, ref, watch } from 'vue' | ||
| import { computed, ref, watch, provide } from 'vue' | ||
| import { WorkflowKind, WorkflowType } from '@/enums/application' | ||
| import DynamicsForm from '@/components/dynamics-form/index.vue' | ||
| import type { FormField } from '@/components/dynamics-form/type' | ||
|
|
@@ -100,9 +100,18 @@ const form_data = computed({ | |
| const source_node_list = computed(() => { | ||
| return props.workflow?.nodes?.filter((n: any) => n.properties.kind === WorkflowKind.DataSource) | ||
| }) | ||
| const extra = ref<any>({ | ||
| current_tool_id: undefined, | ||
| }) | ||
| const get_extra = () => { | ||
| return extra.value | ||
| } | ||
| provide('get_extra', get_extra) | ||
|
|
||
| const sourceChange = (node_id: string) => { | ||
| base_form_data.value.node_id = node_id | ||
| const n = source_node_list.value.find((n: any) => n.id == node_id) | ||
| extra.value.current_tool_id = n.properties.node_data.tool_lib_id | ||
| node_id = n | ||
| ? [WorkflowType.DataSourceLocalNode, WorkflowType.DataSourceWebNode].includes(n.type) | ||
| ? n.type | ||
|
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. I've reviewed the provided code snippet and found a few minor improvements and corrections:
Here's an optimized version of the code snippet: <template>
<DynamicsForm :form-data="base_form_data" />
</template>
<script setup lang="ts">
import { computed, ref, watch, provide } from 'vue'
import { WorkflowKind, WorkflowType } from '@/enums/application'
import DynamicsForm from '@/components/dynamics-form/index.vue'
import type { FormField } from '@/components/dynamics-form/type'
const workflow_nodes_local_types = [
WorkflowType.DataSourceLocalNode,
WorkflowType.DataSourceWebNode
]
const form_data = computed(() => {
// Implementation for form data computation goes here
})
const source_node_list = computed(() => {
return props.workflow?.nodes?.filter((n: any) => n.properties.kind === WorkflowKind.DataSource);
})
// Initialize extra with default values for clarity
const extra = ref<any>({
current_tool_id: null, // or whatever suitable default value you prefer
});
// Define getter function directly within extra property
extra.get_current_tool_lib_id = get_extra;
function get_extra() {
return extra.value.current_tool_id;
}
provid('currentToolLibIdGetter', get_extra);
const sourceChange = (node_id: string): void => {
base_form_data.node_id = node_id;
const n = source_node_list.value.find((n: any) => n.id === node_id);
if (n !== undefined &&
workflow_nodes_local_types.includes(n.type)) {
extra.value.current_tool_id = n.properties.node_data.tool_lib_id;
node_id = n; // Assuming n contains additional properties relevant to this use case
// Further logic can be added here based on specific requirements
}
};
watch(
() => props.workflow,
newVal => {
// Update local state whenever props.workflow changes
},
{ immediate: true }
);
</script>Key Changes:
Make sure to adjust the implementation details according to your project's specific needs. |
||
|
|
||
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.
In terms of readability and functionality, there are a few changes you can make:
Remove Unnecessary Type Casting: The line
const get_extra = inject('get_extra') as anyis unnecessary, as TypeScript should automatically correctly infer the type if you use it consistently.Simplify Template String Usage: You can simplify how the URL template is being constructed by using templated string literals directly instead of concatenating strings using
${}syntax multiple times.Here's an optimized version based on these considerations:
Key Changes:
inject.try-catchblock to handle possible errors more gracefully.'Content-Type': 'application/json'to the request object for clarity and consistency.renderTemplatefunction.