Browse Source

[Improvement-14201][UI] Improve the select component to support users to filter options. (#14202)

3.2.0-release
calvin 2 years ago committed by GitHub
parent
commit
c6ac356134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 48
      dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx
  2. 44
      dolphinscheduler-ui/src/views/projects/workflow/relation/index.tsx
  3. 48
      dolphinscheduler-ui/src/views/projects/workflow/timing/components/timing-condition.tsx

48
dolphinscheduler-ui/src/views/projects/workflow/instance/components/process-instance-condition.tsx

@ -25,13 +25,14 @@ import {
NSpace, NSpace,
NEllipsis NEllipsis
} from 'naive-ui' } from 'naive-ui'
import { defineComponent, getCurrentInstance, h, ref } from 'vue' import { defineComponent, getCurrentInstance, h, ref, unref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { format } from 'date-fns' import { format } from 'date-fns'
import { workflowExecutionStateType } from '@/common/common' import { workflowExecutionStateType } from '@/common/common'
import { queryProcessDefinitionList } from '@/service/modules/process-definition' import { queryProcessDefinitionList } from '@/service/modules/process-definition'
import { SelectMixedOption } from 'naive-ui/lib/select/src/interface' import { SelectMixedOption } from 'naive-ui/lib/select/src/interface'
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import { SelectOption } from 'naive-ui/es/select/src/interface'
export default defineComponent({ export default defineComponent({
name: 'ProcessInstanceCondition', name: 'ProcessInstanceCondition',
@ -111,6 +112,19 @@ export default defineComponent({
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
const selectFilter = (query: string, option: SelectOption) => {
return option.filterLabel
? option.filterLabel
.toString()
.toLowerCase()
.includes(query.toLowerCase())
: false
}
const updateValue = (value: number) => {
processDefineCodeRef.value = value
}
return { return {
searchValRef, searchValRef,
executorNameRef, executorNameRef,
@ -123,23 +137,37 @@ export default defineComponent({
onClearSearchHost, onClearSearchHost,
trim, trim,
processDefinitionOptions, processDefinitionOptions,
processDefineCodeRef processDefineCodeRef,
selectFilter,
updateValue
} }
}, },
render() { render() {
const { t } = useI18n() const { t } = useI18n()
const options = workflowExecutionStateType(t) const options = workflowExecutionStateType(t)
const {
processDefinitionOptions,
processDefineCodeRef,
selectFilter,
updateValue
} = this
return ( return (
<NSpace justify='end'> <NSpace justify='end'>
<NSelect {h(NSelect, {
clearable style: {
filterable width: '210px'
options={this.processDefinitionOptions} },
size='small' size: 'small',
style={{ width: '210px' }} clearable: true,
v-model:value={this.processDefineCodeRef} filterable: true,
/> options: unref(processDefinitionOptions),
value: processDefineCodeRef,
filter: selectFilter,
onUpdateValue: (value: any) => {
updateValue(value)
}
})}
<NInput <NInput
allowInput={this.trim} allowInput={this.trim}
size='small' size='small'

44
dolphinscheduler-ui/src/views/projects/workflow/relation/index.tsx

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, onMounted, toRefs, watch, VNode, h } from 'vue' import { defineComponent, onMounted, toRefs, watch, VNode, h, unref } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { import {
@ -67,6 +67,16 @@ const workflowRelation = defineComponent({
default: () => option.label default: () => option.label
}) })
const selectFilter = (query: string, option: SelectOption) => {
return option.label
? option.label.toString().toLowerCase().includes(query.toLowerCase())
: false
}
const updateValue = (value: any) => {
variables.workflow = value
}
watch( watch(
() => [variables.workflow, variables.labelShow, locale.value], () => [variables.workflow, variables.labelShow, locale.value],
() => { () => {
@ -74,7 +84,14 @@ const workflowRelation = defineComponent({
} }
) )
return { t, handleResetDate, ...toRefs(variables), renderOption } return {
t,
handleResetDate,
...toRefs(variables),
renderOption,
selectFilter,
updateValue
}
}, },
render() { render() {
const { t, handleResetDate } = this const { t, handleResetDate } = this
@ -103,15 +120,20 @@ const workflowRelation = defineComponent({
), ),
'header-extra': () => ( 'header-extra': () => (
<NSpace> <NSpace>
<NSelect {h(NSelect, {
clearable style: {
filterable width: '300px'
style={{ width: '300px' }} },
placeholder={t('project.workflow.workflow_name')} clearable: true,
options={this.workflowOptions} filterable: true,
v-model={[this.workflow, 'value']} placeholder: t('project.workflow.workflow_name'),
renderOption={this.renderOption} options: unref(this.workflowOptions),
/> value: this.workflow,
filter: this.selectFilter,
onUpdateValue: (value: any) => {
this.updateValue(value)
}
})}
<NTooltip trigger={'hover'}> <NTooltip trigger={'hover'}>
{{ {{
default: () => t('project.workflow.refresh'), default: () => t('project.workflow.refresh'),

48
dolphinscheduler-ui/src/views/projects/workflow/timing/components/timing-condition.tsx

@ -17,10 +17,11 @@
import { SearchOutlined } from '@vicons/antd' import { SearchOutlined } from '@vicons/antd'
import { NButton, NSelect, NIcon, NSpace, NEllipsis } from 'naive-ui' import { NButton, NSelect, NIcon, NSpace, NEllipsis } from 'naive-ui'
import { defineComponent, h, ref } from 'vue' import { defineComponent, h, ref, unref } from 'vue'
import { queryProcessDefinitionList } from '@/service/modules/process-definition' import { queryProcessDefinitionList } from '@/service/modules/process-definition'
import { SelectMixedOption } from 'naive-ui/lib/select/src/interface' import { SelectMixedOption } from 'naive-ui/lib/select/src/interface'
import { Router, useRouter } from 'vue-router' import { Router, useRouter } from 'vue-router'
import { SelectOption } from 'naive-ui/es/select/src/interface'
export default defineComponent({ export default defineComponent({
name: 'TimingCondition', name: 'TimingCondition',
@ -59,23 +60,50 @@ export default defineComponent({
}) })
} }
const selectFilter = (query: string, option: SelectOption) => {
return option.filterLabel
? option.filterLabel
.toString()
.toLowerCase()
.includes(query.toLowerCase())
: false
}
const updateValue = (value: number) => {
processDefineCodeRef.value = value
}
return { return {
handleSearch, handleSearch,
processDefinitionOptions, processDefinitionOptions,
processDefineCodeRef processDefineCodeRef,
selectFilter,
updateValue
} }
}, },
render() { render() {
const {
processDefineCodeRef,
processDefinitionOptions,
selectFilter,
updateValue
} = this
return ( return (
<NSpace justify='end'> <NSpace justify='end'>
<NSelect {h(NSelect, {
clearable style: {
filterable width: '310px'
options={this.processDefinitionOptions} },
size='small' size: 'small',
style={{ width: '310px' }} clearable: true,
v-model:value={this.processDefineCodeRef} filterable: true,
/> value: processDefineCodeRef,
options: unref(processDefinitionOptions),
filter: selectFilter,
onUpdateValue: (value: any) => {
updateValue(value)
}
})}
<NButton type='primary' size='small' onClick={this.handleSearch}> <NButton type='primary' size='small' onClick={this.handleSearch}>
<NIcon> <NIcon>
<SearchOutlined /> <SearchOutlined />

Loading…
Cancel
Save