Files
mealie/frontend/components/global/ReportTable.vue

73 lines
1.8 KiB
Vue
Raw Normal View History

<template>
<v-data-table
:headers="headers"
:items="items"
item-key="id"
class="elevation-0"
:items-per-page="50"
@click:row="($event, { item }) => handleRowClick(item)"
>
<template #[`item.category`]="{ item }">
{{ capitalize(item.category) }}
</template>
<template #[`item.timestamp`]="{ item }">
{{ $d(Date.parse(item.timestamp!), "long") }}
</template>
<template #[`item.status`]="{ item }">
{{ capitalize(item.status!) }}
</template>
<template #[`item.actions`]="{ item }">
<v-btn
icon
@click.stop="deleteReport(item.id)"
>
<v-icon>{{ $globals.icons.delete }}</v-icon>
</v-btn>
</template>
</v-data-table>
</template>
2026-03-23 21:18:25 +01:00
<script setup lang="ts">
import type { ReportSummary } from "~/lib/api/types/reports";
2026-03-23 21:18:25 +01:00
defineProps({
items: {
type: Array as () => Array<ReportSummary>,
required: true,
},
2026-03-23 21:18:25 +01:00
});
2026-03-23 21:18:25 +01:00
const emit = defineEmits<{
(e: "delete", id: string): void;
}>();
2026-03-23 21:18:25 +01:00
const i18n = useI18n();
const router = useRouter();
2026-03-23 21:18:25 +01:00
const headers = [
{ title: i18n.t("category.category"), value: "category", key: "category" },
{ title: i18n.t("general.name"), value: "name", key: "name" },
{ title: i18n.t("general.timestamp"), value: "timestamp", key: "timestamp" },
{ title: i18n.t("general.status"), value: "status", key: "status" },
{ title: i18n.t("general.delete"), value: "actions", key: "actions" },
];
2026-03-23 21:18:25 +01:00
function handleRowClick(item: ReportSummary) {
if (item.status === "in-progress") {
return;
}
2026-03-23 21:18:25 +01:00
router.push(`/group/reports/${item.id}`);
}
2026-03-23 21:18:25 +01:00
function capitalize(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
2026-03-23 21:18:25 +01:00
function deleteReport(id: string) {
emit("delete", id);
}
</script>
<style lang="scss" scoped></style>