Add hint for inputs in Welcome Dialog

This commit is contained in:
2024-11-29 11:34:35 +01:00
parent 878c21be4f
commit 1d49f210c5
2 changed files with 33 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import actionDialog from '@/components/basics/actionDialog.vue';
import outlinedButton from '@/components/basics/outlinedButton.vue';
import ServerStateText from '@/components/pageParts/serverStateText.vue';
import { getRegisterNumberRules, getStringRules } from '@/scripts/validationRules';
import { useFeedbackStore } from '@/stores/feedback.store';
import { usePreferencesStore } from '@/stores/preferences.store';
import { ref, watch } from 'vue';
@@ -135,9 +136,9 @@ watch(() => currentStep.value, () => {
<v-col>
<v-text-field
variant="outlined"
hide-details
:label="$t('misc.yourFullName')"
v-model="preferencesStore.studentName"
:rules="getStringRules(4)"
/>
</v-col>
</v-row>
@@ -146,9 +147,9 @@ watch(() => currentStep.value, () => {
<v-col>
<v-text-field
variant="outlined"
hide-details
:label="$t('misc.registrationNumber')"
v-model="preferencesStore.registrationNumber"
:rules="getRegisterNumberRules()"
/>
</v-col>
</v-row>
@@ -177,8 +178,8 @@ watch(() => currentStep.value, () => {
<outlined-button
v-else
@click="showDialog = false; preferencesStore.firstStartup = false"
:disabled="preferencesStore.studentName.length == 0 ||
preferencesStore.registrationNumber.length == 0"
:disabled="preferencesStore.studentName.length < 5 ||
preferencesStore.registrationNumber.length < 8"
prepend-icon="mdi-check"
color="success"
>

View File

@@ -169,3 +169,31 @@ export function getIbanRules() {
}
]
}
export function getRegisterNumberRules() {
const feedbackStore = useFeedbackStore()
return [
value => {
if (value) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.required')
}
},
value => {
if (value?.length >= 8) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.notEnoughChars')
}
},
value => {
if(!isNaN(value) && !isNaN(parseFloat(value))) {
return true
} else {
return feedbackStore.i18n.t('misc.validation.onlyDigitsAllowed')
}
}
]
}