mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-11-26 11:14:23 +01:00
Better UX on failling to save parameters
This commit is contained in:
@@ -5,11 +5,22 @@
|
||||
</v-toolbar>
|
||||
|
||||
<v-tabs v-model="active">
|
||||
<v-tab v-for="(element, index) in displayableElements"
|
||||
:key="index"
|
||||
>
|
||||
{{ element.label }}
|
||||
</v-tab>
|
||||
<template v-for="(element, index) in displayableElements"
|
||||
>
|
||||
<v-tab
|
||||
v-if="tab_error.includes(index)"
|
||||
class="error_tab"
|
||||
:key="index"
|
||||
>
|
||||
{{ element.label }}
|
||||
</v-tab>
|
||||
<v-tab v-else
|
||||
:key="index"
|
||||
>
|
||||
{{ element.label }}
|
||||
</v-tab>
|
||||
</template>
|
||||
|
||||
<v-tabs-items v-model="active">
|
||||
<v-tab-item
|
||||
v-for="(element, index) in displayableElements"
|
||||
@@ -87,7 +98,8 @@ export default {
|
||||
structure: [],
|
||||
parameters: {},
|
||||
formErrors: {},
|
||||
label: ''
|
||||
label: '',
|
||||
tab_error: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -136,13 +148,25 @@ export default {
|
||||
},
|
||||
save () {
|
||||
this.formErrors = {}
|
||||
this.tab_error = []
|
||||
parameters.saveApplication(this.$route.params.app, this.parameters).then(() => {
|
||||
bus.$emit('notification', { msg: this.$gettext('Parameters updated') })
|
||||
if (this.$route.params.app === 'imap_migration') {
|
||||
bus.$emit('imapSettingsChanged', this.parameters.enabled_imapmigration)
|
||||
}
|
||||
}).catch(error => {
|
||||
bus.$emit('notification', { msg: this.$gettext('Could not save parameters'), type: 'error' })
|
||||
this.formErrors = error.response.data
|
||||
Object.keys(this.formErrors).forEach(element => {
|
||||
for (let i = 0; i < this.structure.length; i++) {
|
||||
const isIn = (this.structure[i].parameters.filter(function (val, index, array) {
|
||||
return val.name === element
|
||||
}).length > 0)
|
||||
if (isIn) {
|
||||
this.tab_error.push(i)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -153,4 +177,7 @@ export default {
|
||||
.v-toolbar {
|
||||
background-color: #f7f8fa !important;
|
||||
}
|
||||
.v-application .primary--text .error_tab {
|
||||
color: #ff5252 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user