fix: #319 only allow confirm button when all the fields are filled in
This commit is contained in:
@@ -265,6 +265,10 @@ export default defineComponent({
|
|||||||
await router.push('/account-admin');
|
await router.push('/account-admin');
|
||||||
break;
|
break;
|
||||||
case MODAL_ACCT_EDIT:
|
case MODAL_ACCT_EDIT:
|
||||||
|
await checkAccountIsUnique();
|
||||||
|
if(!isAccountUnique.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 要注意的是舊的username跟新的username可以是不同的
|
// 要注意的是舊的username跟新的username可以是不同的
|
||||||
await acctMgmtStore.editAccount(
|
await acctMgmtStore.editAccount(
|
||||||
currentViewingUser.value.username, {
|
currentViewingUser.value.username, {
|
||||||
@@ -305,31 +309,19 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
watch(
|
||||||
watch(
|
[inputPwd, inputConfirmPwd, inputUserAccount, inputName],
|
||||||
[inputUserAccount, inputName, inputPwd, inputConfirmPwd, isPwdMatched],
|
([newPwd, newConfirmPwd, newAccount, newName]) => {
|
||||||
([newAccount, newName, newPwd, newConfirmPwd, newPwdMatched]) => {
|
isPwdMatched.value = newPwd === newConfirmPwd && newPwd.length;
|
||||||
if (shouldDisalbeConfirmButton(newAccount, newName, newPwd, newConfirmPwd, newPwdMatched)) {
|
isPwdLengthValid.value = newPwd.length >= PWD_VALID_LENGTH && newConfirmPwd.length >= PWD_VALID_LENGTH;
|
||||||
isConfirmDisabled.value = true;
|
// 只要[確認密碼]或[密碼]欄位有更動,且所有欄位都不是空的,confirm 按鈕就可點選
|
||||||
} else {
|
if (newPwd.length > 0 && newConfirmPwd.length > 0 && newAccount.length > 0 && newName.length > 0) {
|
||||||
isConfirmDisabled.value = false;
|
isConfirmDisabled.value = false;
|
||||||
}
|
} else {
|
||||||
},
|
isConfirmDisabled.value = true;
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
[inputPwd, inputConfirmPwd],
|
|
||||||
([newPwd, newConfirmPwd]) => {
|
|
||||||
isPwdMatched.value = newPwd === newConfirmPwd && newPwd.length;
|
|
||||||
isPwdLengthValid.value = newPwd.length >= PWD_VALID_LENGTH && newConfirmPwd.length >= PWD_VALID_LENGTH;
|
|
||||||
// 只要[確認密碼]或[密碼]有更動,confirm 按鈕就可點選
|
|
||||||
if ((newPwd || newConfirmPwd) && inputUserAccount.length && inputName.length) {
|
|
||||||
isConfirmDisabled.value = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isConfirmDisabled,
|
isConfirmDisabled,
|
||||||
|
|||||||
Reference in New Issue
Block a user