-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: Intent node height #4113
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
fix: Intent node height #4113
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 |
---|---|---|
|
@@ -107,10 +107,9 @@ | |
<div> | ||
<div | ||
v-for="(item, index) in form_data.branch" | ||
v-resize="(wh: any) => resizeBranch(wh, item, index)" | ||
:key="item.id" | ||
> | ||
<el-form-item | ||
<el-form-item | ||
:prop="`branch.${index}.content`" | ||
:rules="{ | ||
message: $t('views.applicationWorkflow.nodes.intentNode.classify.placeholder'), | ||
|
@@ -133,7 +132,6 @@ | |
<el-button | ||
link | ||
size="large" | ||
class="mt-4" | ||
v-if="!item.isOther" | ||
:disabled="form_data.branch.filter((b: any) => !b.isOther).length <= 1" | ||
@click="deleteClassifyBranch(item.id)" | ||
|
@@ -192,6 +190,7 @@ function addClassfiyBranch() { | |
list.splice(list.length - 1, 0, obj) | ||
refreshBranchAnchor(list, true) | ||
set(props.nodeModel.properties.node_data, 'branch', list) | ||
props.nodeModel.refreshBranch() | ||
} | ||
|
||
function deleteClassifyBranch(id: string) { | ||
|
@@ -336,7 +335,7 @@ const validate = () => { | |
nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(''), | ||
IntentClassifyNodeFormRef.value?.validate(), | ||
]).then(() => { | ||
if (form_data.value.branch.length != new Set(form_data.value.branch.map((item: any) => item.content)).size) { | ||
if (form_data.value.branch.length != new Set(form_data.value.branch.map((item: any) => item.content)).size) { | ||
throw t('views.applicationWorkflow.nodes.intentNode.error2') | ||
} | ||
}).catch((err: any) => { | ||
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. No apparent errors or issues were found with the provided code. However, there are some optimization and readability improvements that can be made:
const validate = () => {
return Promise.all([
nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(),
IntentClassifyNodeFormRef.value?.validate(),
]).then(() => {
// If form is valid, perform additional checks here
});
};
const validate = () => {
return Promise.all([
nodeCascaderRef.value ? nodeCascaderRef.value.validate() : Promise.resolve(),
IntentClassifyNodeFormRef.value?.validate(),
].reduce((resolve, validator) => validator.then(resolve), Promise.reject()))
.then(() => {
const uniqueContentsSet = new Set(form_data.value.branch.map((item: any) => item.content))
if (uniqueContentsSet.size !== form_data.value.branch.length) throw t('views.applicationWorkflow.nodes.intentNode.error2');
else return null; // Indicating all good
})
};
// Then handle rejection
.catch((err: any) => {});
These changes will help in cleaner code with fewer unnecessary operations. |
||
|
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.
const FORM_ITEMS_HEIGHT = 382
should be updated toconst FORM_ITEMS_HEIGHT = 397
.y - height / 2 + FORM_ITEMS_HEIGHT + h + element.height / 2
is slightly off due to incorrect indexing logic (h
). This could lead to misplacement of elements.FORM_ITEMS_HEIGHT
with a more descriptive name likeFORM_ROW_HEIGHT
. Also, consider renamingwidth
,height
,x
, andy
to make code self-explanatory.Here's the corrected and optimized version:
Key Changes Made:
index % 2
instead of hardcoding offsets directly. This ensures that every second row has additional spacing for better layout consistency.rowHeightOffset
to reflect its purpose better.