This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/misc/create-edit.vue

97 lines
1.6 KiB
Vue
Raw Normal View History

<template>
2024-02-07 11:18:19 +00:00
<modal
:overflow="true"
:wide="wide"
@close="$router.back()"
>
<card
:title="title"
:shadow="false"
:padding="false"
class="has-text-left"
:has-close="true"
:loading="loading"
2024-02-07 11:18:19 +00:00
@close="$router.back()"
>
<div class="p-4">
2024-02-07 11:18:19 +00:00
<slot />
</div>
<template #footer>
<slot name="footer">
<x-button
v-if="tertiary !== ''"
:shadow="false"
variant="tertiary"
@click.prevent.stop="$emit('tertiary')"
>
{{ tertiary }}
</x-button>
<x-button
variant="secondary"
@click.prevent.stop="$router.back()"
>
{{ $t('misc.cancel') }}
</x-button>
<x-button
v-if="hasPrimaryAction"
variant="primary"
:icon="primaryIcon"
:disabled="primaryDisabled || loading"
class="ml-2"
2024-02-07 11:18:19 +00:00
@click.prevent.stop="primary()"
>
{{ primaryLabel || $t('misc.create') }}
</x-button>
</slot>
</template>
</card>
</modal>
</template>
2022-02-15 12:07:59 +00:00
<script setup lang="ts">
import type {PropType} from 'vue'
import type {IconProp} from '@fortawesome/fontawesome-svg-core'
2022-02-15 12:07:59 +00:00
defineProps({
title: {
type: String,
default: '',
},
2022-02-15 12:07:59 +00:00
primaryLabel: {
type: String,
},
2022-02-15 12:07:59 +00:00
primaryIcon: {
type: String as PropType<IconProp>,
2022-02-15 12:07:59 +00:00
default: 'plus',
},
primaryDisabled: {
type: Boolean,
default: false,
},
hasPrimaryAction: {
type: Boolean,
default: true,
},
2022-02-15 12:07:59 +00:00
tertiary: {
type: String,
default: '',
},
wide: {
type: Boolean,
default: false,
},
loading: {
type: Boolean,
default: false,
},
})
2022-02-15 12:07:59 +00:00
const emit = defineEmits(['create', 'primary', 'tertiary'])
function primary() {
emit('create')
emit('primary')
}
</script>