Skip to content
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

[Feature][UI Next][V1.0.0-Beta] Add hints to the password repeat. #9888

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions dolphinscheduler-ui-next/src/views/password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import Card from '@/components/card'
const password = defineComponent({
name: 'password',
setup() {
const { state, t } = useForm()
const { state, rules, t } = useForm()
const { handleUpdate } = useUpdate(state)

return { ...toRefs(state), t, handleUpdate }
return { ...toRefs(state), t, handleUpdate, rules }
},
render() {
const { t } = this
Expand All @@ -37,17 +37,28 @@ const password = defineComponent({
{{
default: () => (
<div>
<NForm rules={this.rules} ref='passwordFormRef'>
<NForm
rules={this.rules}
ref='passwordFormRef'
model={this.passwordForm}
>
<NFormItem label={t('password.password')} path='password'>
<NInput
type='password'
placeholder={t('password.password_tips')}
v-model={[this.passwordForm.password, 'value']}
onInput={() => {
this.rPasswordFormItemRef.validate({
trigger: 'password-input'
})
}}
/>
</NFormItem>
<NFormItem
ref='rPasswordFormItemRef'
label={t('password.confirm_password')}
path='confirmPassword'
first
>
<NInput
type='password'
Expand Down
40 changes: 24 additions & 16 deletions dolphinscheduler-ui-next/src/views/password/use-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,38 @@ export function useForm() {

const state = reactive({
passwordFormRef: ref(),
rPasswordFormItemRef: ref(),
passwordForm: {
password: '',
confirmPassword: ''
},
saving: false,
rules: {
password: {
saving: false
})

const rules = {
password: {
trigger: ['input', 'blur'],
required: true,
message: t('password.password_tips')
},
confirmPassword: [
{
trigger: ['input', 'blur'],
validator() {
if (state.passwordForm.password === '') {
return new Error(t('password.password_tips'))
}
}
required: true,
message: t('password.confirm_password_tips')
},
confirmPassword: {
trigger: ['input', 'blur'],
validator() {
if (state.passwordForm.confirmPassword === '') {
return new Error(t('password.confirm_password_tips'))
{
trigger: ['password-input', 'blur', 'input'],
message: t('password.two_password_entries_are_inconsistent'),
validator: (unuse: any, value: string) => {
if (value) {
return state.passwordForm.password === value
}
return true
}
}
} as FormRules
})
]
} as FormRules

return { state, t }
return { state, rules, t }
}