Add email language option to registration form

This commit is contained in:
Tusooa Zhu 2022-03-26 13:03:23 -04:00
parent d39de30221
commit 1d36ea5ec5
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
3 changed files with 25 additions and 3 deletions

View file

@ -37,7 +37,7 @@ export default {
required: true required: true
}, },
setLanguage: { setLanguage: {
type: String, type: Function,
required: true required: true
} }
}, },

View file

@ -1,6 +1,8 @@
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { required, requiredIf, sameAs } from '@vuelidate/validators' import { required, requiredIf, sameAs } from '@vuelidate/validators'
import { mapActions, mapState } from 'vuex' import { mapActions, mapState } from 'vuex'
import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'
import localeService from '../../services/locale/locale.service.js'
const registration = { const registration = {
setup () { return { v$: useVuelidate() } }, setup () { return { v$: useVuelidate() } },
@ -11,10 +13,14 @@ const registration = {
username: '', username: '',
password: '', password: '',
confirm: '', confirm: '',
reason: '' reason: '',
language: '',
}, },
captcha: {} captcha: {}
}), }),
components: {
InterfaceLanguageSwitcher
},
validations () { validations () {
return { return {
user: { user: {
@ -26,7 +32,8 @@ const registration = {
required, required,
sameAs: sameAs(this.user.password) sameAs: sameAs(this.user.password)
}, },
reason: { required: requiredIf(() => this.accountApprovalRequired) } reason: { required: requiredIf(() => this.accountApprovalRequired) },
language: {}
} }
} }
}, },
@ -64,6 +71,9 @@ const registration = {
this.user.captcha_solution = this.captcha.solution this.user.captcha_solution = this.captcha.solution
this.user.captcha_token = this.captcha.token this.user.captcha_token = this.captcha.token
this.user.captcha_answer_data = this.captcha.answer_data this.user.captcha_answer_data = this.captcha.answer_data
if (this.user.language) {
this.user.language = localeService.internalToBackendLocale(this.user.language)
}
this.v$.$touch() this.v$.$touch()

View file

@ -162,6 +162,18 @@
</ul> </ul>
</div> </div>
<div
class="form-group"
:class="{ 'form-group--error': $v.user.language.$error }"
>
<interface-language-switcher
for="email-language"
:prompt-text="$t('registration.email_language')"
:language="$v.user.language.$model"
:set-language="val => $v.user.language.$model = val"
/>
</div>
<div <div
v-if="accountApprovalRequired" v-if="accountApprovalRequired"
class="form-group" class="form-group"