2021-03-29 05:35:23 +00:00
|
|
|
<template>
|
2021-03-30 13:48:15 +00:00
|
|
|
<q-card
|
|
|
|
bordered
|
|
|
|
style="position: relative; min-height: 3em"
|
|
|
|
:class="{ 'cursor-pointer': modelValue.link }"
|
|
|
|
@click="click"
|
|
|
|
>
|
2021-03-29 05:35:23 +00:00
|
|
|
<q-btn
|
2021-11-24 14:28:53 +00:00
|
|
|
v-if="modelValue.accept !== undefined"
|
2021-03-29 05:35:23 +00:00
|
|
|
round
|
|
|
|
dense
|
2021-11-24 14:28:53 +00:00
|
|
|
icon="mdi-trash-can"
|
2021-03-29 05:35:23 +00:00
|
|
|
size="sm"
|
|
|
|
color="negative"
|
|
|
|
class="q-ma-xs"
|
2021-11-24 14:28:53 +00:00
|
|
|
title="Löschen"
|
2021-03-29 05:35:23 +00:00
|
|
|
style="position: absolute; top: 0; right: 0"
|
2021-11-24 14:28:53 +00:00
|
|
|
@click="dismiss"
|
2021-03-29 22:28:18 +00:00
|
|
|
/>
|
2021-11-24 14:28:53 +00:00
|
|
|
<q-card-section class="q-pa-xs">
|
|
|
|
<div class="text-overline">{{ dateString }}</div>
|
|
|
|
<q-item style="padding: 1px">
|
|
|
|
<q-item-section v-if="modelValue.icon" side
|
|
|
|
><q-icon color="primary" :name="modelValue.icon"
|
|
|
|
/></q-item-section>
|
|
|
|
<q-item-section>{{ modelValue.text }}</q-item-section>
|
|
|
|
</q-item>
|
|
|
|
</q-card-section>
|
|
|
|
<q-card-actions v-if="modelValue.reject || modelValue.accept">
|
|
|
|
<q-btn
|
|
|
|
v-if="modelValue.accept"
|
|
|
|
icon="mdi-check"
|
|
|
|
color="positive"
|
|
|
|
label="Annehmen"
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
size="sm"
|
|
|
|
@click="accept"
|
|
|
|
/>
|
|
|
|
<q-btn
|
|
|
|
v-if="modelValue.reject"
|
|
|
|
icon="mdi-close"
|
|
|
|
color="negative"
|
|
|
|
label="Ablehnen"
|
|
|
|
flat
|
|
|
|
dense
|
|
|
|
size="sm"
|
|
|
|
@click="reject"
|
|
|
|
/>
|
|
|
|
</q-card-actions>
|
2021-03-29 05:35:23 +00:00
|
|
|
</q-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, PropType, computed } from 'vue';
|
2021-05-25 14:13:15 +00:00
|
|
|
import { formatDateTime } from '@flaschengeist/api';
|
|
|
|
import { FG_Plugin } from '@flaschengeist/types';
|
2021-03-29 22:28:18 +00:00
|
|
|
import { useRouter } from 'vue-router';
|
2021-03-29 05:35:23 +00:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
name: 'Notification',
|
|
|
|
props: {
|
|
|
|
modelValue: {
|
|
|
|
required: true,
|
2021-03-29 22:28:18 +00:00
|
|
|
type: Object as PropType<FG_Plugin.Notification>,
|
2021-03-29 05:35:23 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
emits: {
|
|
|
|
remove: (id: number) => !!id,
|
|
|
|
},
|
|
|
|
setup(props, { emit }) {
|
2021-03-29 22:28:18 +00:00
|
|
|
const router = useRouter();
|
2021-03-29 05:35:23 +00:00
|
|
|
const dateString = computed(() => formatDateTime(props.modelValue.time, true, true));
|
|
|
|
|
2021-03-29 22:28:18 +00:00
|
|
|
async function click() {
|
|
|
|
if (props.modelValue.link) await router.push(props.modelValue.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
function accept() {
|
2021-03-30 13:48:15 +00:00
|
|
|
if (typeof props.modelValue.accept === 'function')
|
|
|
|
void props.modelValue.accept().finally(() => emit('remove', props.modelValue.id));
|
2021-03-29 22:28:18 +00:00
|
|
|
else emit('remove', props.modelValue.id);
|
|
|
|
}
|
|
|
|
|
2021-11-24 14:28:53 +00:00
|
|
|
function reject() {
|
2021-03-30 13:48:15 +00:00
|
|
|
if (typeof props.modelValue.reject === 'function')
|
|
|
|
void props.modelValue.reject().finally(() => emit('remove', props.modelValue.id));
|
|
|
|
else emit('remove', props.modelValue.id);
|
2021-03-29 05:35:23 +00:00
|
|
|
}
|
|
|
|
|
2021-11-24 14:28:53 +00:00
|
|
|
function dismiss() {
|
|
|
|
if (typeof props.modelValue.dismiss === 'function')
|
|
|
|
void props.modelValue.dismiss().finally(() => emit('remove', props.modelValue.id));
|
|
|
|
else emit('remove', props.modelValue.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return { accept, click, dateString, dismiss, reject };
|
2021-03-29 05:35:23 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|