diff --git a/frontend/src/components/identities/AccountCreationForm.vue b/frontend/src/components/identities/AccountCreationForm.vue index d7068fb87..4c4983651 100644 --- a/frontend/src/components/identities/AccountCreationForm.vue +++ b/frontend/src/components/identities/AccountCreationForm.vue @@ -175,11 +175,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 +195,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') diff --git a/frontend/src/components/identities/AccountGeneralForm.vue b/frontend/src/components/identities/AccountGeneralForm.vue index b680756ca..856d0436d 100644 --- a/frontend/src/components/identities/AccountGeneralForm.vue +++ b/frontend/src/components/identities/AccountGeneralForm.vue @@ -56,7 +56,7 @@ export default { AccountPasswordForm, EmailField }, - props: ['value', 'account'], + props: ['value'], data () { return { form: {} @@ -76,6 +76,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 +85,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 + } } } diff --git a/frontend/src/components/identities/AccountPasswordForm.vue b/frontend/src/components/identities/AccountPasswordForm.vue index 556019394..d6b61edcb 100644 --- a/frontend/src/components/identities/AccountPasswordForm.vue +++ b/frontend/src/components/identities/AccountPasswordForm.vue @@ -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() } } diff --git a/frontend/src/mixins/importExport.js b/frontend/src/mixins/importExport.js index 12139d036..202751635 100644 --- a/frontend/src/mixins/importExport.js +++ b/frontend/src/mixins/importExport.js @@ -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'