update AbstractForm to be more generic

This commit is contained in:
axolotle 2022-02-06 20:31:53 +01:00
parent dc0868262e
commit c178347990

View file

@ -1,40 +1,37 @@
<template> <template>
<b-tab no-body> <div>
<template #title>
<icon :iname="icon" /> {{ name }}
</template>
<b-card-body> <b-card-body>
<slot name="disclaimer" /> <slot name="disclaimer" />
<b-form <b-form
:id="id" :inline="inline" :class="formClasses" :id="id" :inline="inline" :class="formClasses"
@submit.prevent="onSubmit" novalidate @submit.prevent="onSubmit" novalidate
> >
<slot name="default" /> <slot name="default" />
<slot name="server-error"> <slot name="server-error" v-bind="{ errorFeedback }">
<b-alert <b-alert
v-if="errorFeedback"
variant="danger" class="my-3" icon="ban" variant="danger" class="my-3" icon="ban"
:show="errorFeedback !== ''" v-html="errorFeedback" v-html="errorFeedback"
/> />
</slot> </slot>
</b-form> </b-form>
</b-card-body> </b-card-body>
<b-card-footer> <b-card-footer v-if="!noFooter">
<b-button type="submit" variant="success" :form="id"> <slot name="footer">
{{ submitText ? submitText : $t('save') }} <b-button type="submit" variant="success" :form="id">
</b-button> {{ submitText || $t('save') }}
</b-button>
</slot>
</b-card-footer> </b-card-footer>
</b-tab> </div>
</template> </template>
<script> <script>
export default { export default {
name: 'TabForm', name: 'AbstractForm',
props: { props: {
id: { type: String, default: 'ynh-form' }, id: { type: String, default: 'ynh-form' },
@ -43,8 +40,7 @@ export default {
serverError: { type: String, default: '' }, serverError: { type: String, default: '' },
inline: { type: Boolean, default: false }, inline: { type: Boolean, default: false },
formClasses: { type: [Array, String, Object], default: null }, formClasses: { type: [Array, String, Object], default: null },
name: { type: String, required: true }, noFooter: { type: Boolean, default: false }
icon: { type: String, default: 'wrench' }
}, },
computed: { computed: {