mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update ConfigPanels using RoutableTabs
This commit is contained in:
parent
7d5d29af1e
commit
b7aa8117ec
1 changed files with 28 additions and 45 deletions
|
@ -1,67 +1,50 @@
|
||||||
<template>
|
<template>
|
||||||
<b-card no-body>
|
<routable-tabs
|
||||||
<b-tabs fill pills card>
|
:routes="routes_"
|
||||||
<slot name="before" />
|
v-bind="{ panels, forms, v: $v }"
|
||||||
|
v-on="$listeners"
|
||||||
<tab-form
|
|
||||||
v-for="{ name, id, sections, help, serverError } in panels" :key="id"
|
|
||||||
v-bind="{ name, id: id + '-form', validation: $v.forms[id], serverError }"
|
|
||||||
@submit.prevent.stop="$emit('submit', id)"
|
|
||||||
>
|
|
||||||
<template v-if="help" #disclaimer>
|
|
||||||
<div class="alert alert-info" v-html="help" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<slot :name="id + '-tab-before'" />
|
|
||||||
|
|
||||||
<template v-for="section in sections">
|
|
||||||
<div v-if="isVisible(section.visible, section)" :key="section.id" class="mb-5">
|
|
||||||
<b-card-title v-if="section.name" title-tag="h3">
|
|
||||||
{{ section.name }} <small v-if="section.help">{{ section.help }}</small>
|
|
||||||
</b-card-title>
|
|
||||||
|
|
||||||
<template v-for="(field, fname) in section.fields">
|
|
||||||
<form-field
|
|
||||||
v-if="isVisible(field.visible, field)" :key="fname"
|
|
||||||
v-model="forms[id][fname]" v-bind="field" :validation="$v.forms[id][fname]"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<slot :name="id + '-tab-after'" />
|
|
||||||
</tab-form>
|
|
||||||
|
|
||||||
<slot name="default" />
|
|
||||||
</b-tabs>
|
|
||||||
</b-card>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { validationMixin } from 'vuelidate'
|
import { validationMixin } from 'vuelidate'
|
||||||
|
|
||||||
import { configPanelsFieldIsVisible } from '@/helpers/yunohostArguments'
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ConfigPanels',
|
name: 'ConfigPanels',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
RoutableTabs: () => import('@/components/RoutableTabs.vue')
|
||||||
|
},
|
||||||
|
|
||||||
mixins: [validationMixin],
|
mixins: [validationMixin],
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
panels: { type: Array, default: undefined },
|
panels: { type: Array, default: undefined },
|
||||||
forms: { type: Object, default: undefined },
|
forms: { type: Object, default: undefined },
|
||||||
validations: { type: Object, default: undefined }
|
validations: { type: Object, default: undefined },
|
||||||
|
errors: { type: Object, default: undefined }, // never used
|
||||||
|
routes: { type: Array, default: null },
|
||||||
|
noRedirect: { type: Boolean, default: false }
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
routes_ () {
|
||||||
|
if (this.routes) return this.routes
|
||||||
|
return this.panels.map(panel => ({
|
||||||
|
to: { params: { tabId: panel.id } },
|
||||||
|
text: panel.name,
|
||||||
|
icon: panel.icon || 'wrench'
|
||||||
|
}))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
validations () {
|
validations () {
|
||||||
const v = this.validations
|
return { forms: this.validations }
|
||||||
return v ? { forms: v } : null
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
created () {
|
||||||
isVisible (expression, field) {
|
if (!this.noRedirect && !this.$route.params.tabId) {
|
||||||
return configPanelsFieldIsVisible(expression, field, this.forms)
|
this.$router.replace({ params: { tabId: this.panels[0].id } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue