fix SplittedMailInput default value

This commit is contained in:
Axolotle 2020-07-27 21:25:41 +02:00
parent bbc94179b3
commit 4d4dd4fe4f
3 changed files with 20 additions and 4 deletions

View file

@ -28,13 +28,13 @@ export default {
},
data () {
return {
mail: this.value.split('@')[0],
domain: this.value.split('@')[1]
mail: '',
domain: ''
}
},
watch: {
domains () {
if (this.domain === undefined) {
if (!this.domain) {
this.domain = this.domains[0]
}
}
@ -43,6 +43,17 @@ export default {
updateValue () {
this.$emit('input', `${this.mail}@${this.domain}`)
}
},
created () {
if (this.value) {
const [mail, domain] = this.value.split('@')
Object.assign(this, { mail, domain })
} else if (this.domains) {
this.domain = this.domains[0]
}
// if (this.domain === undefined) {
// this.domain = this.domains[0]
// }
}
}
</script>

View file

@ -2,6 +2,7 @@
<div class="user-create">
<b-card :header="$t('users_new')" header-tag="h2">
<b-form id="user-create" @submit.prevent="onSubmit">
<!-- USER NAME -->
<b-form-group label-cols="auto" :label="$t('user_username')" label-for="input-username">
<b-input
id="input-username" :placeholder="$t('placeholder.username')"
@ -14,6 +15,7 @@
</b-form-invalid-feedback>
</b-form-group>
<!-- USER FULLNAME -->
<b-form-group label-cols="auto">
<template v-slot:label aria-hidden="true">
{{ $t('user_fullname') }}
@ -50,6 +52,7 @@
</div>
</b-form-group>
<!-- USER EMAIL -->
<b-form-group label-cols="auto" :label="$t('user_email')" label-for="input-email">
<splitted-mail-input
id="input-email" feedback="email-feedback"
@ -62,6 +65,7 @@
</b-form-invalid-feedback>
</b-form-group>
<!-- MAILBOX QUOTA -->
<b-form-group
label-cols="auto" :label="$t('user_mailbox_quota')" label-for="input-mailbox-quota"
:description="$t('mailbox_quota_description')"
@ -74,6 +78,7 @@
</b-input-group>
</b-form-group>
<!-- USER PASSWORD -->
<b-form-group label-cols="auto" :label="$t('password')" label-for="input-password">
<b-input
id="input-password" placeholder="••••••••"
@ -86,6 +91,7 @@
</b-form-invalid-feedback>
</b-form-group>
<!-- USER PASSWORD CONFIRMATION -->
<b-form-group
label-cols="auto" :label="$t('password_confirmation')" label-for="input-confirmation"
:description="$t('good_practices_about_user_password')"

View file

@ -244,7 +244,6 @@ export default {
this.form['mail-aliases'] = userData['mail-aliases'] ? [...userData['mail-aliases'], ''] : ['']
this.form['mail-forward'] = userData['mail-forward'] ? [...userData['mail-forward'], ''] : ['']
if (userData['mailbox-quota'].limit !== 'No quota') {
console.log(userData['mailbox-quota'])
this.form['mailbox-quota'] = userData['mailbox-quota'].limit.slice(0, -1)
}
})