mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[fix] Empty quota doesn't work
This commit is contained in:
parent
d90cc05d58
commit
54df05d951
1 changed files with 13 additions and 9 deletions
|
@ -139,7 +139,7 @@ export default {
|
||||||
form: {
|
form: {
|
||||||
fullname: { firstname: '', lastname: '' },
|
fullname: { firstname: '', lastname: '' },
|
||||||
mail: { localPart: '', separator: '@', domain: '' },
|
mail: { localPart: '', separator: '@', domain: '' },
|
||||||
mailbox_quota: 0,
|
mailbox_quota: '',
|
||||||
mail_aliases: [],
|
mail_aliases: [],
|
||||||
mail_forward: [],
|
mail_forward: [],
|
||||||
password: '',
|
password: '',
|
||||||
|
@ -183,8 +183,7 @@ export default {
|
||||||
example: this.$i18n.t('mailbox_quota_example'),
|
example: this.$i18n.t('mailbox_quota_example'),
|
||||||
props: {
|
props: {
|
||||||
id: 'mailbox-quota',
|
id: 'mailbox-quota',
|
||||||
placeholder: this.$i18n.t('mailbox_quota_placeholder'),
|
placeholder: this.$i18n.t('mailbox_quota_placeholder')
|
||||||
type: 'number'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -228,7 +227,7 @@ export default {
|
||||||
mail: {
|
mail: {
|
||||||
localPart: { required, email: emailLocalPart }
|
localPart: { required, email: emailLocalPart }
|
||||||
},
|
},
|
||||||
mailbox_quota: { number: required, integer, minValue: minValue(0) },
|
mailbox_quota: { integer, minValue: minValue(0) },
|
||||||
mail_aliases: {
|
mail_aliases: {
|
||||||
$each: {
|
$each: {
|
||||||
localPart: { required, email: emailLocalPart }
|
localPart: { required, email: emailLocalPart }
|
||||||
|
@ -259,8 +258,11 @@ export default {
|
||||||
if (user['mail-forward']) {
|
if (user['mail-forward']) {
|
||||||
this.form.mail_forward = user['mail-forward'].slice() // Copy value
|
this.form.mail_forward = user['mail-forward'].slice() // Copy value
|
||||||
}
|
}
|
||||||
if (user['mailbox-quota'].limit !== 'No quota') {
|
// mailbox-quota could be 'No quota' or 'Pas de quota'...
|
||||||
|
if (parseInt(user['mailbox-quota'].limit) > 0) {
|
||||||
this.form.mailbox_quota = sizeToM(user['mailbox-quota'].limit)
|
this.form.mailbox_quota = sizeToM(user['mailbox-quota'].limit)
|
||||||
|
} else {
|
||||||
|
this.form.mailbox_quota = ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -268,7 +270,9 @@ export default {
|
||||||
const formData = formatFormData(this.form, { flatten: true })
|
const formData = formatFormData(this.form, { flatten: true })
|
||||||
const user = this.user(this.name)
|
const user = this.user(this.name)
|
||||||
const data = {}
|
const data = {}
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(formData, 'mailbox_quota')) {
|
||||||
|
formData.mailbox_quota = ''
|
||||||
|
}
|
||||||
for (const key of ['mail_aliases', 'mail_forward']) {
|
for (const key of ['mail_aliases', 'mail_forward']) {
|
||||||
const dashedKey = key.replace('_', '-')
|
const dashedKey = key.replace('_', '-')
|
||||||
const newKey = key.replace('_', '').replace('es', '')
|
const newKey = key.replace('_', '').replace('es', '')
|
||||||
|
@ -280,9 +284,9 @@ export default {
|
||||||
|
|
||||||
for (const key in formData) {
|
for (const key in formData) {
|
||||||
if (key === 'mailbox_quota') {
|
if (key === 'mailbox_quota') {
|
||||||
const quota = parseInt(formData[key]) !== 0 ? formData[key] + 'M' : 'No quota'
|
const quota = parseInt(formData[key]) > 0 ? formData[key] + 'M' : 'No quota'
|
||||||
if (quota !== user['mailbox-quota'].limit) {
|
if (parseInt(quota) !== parseInt(user['mailbox-quota'].limit)) {
|
||||||
data[key] = quota === 'No quota' ? 0 : quota
|
data[key] = quota === 'No quota' ? '0' : quota
|
||||||
}
|
}
|
||||||
} else if (!key.includes('mail_') && formData[key] !== user[key]) {
|
} else if (!key.includes('mail_') && formData[key] !== user[key]) {
|
||||||
data[key] = formData[key]
|
data[key] = formData[key]
|
||||||
|
|
Loading…
Reference in a new issue