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

94 lines
1.7 KiB
Vue
Raw Normal View History

<template>
2022-11-14 18:02:28 +00:00
<modal :overflow="true" :wide="wide" #default="{ onClose }">
<card
:title="title"
:shadow="false"
:padding="false"
class="has-text-left"
:has-close="true"
2022-11-14 18:02:28 +00:00
@close="onClose"
:loading="loading"
>
<div class="p-4">
2022-11-14 18:02:28 +00:00
<slot :onClose="onClose" />
</div>
<template #footer>
2022-11-14 18:02:28 +00:00
<slot name="footer" :onClose="onClose">
<x-button
v-if="tertiary !== ''"
:shadow="false"
variant="tertiary"
2022-11-14 18:02:28 +00:00
@click="$emit('tertiary')"
>
{{ tertiary }}
</x-button>
<x-button
variant="secondary"
2022-11-14 18:02:28 +00:00
@click="onClose"
>
{{ $t('misc.cancel') }}
</x-button>
<x-button
v-if="hasPrimaryAction"
variant="primary"
2022-11-14 18:02:28 +00:00
@click="primary(onClose)"
:icon="primaryIcon"
:disabled="primaryDisabled || loading"
class="ml-2"
>
{{ 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-11-14 18:02:28 +00:00
// 'close'
2022-02-15 12:07:59 +00:00
const emit = defineEmits(['create', 'primary', 'tertiary'])
2022-11-14 18:02:28 +00:00
function primary(onClose: () => void) {
emit('create', onClose)
emit('primary', onClose)
}
</script>