Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ui/src/views/tool/component/FieldFormDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
<el-option v-for="item in typeOptions" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item :label="$t('views.tool.form.toolDescription.label')">
<el-input
v-model="form.desc"
type="textarea"
:placeholder="$t('components.folder.descriptionPlaceholder')"
maxlength="128"
show-word-limit
:autosize="{ minRows: 3 }"
@blur="form.desc = form.desc?.trim()"
/>
</el-form-item>
<el-form-item :label="$t('views.tool.form.source.label')">
<el-select v-model="form.source">
<el-option :label="$t('views.tool.form.source.reference')" value="reference" />
Expand Down Expand Up @@ -64,6 +75,7 @@ const isEdit = ref(false)
const form = ref<any>({
name: '',
type: typeOptions[0],
desc: '',
source: 'reference',
is_required: true,
})
Expand All @@ -85,6 +97,7 @@ watch(dialogVisible, (bool) => {
form.value = {
name: '',
type: typeOptions[0],
desc: '',
source: 'reference',
is_required: true,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code has no major irregularities or critical issues. Here are some optimization and suggestions:

  1. Trimming Input: The @blur event on the textarea removes leading and trailing whitespace from the description when it loses focus, improving data integrity.

  2. Autosize for Textarea: Enabling autosizing with { minRows: 3 } is a good practice, especially if you expect descriptions to vary in length but should be at least three lines high.

  3. Type Definition: It's a good practice to explicitly define the type of form using something like ref<Record<string, string>>, which helps maintain consistency and catch potential errors related to mismatched types.

  4. Semi-Colon Usage: JavaScript prefers semicolons at the end of statements except where they're required by syntax (e.g., after commas). While this line does not require a semicolon (`},```), consistency could improve readability.

Overall, these changes make the form more robust and user-friendly, reducing potential edge cases and input errors.

Expand Down
Loading