mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
testing component for self domain email
This commit is contained in:
parent
7d40b380e2
commit
68dff35b23
3 changed files with 70 additions and 28 deletions
48
app/src/components/SplittedMailInput.vue
Normal file
48
app/src/components/SplittedMailInput.vue
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<b-input-group>
|
||||||
|
<b-input
|
||||||
|
:id="id" :placeholder="$t(placeholder)" :aria-describedby="feedback"
|
||||||
|
v-model="mail" @input="updateValue" :state="state"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<b-input-group-append>
|
||||||
|
<b-input-group-text>@</b-input-group-text>
|
||||||
|
</b-input-group-append>
|
||||||
|
|
||||||
|
<b-input-group-append>
|
||||||
|
<b-select v-model="domain" :options="domains" @change="updateValue" />
|
||||||
|
</b-input-group-append>
|
||||||
|
</b-input-group>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'SplittedMailInput',
|
||||||
|
props: {
|
||||||
|
value: { type: String, required: true },
|
||||||
|
domains: { type: null, required: true },
|
||||||
|
placeholder: { type: String, default: 'placeholder.username' },
|
||||||
|
id: { type: String, default: null },
|
||||||
|
state: { type: null, default: null },
|
||||||
|
feedback: { type: String, default: null }
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
mail: this.value.split('@')[0],
|
||||||
|
domain: this.value.split('@')[1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
domains () {
|
||||||
|
if (this.domain === undefined) {
|
||||||
|
this.domain = this.domains[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateValue () {
|
||||||
|
this.$emit('input', `${this.mail}@${this.domain}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -31,6 +31,10 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.input-group {
|
.input-group {
|
||||||
|
.input-group-append ~ .input-group-append {
|
||||||
|
min-width: 40%;
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-bottom-left-radius: 0;
|
border-bottom-left-radius: 0;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{ $t('user_fullname') }}
|
{{ $t('user_fullname') }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div class="input-double" id="group-fullname">
|
<div class="input-double">
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<b-input-group-prepend
|
<b-input-group-prepend
|
||||||
tag="label" class="ssr-only" is-text
|
tag="label" class="ssr-only" is-text
|
||||||
|
@ -51,25 +51,14 @@
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group label-cols="auto" :label="$t('user_email')" label-for="input-email">
|
<b-form-group label-cols="auto" :label="$t('user_email')" label-for="input-email">
|
||||||
<b-input-group>
|
<splitted-mail-input
|
||||||
<b-input
|
id="input-email" feedback="email-feedback"
|
||||||
id="input-email" :placeholder="$t('placeholder.username')"
|
v-model="form.mail" :domains="domains"
|
||||||
aria-describedby="email-feedback"
|
:state="isValid.mail" @input="validateEmail"
|
||||||
v-model="form.email" required
|
|
||||||
:state="isValid.email" @input="validateEmail"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<b-input-group-append>
|
<b-form-invalid-feedback id="email-feedback" :state="isValid.mail">
|
||||||
<b-input-group-text>@</b-input-group-text>
|
{{ this.error.mail }}
|
||||||
</b-input-group-append>
|
|
||||||
|
|
||||||
<b-input-group-append>
|
|
||||||
<b-select v-model="form.domain" :options="domains" required />
|
|
||||||
</b-input-group-append>
|
|
||||||
</b-input-group>
|
|
||||||
|
|
||||||
<b-form-invalid-feedback id="email-feedback" :state="isValid.email">
|
|
||||||
{{ this.error.email }}
|
|
||||||
</b-form-invalid-feedback>
|
</b-form-invalid-feedback>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
|
@ -129,6 +118,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import SplittedMailInput from '@/components/SplittedMailInput'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -136,21 +127,20 @@ export default {
|
||||||
username: '',
|
username: '',
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
email: '',
|
mail: '',
|
||||||
domain: '',
|
|
||||||
mailbox_quota: '',
|
mailbox_quota: '',
|
||||||
password: '',
|
password: '',
|
||||||
confirmation: ''
|
confirmation: ''
|
||||||
},
|
},
|
||||||
isValid: {
|
isValid: {
|
||||||
username: null,
|
username: null,
|
||||||
email: null,
|
mail: null,
|
||||||
password: null,
|
password: null,
|
||||||
confirmation: null
|
confirmation: null
|
||||||
},
|
},
|
||||||
error: {
|
error: {
|
||||||
username: '',
|
username: '',
|
||||||
email: ''
|
mail: ''
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
isValid: null,
|
isValid: null,
|
||||||
|
@ -174,7 +164,6 @@ export default {
|
||||||
const data = JSON.parse(JSON.stringify(this.form))
|
const data = JSON.parse(JSON.stringify(this.form))
|
||||||
const quota = data.mailbox_quota
|
const quota = data.mailbox_quota
|
||||||
data.mailbox_quota = parseInt(quota) ? quota + 'M' : 0
|
data.mailbox_quota = parseInt(quota) ? quota + 'M' : 0
|
||||||
data.mail = `${data.email}@${data.domain}`
|
|
||||||
|
|
||||||
this.$store.dispatch('POST',
|
this.$store.dispatch('POST',
|
||||||
{ uri: 'users', data, param: data.username, storeKey: '' }
|
{ uri: 'users', data, param: data.username, storeKey: '' }
|
||||||
|
@ -209,7 +198,7 @@ export default {
|
||||||
|
|
||||||
validateEmail () {
|
validateEmail () {
|
||||||
// FIXME check allowed characters
|
// FIXME check allowed characters
|
||||||
const isValid = this.form.email.match('^[A-Za-z0-9-_]+$')
|
const isValid = this.form.mail.split('@')[0].match('^[A-Za-z0-9-_]+$')
|
||||||
this.error.email = isValid ? '' : this.$i18n.t('form_errors.email_syntax')
|
this.error.email = isValid ? '' : this.$i18n.t('form_errors.email_syntax')
|
||||||
this.isValid.email = isValid ? null : false
|
this.isValid.email = isValid ? null : false
|
||||||
},
|
},
|
||||||
|
@ -222,10 +211,11 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
created () {
|
created () {
|
||||||
this.$store.dispatch('FETCH', { uri: 'domains' }).then(domains => {
|
this.$store.dispatch('FETCH', { uri: 'domains' })
|
||||||
this.form.domain = domains[0]
|
|
||||||
})
|
|
||||||
this.$store.dispatch('FETCH', { uri: 'users' })
|
this.$store.dispatch('FETCH', { uri: 'users' })
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
SplittedMailInput
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue