Skip to content

Commit

Permalink
feat: add smart fill functionality for Associated Fields in verificat…
Browse files Browse the repository at this point in the history
…ion component

- Introduced new localization strings for English, Simplified Chinese, and Traditional Chinese to support smart fill feature.
- Enhanced ConditionBox.vue to include a toggle for auto-filling join fields, with tooltips explaining the feature's behavior.
- Updated FieldSelectWrap.vue to handle empty input values more gracefully.

This update improves user experience by automating the join condition setup process.

(cherry picked from commit 60898a7)
  • Loading branch information
cn-xufei committed Jan 21, 2025
1 parent 97a6225 commit babe807
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 9 deletions.
7 changes: 6 additions & 1 deletion packages/business/src/locale/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1319,5 +1319,10 @@ export default {
packages_business_warning_details: 'Warning Details',
packages_business_custom_collate: 'Custom Collate',
packages_business_please_select_field: 'Please select a field',
packages_business_please_input_charset: 'Please input charset'
packages_business_please_input_charset: 'Please input charset',
packages_business_auto_fill_join_fields: 'Smart Fill Associated Fields',
packages_business_auto_fill_join_tooltip_title:
'After enabling, the system will automatically fill in the join conditions according to the following priority:',
packages_business_auto_fill_join_tooltip_primary: '1. Use primary key fields first',
packages_business_auto_fill_join_tooltip_all: '2. If there is no primary key, use all fields'
}
6 changes: 5 additions & 1 deletion packages/business/src/locale/lang/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,5 +1258,9 @@ export default {
packages_business_warning_details: '警告详情',
packages_business_custom_collate: '自定义排序',
packages_business_please_select_field: '请选择字段',
packages_business_please_input_charset: '请输入字符集'
packages_business_please_input_charset: '请输入字符集',
packages_business_auto_fill_join_fields: '智能填充关联条件',
packages_business_auto_fill_join_tooltip_title: '开启后,系统将按以下优先级自动填充关联条件:',
packages_business_auto_fill_join_tooltip_primary: '1. 优先使用主键字段',
packages_business_auto_fill_join_tooltip_all: '2. 如无主键,则使用全部字段'
}
6 changes: 5 additions & 1 deletion packages/business/src/locale/lang/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -1249,5 +1249,9 @@ export default {
packages_business_warning_details: '警告詳情',
packages_business_custom_collate: '自定義排序',
packages_business_please_select_field: '請選擇字段',
packages_business_please_input_charset: '請輸入字符集'
packages_business_please_input_charset: '請輸入字符集',
packages_business_auto_fill_join_fields: '智能填充关联条件',
packages_business_auto_fill_join_tooltip_title: '開啓後,系統將按以下優先級自動填充關聯條件:',
packages_business_auto_fill_join_tooltip_primary: '1. 優先使用主鍵字段',
packages_business_auto_fill_join_tooltip_all: '2. 如無主鍵,則使用全部字段'
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@
@click="autoAddTable"
>{{ $t('packages_business_verification_button_auto_add_table') }}
</ElButton>

<template v-if="!isCountOrHash">
<el-divider direction="vertical"></el-divider>
<div class="inline-flex align-items-center">
<span class="fs-7">{{ $t('packages_business_auto_fill_join_fields') }}</span>
<el-tooltip class="color-primary" effect="dark" placement="top">
<template #content>
<div>{{ $t('packages_business_auto_fill_join_tooltip_title') }}</div>
<div>{{ $t('packages_business_auto_fill_join_tooltip_primary') }}</div>
<div>{{ $t('packages_business_auto_fill_join_tooltip_all') }}</div>
</template>
<i class="el-icon-question"></i>
</el-tooltip>
<el-switch class="ml-3" v-model="autoSuggestJoinFields" />
</div>
</template>
</div>
<ElDialog
width="60%"
Expand Down Expand Up @@ -994,7 +1010,8 @@ export default {
}
}
}
}
},
autoSuggestJoinFields: true
}
},
Expand Down Expand Up @@ -1449,7 +1466,12 @@ export default {
.map(t => t.original_field_name)
.join(',')
}
item.source.fields = findTable.fields
item.source.fields = findTable.fields.map(t => {
t.isPrimaryKey = t.primary_key_position > 0
return t
})
item.source.sortColumn = sourceSortColumn
const key = [source || '', sourceConnectionId, item.source.table].join()
this.fieldsMap[key] = item.source.fields
Expand All @@ -1459,12 +1481,22 @@ export default {
const targetSortColumn = updateList.length
? updateList.join(',')
: this.getPrimaryKeyFieldStr(findTargetTable.fields)
item.target.fields = findTargetTable.fields
item.target.fields = findTargetTable.fields.map(t => {
t.isPrimaryKey = t.primary_key_position > 0
return t
})
item.target.sortColumn = targetSortColumn
const key = [target || '', targetConnectionId, item.target.table].join()
this.fieldsMap[key] = item.target.fields
}
if (this.autoSuggestJoinFields && !item.source.sortColumn && !item.target.sortColumn) {
item.source.sortColumn = item.source.fields.map(t => t.field_name).join(',')
item.target.sortColumn = item.target.fields.map(t => t.field_name).join(',')
}
list.push(item)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineComponent({
setup(props, { emit }) {
const selectFields = computed({
get() {
return props.value.split(',')
return props.value ? props.value.split(',') : []
},
set(val) {
emit('input', val?.length ? Array.from(new Set(val.filter(v => !!v.trim()))).join(',') : '')
Expand All @@ -41,8 +41,6 @@ export default defineComponent({
emit('focus')
}
console.log('props.options', props.options)
return {
selectFields,
handleFocus
Expand Down

0 comments on commit babe807

Please sign in to comment.