mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge pull request #3051 from modoboa/fix/superadmin_creation
Fixed creation of superadmin with new UI
This commit is contained in:
@@ -67,6 +67,9 @@ export default {
|
||||
CreationForm
|
||||
},
|
||||
computed: {
|
||||
needsMailbox () {
|
||||
return this.account.role !== 'SuperAdmins' || (this.account.username && this.account.username.indexOf('@') !== -1)
|
||||
},
|
||||
summarySections () {
|
||||
const result = [
|
||||
{
|
||||
@@ -93,46 +96,47 @@ export default {
|
||||
type: 'yesno'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.$gettext('Mailbox'),
|
||||
items: [
|
||||
{ key: this.$gettext('Email'), value: this.account.mailbox.full_address },
|
||||
{
|
||||
key: this.$gettext('Quota'),
|
||||
value: (this.account.mailbox.use_domain_quota)
|
||||
? this.$gettext('Domain default value')
|
||||
: this.account.mailbox.quota
|
||||
},
|
||||
{
|
||||
key: this.$gettext('Message sending limit'),
|
||||
value: this.account.mailbox.message_limit
|
||||
},
|
||||
{
|
||||
key: this.$gettext('Send only account'),
|
||||
value: this.account.mailbox.is_send_only,
|
||||
type: 'yesno'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.$gettext('Aliases'),
|
||||
items: [
|
||||
{
|
||||
key: this.$gettext('Aliases'),
|
||||
value: this.account.aliases,
|
||||
type: 'list'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
if (this.needsMailbox) {
|
||||
return result.concat([
|
||||
{
|
||||
title: this.$gettext('Mailbox'),
|
||||
items: [
|
||||
{ key: this.$gettext('Email'), value: this.account.mailbox.full_address },
|
||||
{
|
||||
key: this.$gettext('Quota'),
|
||||
value: (this.account.mailbox.use_domain_quota)
|
||||
? this.$gettext('Domain default value')
|
||||
: this.account.mailbox.quota
|
||||
},
|
||||
{
|
||||
key: this.$gettext('Message sending limit'),
|
||||
value: this.account.mailbox.message_limit
|
||||
},
|
||||
{
|
||||
key: this.$gettext('Send only account'),
|
||||
value: this.account.mailbox.is_send_only,
|
||||
type: 'yesno'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: this.$gettext('Aliases'),
|
||||
items: [
|
||||
{
|
||||
key: this.$gettext('Aliases'),
|
||||
value: this.account.aliases,
|
||||
type: 'list'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
return result
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
account: this.getInitialForm(),
|
||||
steps: [
|
||||
},
|
||||
steps () {
|
||||
const result = [
|
||||
{
|
||||
name: 'role',
|
||||
title: this.$gettext('Role')
|
||||
@@ -140,16 +144,26 @@ export default {
|
||||
{
|
||||
name: 'identification',
|
||||
title: this.$gettext('Identification')
|
||||
},
|
||||
{
|
||||
name: 'mailbox',
|
||||
title: this.$gettext('Mailbox')
|
||||
},
|
||||
{
|
||||
name: 'aliases',
|
||||
title: this.$gettext('Aliases')
|
||||
}
|
||||
]
|
||||
if (this.needsMailbox) {
|
||||
return result.concat([
|
||||
{
|
||||
name: 'mailbox',
|
||||
title: this.$gettext('Mailbox')
|
||||
},
|
||||
{
|
||||
name: 'aliases',
|
||||
title: this.$gettext('Aliases')
|
||||
}
|
||||
])
|
||||
}
|
||||
return result
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
account: this.getInitialForm()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -175,11 +189,18 @@ export default {
|
||||
getObserver (step) {
|
||||
return this.$refs[`form_${step}`].$refs.observer
|
||||
},
|
||||
validateAccount () {
|
||||
if (this.account.mailbox.message_limit === '') {
|
||||
this.$set(this.account.mailbox, 'message_limit', undefined)
|
||||
preparePayload (payload) {
|
||||
if (payload.role === 'SuperAdmins' && payload.username && payload.username.indexOf('@') === -1) {
|
||||
delete payload.mailbox
|
||||
}
|
||||
return accounts.validate(this.account)
|
||||
if (payload.mailbox && payload.mailbox.message_limit === '') {
|
||||
this.$set(payload.mailbox, 'message_limit', undefined)
|
||||
}
|
||||
},
|
||||
validateAccount () {
|
||||
const payload = { ...this.account }
|
||||
this.preparePayload(payload)
|
||||
return accounts.validate(payload)
|
||||
},
|
||||
close () {
|
||||
this.account = this.getInitialForm()
|
||||
@@ -188,9 +209,7 @@ export default {
|
||||
},
|
||||
submit () {
|
||||
const data = { ...this.account }
|
||||
if (this.account.role === 'SuperAdmins' && this.account.username.indexOf('@') === -1) {
|
||||
delete data.mailbox
|
||||
}
|
||||
this.preparePayload(data)
|
||||
accounts.create(data).then(() => {
|
||||
bus.$emit('notification', { msg: this.$gettext('Account created') })
|
||||
this.$emit('created')
|
||||
@@ -200,6 +219,11 @@ export default {
|
||||
},
|
||||
mounted () {
|
||||
this.$store.dispatch('identities/fetchDomains')
|
||||
},
|
||||
watch: {
|
||||
'account.role' () {
|
||||
delete this.account.username
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<validation-provider
|
||||
v-slot="{ errors }"
|
||||
rules="required"
|
||||
vid="username"
|
||||
>
|
||||
<label class="m-label">{{ $gettext('Username') }}</label>
|
||||
<email-field
|
||||
@@ -56,7 +57,7 @@ export default {
|
||||
AccountPasswordForm,
|
||||
EmailField
|
||||
},
|
||||
props: ['value', 'account'],
|
||||
props: ['value'],
|
||||
data () {
|
||||
return {
|
||||
form: {}
|
||||
@@ -76,6 +77,7 @@ export default {
|
||||
methods: {
|
||||
reset () {
|
||||
this.form = {}
|
||||
this.$refs.passwordForm.reset()
|
||||
},
|
||||
async validateForm () {
|
||||
return await this.$refs.observer.validate() && await this.$refs.passwordForm.validate()
|
||||
@@ -84,8 +86,18 @@ export default {
|
||||
this.$emit('input', this.form)
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.form = { ...this.value }
|
||||
watch: {
|
||||
value: {
|
||||
handler (newValue) {
|
||||
if (newValue) {
|
||||
this.form = { ...newValue }
|
||||
} else {
|
||||
this.form = {}
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -116,15 +116,18 @@ export default {
|
||||
},
|
||||
async validate () {
|
||||
return await this.$refs.observer.validate()
|
||||
},
|
||||
reset () {
|
||||
if (this.account) {
|
||||
this.form.random_password = this.account.random_password
|
||||
if (this.form.random_password) {
|
||||
this.updatePassword(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (this.account) {
|
||||
this.form.random_password = this.account.random_password
|
||||
if (this.form.random_password) {
|
||||
this.updatePassword(true)
|
||||
}
|
||||
}
|
||||
this.reset()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -18,7 +18,7 @@ export const importExportMixin = {
|
||||
} else {
|
||||
bus.$emit('notification', { msg: resp.data.message, type: 'error' })
|
||||
}
|
||||
}).catch(error => {
|
||||
}).catch(() => {
|
||||
bus.$emit('notification', {
|
||||
msg: this.$gettext('CSV seems to be badly formatted'),
|
||||
type: 'error'
|
||||
|
||||
Reference in New Issue
Block a user