Tweaked training report edit to be an icon instead of text

This commit is contained in:
2026-04-06 21:02:29 -04:00
parent f0507beb88
commit 7bbf30f9c0

View File

@@ -1,73 +1,73 @@
<script setup lang="ts"> <script setup lang="ts">
import { getTrainingReport, getTrainingReports } from '@/api/trainingReport'; import { getTrainingReport, getTrainingReports } from '@/api/trainingReport';
import { CourseAttendee, CourseEventDetails, CourseEventSummary } from '@shared/types/course'; import { CourseAttendee, CourseEventDetails, CourseEventSummary } from '@shared/types/course';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'; import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { import {
Table, Table,
TableBody, TableBody,
TableCell, TableCell,
TableHead, TableHead,
TableHeader, TableHeader,
TableRow, TableRow,
} from '@/components/ui/table' } from '@/components/ui/table'
import { ArrowUpDown, ChevronDown, ChevronLeft, ChevronUp, Funnel, Link, Plus, Search, X } from 'lucide-vue-next'; import { ArrowUpDown, ChevronDown, ChevronLeft, ChevronUp, Funnel, Link, Pencil, Plus, Search, X } from 'lucide-vue-next';
import Button from '@/components/ui/button/Button.vue'; import Button from '@/components/ui/button/Button.vue';
import TrainingReportForm from '@/components/trainingReport/trainingReportForm.vue'; import TrainingReportForm from '@/components/trainingReport/trainingReportForm.vue';
import Checkbox from '@/components/ui/checkbox/Checkbox.vue'; import Checkbox from '@/components/ui/checkbox/Checkbox.vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import Select from '@/components/ui/select/Select.vue'; import Select from '@/components/ui/select/Select.vue';
import SelectTrigger from '@/components/ui/select/SelectTrigger.vue'; import SelectTrigger from '@/components/ui/select/SelectTrigger.vue';
import SelectValue from '@/components/ui/select/SelectValue.vue'; import SelectValue from '@/components/ui/select/SelectValue.vue';
import SelectContent from '@/components/ui/select/SelectContent.vue'; import SelectContent from '@/components/ui/select/SelectContent.vue';
import SelectItem from '@/components/ui/select/SelectItem.vue'; import SelectItem from '@/components/ui/select/SelectItem.vue';
import Input from '@/components/ui/input/Input.vue'; import Input from '@/components/ui/input/Input.vue';
import MemberCard from '@/components/members/MemberCard.vue'; import MemberCard from '@/components/members/MemberCard.vue';
import Spinner from '@/components/ui/spinner/Spinner.vue'; import Spinner from '@/components/ui/spinner/Spinner.vue';
import { pagination } from '@shared/types/pagination'; import { pagination } from '@shared/types/pagination';
import { import {
Pagination, Pagination,
PaginationContent, PaginationContent,
PaginationEllipsis, PaginationEllipsis,
PaginationItem, PaginationItem,
PaginationNext, PaginationNext,
PaginationPrevious, PaginationPrevious,
} from '@/components/ui/pagination' } from '@/components/ui/pagination'
import Tooltip from '@/components/tooltip/Tooltip.vue'; import Tooltip from '@/components/tooltip/Tooltip.vue';
import { CopyLink } from '@/lib/copyLink'; import { CopyLink } from '@/lib/copyLink';
import { useUserStore } from '@/stores/user'; import { useUserStore } from '@/stores/user';
enum sidePanelState { view, create, edit, closed }; enum sidePanelState { view, create, edit, closed };
const trainingReports = ref<CourseEventSummary[] | null>(null); const trainingReports = ref<CourseEventSummary[] | null>(null);
const loaded = ref(false); const loaded = ref(false);
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const user = useUserStore(); const user = useUserStore();
const sidePanel = computed<sidePanelState>(() => { const sidePanel = computed<sidePanelState>(() => {
if (route.path.endsWith('/edit')) return sidePanelState.edit; if (route.path.endsWith('/edit')) return sidePanelState.edit;
if (route.path.endsWith('/new')) return sidePanelState.create; if (route.path.endsWith('/new')) return sidePanelState.create;
if (route.params.id) return sidePanelState.view; if (route.params.id) return sidePanelState.view;
return sidePanelState.closed; return sidePanelState.closed;
}) })
const isMobile = ref(false); const isMobile = ref(false);
const mobilePanel = ref<sidePanelState>(sidePanelState.closed); const mobilePanel = ref<sidePanelState>(sidePanelState.closed);
let mobileMediaQuery: MediaQueryList | null = null; let mobileMediaQuery: MediaQueryList | null = null;
function syncMobileMode() { function syncMobileMode() {
isMobile.value = mobileMediaQuery?.matches ?? window.innerWidth < 1024; isMobile.value = mobileMediaQuery?.matches ?? window.innerWidth < 1024;
if (!isMobile.value) { if (!isMobile.value) {
mobilePanel.value = sidePanelState.closed; mobilePanel.value = sidePanelState.closed;
} }
} }
const effectivePanel = computed<sidePanelState>(() => { const effectivePanel = computed<sidePanelState>(() => {
return isMobile.value ? mobilePanel.value : sidePanel.value; return isMobile.value ? mobilePanel.value : sidePanel.value;
}) })
watch(() => route.params.id, async (newID) => { watch(() => route.params.id, async (newID) => {
if (!newID) { if (!newID) {
focusedTrainingReport.value = null; focusedTrainingReport.value = null;
return; return;
@@ -75,32 +75,32 @@ watch(() => route.params.id, async (newID) => {
TRLoaded.value = false; TRLoaded.value = false;
expanded.value = null; expanded.value = null;
viewTrainingReport(Number(route.params.id)); viewTrainingReport(Number(route.params.id));
}) })
const focusedTrainingReport = ref<CourseEventDetails | null>(null); const focusedTrainingReport = ref<CourseEventDetails | null>(null);
const focusedTrainingTrainees = computed<CourseAttendee[] | null>(() => { const focusedTrainingTrainees = computed<CourseAttendee[] | null>(() => {
if (focusedTrainingReport.value == null) return null; if (focusedTrainingReport.value == null) return null;
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'Trainee'); return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'Trainee');
}) })
const focusedNoShows = computed<CourseAttendee[] | null>(() => { const focusedNoShows = computed<CourseAttendee[] | null>(() => {
if (focusedTrainingReport.value == null) return null; if (focusedTrainingReport.value == null) return null;
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'No-Show'); return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name == 'No-Show');
}) })
const focusedTrainingTrainers = computed<CourseAttendee[] | null>(() => { const focusedTrainingTrainers = computed<CourseAttendee[] | null>(() => {
if (focusedTrainingReport.value == null) return null; if (focusedTrainingReport.value == null) return null;
return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name != 'Trainee' && attendee.role.name != 'No-Show'); return focusedTrainingReport.value.attendees.filter((attendee) => attendee.role.name != 'Trainee' && attendee.role.name != 'No-Show');
}) })
async function viewTrainingReport(id: number) { async function viewTrainingReport(id: number) {
focusedTrainingReport.value = await getTrainingReport(id); focusedTrainingReport.value = await getTrainingReport(id);
TRLoaded.value = true; TRLoaded.value = true;
} }
async function closeTrainingReport() { async function closeTrainingReport() {
router.push(`/trainingReport`) router.push(`/trainingReport`)
focusedTrainingReport.value = null; focusedTrainingReport.value = null;
} }
async function openTrainingReport(id: number) { async function openTrainingReport(id: number) {
if (isMobile.value) { if (isMobile.value) {
focusedTrainingReport.value = null; focusedTrainingReport.value = null;
TRLoaded.value = false; TRLoaded.value = false;
@@ -111,9 +111,9 @@ async function openTrainingReport(id: number) {
} }
router.push(`/trainingReport/${id}`); router.push(`/trainingReport/${id}`);
} }
async function openEditPanel() { async function openEditPanel() {
if (!focusedTrainingReport.value) return; if (!focusedTrainingReport.value) return;
if (isMobile.value) { if (isMobile.value) {
@@ -122,9 +122,9 @@ async function openEditPanel() {
} }
router.push(`/trainingReport/${focusedTrainingReport.value.id}/edit`); router.push(`/trainingReport/${focusedTrainingReport.value.id}/edit`);
} }
function openCreatePanel() { function openCreatePanel() {
if (isMobile.value) { if (isMobile.value) {
mobilePanel.value = sidePanelState.create; mobilePanel.value = sidePanelState.create;
focusedTrainingReport.value = null; focusedTrainingReport.value = null;
@@ -132,9 +132,9 @@ function openCreatePanel() {
} }
router.push('/trainingReport/new'); router.push('/trainingReport/new');
} }
async function closePanel() { async function closePanel() {
if (isMobile.value) { if (isMobile.value) {
mobilePanel.value = sidePanelState.closed; mobilePanel.value = sidePanelState.closed;
focusedTrainingReport.value = null; focusedTrainingReport.value = null;
@@ -144,9 +144,9 @@ async function closePanel() {
} }
await closeTrainingReport(); await closeTrainingReport();
} }
const canEditFocusedReport = computed<boolean>(() => { const canEditFocusedReport = computed<boolean>(() => {
const report = focusedTrainingReport.value; const report = focusedTrainingReport.value;
if (!report) return false; if (!report) return false;
@@ -155,31 +155,31 @@ const canEditFocusedReport = computed<boolean>(() => {
const isAdmin = user.hasRole('17th Administrator'); const isAdmin = user.hasRole('17th Administrator');
return isAuthor || isAdmin; return isAuthor || isAdmin;
}); });
const sortMode = ref<string>("descending"); const sortMode = ref<string>("descending");
const searchString = ref<string>(""); const searchString = ref<string>("");
let debounceTimer: ReturnType<typeof setTimeout> | null = null; let debounceTimer: ReturnType<typeof setTimeout> | null = null;
watch(searchString, (newValue) => { watch(searchString, (newValue) => {
if (debounceTimer) clearTimeout(debounceTimer); if (debounceTimer) clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => { debounceTimer = setTimeout(() => {
loadTrainingReports(); loadTrainingReports();
}, 300); // 300ms debounce }, 300); // 300ms debounce
}); });
watch(() => sortMode.value, async (newSortMode) => { watch(() => sortMode.value, async (newSortMode) => {
loadTrainingReports(); loadTrainingReports();
}) })
async function loadTrainingReports() { async function loadTrainingReports() {
let data = await getTrainingReports(sortMode.value, searchString.value, pageNum.value, pageSize.value); let data = await getTrainingReports(sortMode.value, searchString.value, pageNum.value, pageSize.value);
trainingReports.value = data.data; trainingReports.value = data.data;
pageData.value = data.pagination; pageData.value = data.pagination;
} }
onMounted(async () => { onMounted(async () => {
mobileMediaQuery = window.matchMedia('(max-width: 1023px)'); mobileMediaQuery = window.matchMedia('(max-width: 1023px)');
syncMobileMode(); syncMobileMode();
mobileMediaQuery.addEventListener('change', syncMobileMode); mobileMediaQuery.addEventListener('change', syncMobileMode);
@@ -188,21 +188,21 @@ onMounted(async () => {
if (route.params.id) if (route.params.id)
viewTrainingReport(Number(route.params.id)) viewTrainingReport(Number(route.params.id))
loaded.value = true; loaded.value = true;
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
mobileMediaQuery?.removeEventListener('change', syncMobileMode); mobileMediaQuery?.removeEventListener('change', syncMobileMode);
}) })
const TRLoaded = ref(false); const TRLoaded = ref(false);
const pageNum = ref<number>(1); const pageNum = ref<number>(1);
const pageData = ref<pagination>(); const pageData = ref<pagination>();
const pageSize = ref<number>(15) const pageSize = ref<number>(15)
const pageSizeOptions = [10, 15, 30] const pageSizeOptions = [10, 15, 30]
function formatDate(date: Date | string): string { function formatDate(date: Date | string): string {
if (!date) return ''; if (!date) return '';
const dateObj = typeof date === 'string' ? new Date(date) : date; const dateObj = typeof date === 'string' ? new Date(date) : date;
return dateObj.toLocaleDateString('en-US', { return dateObj.toLocaleDateString('en-US', {
@@ -210,20 +210,20 @@ function formatDate(date: Date | string): string {
month: 'short', month: 'short',
day: 'numeric', day: 'numeric',
}); });
} }
function setPageSize(size: number) { function setPageSize(size: number) {
pageSize.value = size pageSize.value = size
pageNum.value = 1; pageNum.value = 1;
loadTrainingReports(); loadTrainingReports();
} }
function setPage(pagenum: number) { function setPage(pagenum: number) {
pageNum.value = pagenum; pageNum.value = pagenum;
loadTrainingReports(); loadTrainingReports();
} }
const expanded = ref<number>(null); const expanded = ref<number>(null);
</script> </script>
<template> <template>
@@ -299,7 +299,8 @@ const expanded = ref<number>(null);
<TableBody v-if="loaded"> <TableBody v-if="loaded">
<TableRow class="cursor-pointer" v-for="report in trainingReports" :key="report.event_id" <TableRow class="cursor-pointer" v-for="report in trainingReports" :key="report.event_id"
@click="openTrainingReport(report.event_id)"> @click="openTrainingReport(report.event_id)">
<TableCell class="font-medium">{{ report.course_name.length > 30 ? report.course_shortname : <TableCell class="font-medium">{{ report.course_name.length > 30 ?
report.course_shortname :
report.course_name }}</TableCell> report.course_name }}</TableCell>
<TableCell>{{ report.date.split('T')[0] }}</TableCell> <TableCell>{{ report.date.split('T')[0] }}</TableCell>
<TableCell class="text-right"> <TableCell class="text-right">
@@ -353,8 +354,9 @@ const expanded = ref<number>(null);
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p> <p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Report Details</p>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Button v-if="canEditFocusedReport" @click="openEditPanel" class="cursor-pointer" variant="outline" size="sm"> <Button v-if="canEditFocusedReport" @click="openEditPanel" class="cursor-pointer" variant="ghost"
Edit size="sm">
<Pencil class="size-4"></Pencil>
</Button> </Button>
<Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm"> <Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm">
<ChevronLeft class="size-4"></ChevronLeft> Back <ChevronLeft class="size-4"></ChevronLeft> Back
@@ -367,7 +369,8 @@ const expanded = ref<number>(null);
</Button> </Button>
</div> </div>
</div> </div>
<div v-if="TRLoaded" :class="isMobile ? 'my-3 pb-8' : 'my-5 max-h-[70vh] overflow-y-auto overflow-x-hidden scrollbar-themed'"> <div v-if="TRLoaded"
:class="isMobile ? 'my-3 pb-8' : 'my-5 max-h-[70vh] overflow-y-auto overflow-x-hidden scrollbar-themed'">
<div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4"> <div class="flex flex-col mb-5 border rounded-lg bg-muted/70 p-2 py-3 px-4">
<p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }} <p class="scroll-m-20 text-xl font-semibold tracking-tight">{{ focusedTrainingReport.course_name }}
</p> </p>
@@ -385,15 +388,20 @@ const expanded = ref<number>(null);
<div> <div>
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainers</label> <label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainers</label>
<div class="mt-3 space-y-2 md:hidden"> <div class="mt-3 space-y-2 md:hidden">
<article v-for="person in focusedTrainingTrainers" :key="person.attendee_id ?? person.attendee_name" <article v-for="person in focusedTrainingTrainers"
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'"> :key="person.attendee_id ?? person.attendee_name"
class="rounded-xl border bg-card p-3 shadow-sm"
:class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
<div class="flex items-start justify-between gap-2"> <div class="flex items-start justify-between gap-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard> class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis">
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> </MemberCard>
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id" <Button
@click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
variant="ghost" size="icon" class="shrink-0"> variant="ghost" size="icon" class="shrink-0">
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" /> <ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
<ChevronUp v-else class="size-5" /> <ChevronUp v-else class="size-5" />
@@ -409,7 +417,8 @@ const expanded = ref<number>(null);
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p> <p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
</div> </div>
</div> </div>
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2"> <div v-if="expanded === person.attendee_id"
class="mt-3 rounded-lg border bg-background px-3 py-2">
<p class="text-sm font-medium text-foreground">Full Remarks</p> <p class="text-sm font-medium text-foreground">Full Remarks</p>
<p v-if="person.remarks" <p v-if="person.remarks"
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto"> class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
@@ -429,14 +438,18 @@ const expanded = ref<number>(null);
<span class="text-right">Remarks</span> <span class="text-right">Remarks</span>
<span></span> <span></span>
</div> </div>
<div v-for="person in focusedTrainingTrainers" :key="person.attendee_id ?? person.attendee_name" <div v-for="person in focusedTrainingTrainers"
:key="person.attendee_id ?? person.attendee_name"
class="items-center border-b last:border-none" class="items-center border-b last:border-none"
:class="expanded === person.attendee_id && 'bg-muted/20'"> :class="expanded === person.attendee_id && 'bg-muted/20'">
<div class="grid grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_minmax(0,1.4fr)_2.5rem] items-center py-2 gap-x-2"> <div
class="grid grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_minmax(0,1.4fr)_2.5rem] items-center py-2 gap-x-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard> class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis">
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> </MemberCard>
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<p class="truncate">{{ person.role.name }}</p> <p class="truncate">{{ person.role.name }}</p>
<p class="text-right px-2 truncate" <p class="text-right px-2 truncate"
@@ -477,15 +490,21 @@ const expanded = ref<number>(null);
<div class="flex flex-col"> <div class="flex flex-col">
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainees</label> <label class="scroll-m-20 text-xl font-semibold tracking-tight">Trainees</label>
<div class="mt-3 space-y-2 md:hidden"> <div class="mt-3 space-y-2 md:hidden">
<article v-for="person in focusedTrainingTrainees" :key="person.attendee_id ?? person.attendee_name" <article v-for="person in focusedTrainingTrainees"
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'"> :key="person.attendee_id ?? person.attendee_name"
class="rounded-xl border bg-card p-3 shadow-sm"
:class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
<div class="flex items-start justify-between gap-2"> <div class="flex items-start justify-between gap-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard> class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis">
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> </MemberCard>
<p v-else
class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id" <Button
@click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
variant="ghost" size="icon" class="shrink-0"> variant="ghost" size="icon" class="shrink-0">
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" /> <ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
<ChevronUp v-else class="size-5" /> <ChevronUp v-else class="size-5" />
@@ -494,18 +513,25 @@ const expanded = ref<number>(null);
<div class="mt-3 grid grid-cols-2 gap-2 text-xs"> <div class="mt-3 grid grid-cols-2 gap-2 text-xs">
<div class="rounded-lg bg-muted px-3 py-2 text-center"> <div class="rounded-lg bg-muted px-3 py-2 text-center">
<p class="text-muted-foreground">Bookwork</p> <p class="text-muted-foreground">Bookwork</p>
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasBookwork ? 'N/A' : (person.passed_bookwork ? 'Pass' : 'Fail') }}</p> <p class="font-semibold text-foreground">{{
!focusedTrainingReport.course.hasBookwork ? 'N/A' :
(person.passed_bookwork ?
'Pass' : 'Fail') }}</p>
</div> </div>
<div class="rounded-lg bg-muted px-3 py-2 text-center"> <div class="rounded-lg bg-muted px-3 py-2 text-center">
<p class="text-muted-foreground">Qual</p> <p class="text-muted-foreground">Qual</p>
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasQual ? 'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p> <p class="font-semibold text-foreground">{{
!focusedTrainingReport.course.hasQual ?
'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p>
</div> </div>
<div class="col-span-2 rounded-lg bg-muted px-3 py-2"> <div class="col-span-2 rounded-lg bg-muted px-3 py-2">
<p class="text-muted-foreground">Remarks</p> <p class="text-muted-foreground">Remarks</p>
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p> <p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}
</p>
</div> </div>
</div> </div>
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2"> <div v-if="expanded === person.attendee_id"
class="mt-3 rounded-lg border bg-background px-3 py-2">
<p class="text-sm font-medium text-foreground">Full Remarks</p> <p class="text-sm font-medium text-foreground">Full Remarks</p>
<p v-if="person.remarks" <p v-if="person.remarks"
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto"> class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
@@ -526,13 +552,17 @@ const expanded = ref<number>(null);
<span class="text-right">Remarks</span> <span class="text-right">Remarks</span>
<span class="w-15"></span> <span class="w-15"></span>
</div> </div>
<div v-for="person in focusedTrainingTrainees" :key="person.attendee_id ?? person.attendee_name" class="border-b last:border-none" <div v-for="person in focusedTrainingTrainees"
:key="person.attendee_id ?? person.attendee_name" class="border-b last:border-none"
:class="expanded === person.attendee_id && 'bg-muted/20'"> :class="expanded === person.attendee_id && 'bg-muted/20'">
<div class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center px-2 gap-x-2"> <div
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center px-2 gap-x-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard> class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis">
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> </MemberCard>
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<div class="flex justify-center"> <div class="flex justify-center">
<Tooltip :open="!focusedTrainingReport.course.hasBookwork" <Tooltip :open="!focusedTrainingReport.course.hasBookwork"
@@ -592,13 +622,17 @@ const expanded = ref<number>(null);
</label> </label>
<div class="mt-3 space-y-2 md:hidden"> <div class="mt-3 space-y-2 md:hidden">
<article v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name" <article v-for="person in focusedNoShows"
class="rounded-xl border bg-card p-3 shadow-sm" :class="expanded === person.attendee_id && 'ring-1 ring-primary/30'"> :key="person.attendee_id ?? person.attendee_name"
class="rounded-xl border bg-card p-3 shadow-sm"
:class="expanded === person.attendee_id && 'ring-1 ring-primary/30'">
<div class="flex items-start justify-between gap-2"> <div class="flex items-start justify-between gap-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" /> class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" />
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> <p v-else
class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<Button variant="ghost" size="icon" class="shrink-0" @click.stop="expanded === person.attendee_id <Button variant="ghost" size="icon" class="shrink-0" @click.stop="expanded === person.attendee_id
? expanded = null ? expanded = null
@@ -618,11 +652,13 @@ const expanded = ref<number>(null);
</div> </div>
<div class="col-span-2 rounded-lg bg-muted px-3 py-2"> <div class="col-span-2 rounded-lg bg-muted px-3 py-2">
<p class="text-muted-foreground">Remarks</p> <p class="text-muted-foreground">Remarks</p>
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p> <p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}
</p>
</div> </div>
</div> </div>
<div v-if="expanded === person.attendee_id" class="mt-3 rounded-lg border bg-background px-3 py-2"> <div v-if="expanded === person.attendee_id"
class="mt-3 rounded-lg border bg-background px-3 py-2">
<p class="text-sm font-medium text-foreground"> <p class="text-sm font-medium text-foreground">
Full Remarks Full Remarks
</p> </p>
@@ -652,17 +688,20 @@ const expanded = ref<number>(null);
<div v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name" <div v-for="person in focusedNoShows" :key="person.attendee_id ?? person.attendee_name"
class="border-b last:border-none transition-colors" class="border-b last:border-none transition-colors"
:class="expanded === person.attendee_id && 'bg-muted/20'"> :class="expanded === person.attendee_id && 'bg-muted/20'">
<div class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center gap-x-2"> <div
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 items-center gap-x-2">
<div class="min-w-0"> <div class="min-w-0">
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" <MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" /> class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" />
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p> <p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{
person.attendee_name }}</p>
</div> </div>
<p class="text-center text-muted-foreground">-</p> <p class="text-center text-muted-foreground">-</p>
<p class="text-center text-muted-foreground">-</p> <p class="text-center text-muted-foreground">-</p>
<p class="text-right px-2 truncate" :class="!person.remarks && 'text-muted-foreground'"> <p class="text-right px-2 truncate"
:class="!person.remarks && 'text-muted-foreground'">
{{ person.remarks || '--' }} {{ person.remarks || '--' }}
</p> </p>
@@ -706,7 +745,8 @@ const expanded = ref<number>(null);
<Spinner class="size-8"></Spinner> <Spinner class="size-8"></Spinner>
</div> </div>
</div> </div>
<div v-if="effectivePanel == sidePanelState.create" :class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto bg-background px-3 py-3' : 'mt-2 w-full max-w-5xl lg:mt-0 lg:w-3/5 lg:border-l lg:pl-7'" <div v-if="effectivePanel == sidePanelState.create"
:class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto bg-background px-3 py-3' : 'mt-2 w-full max-w-5xl lg:mt-0 lg:w-3/5 lg:border-l lg:pl-7'"
:style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}"> :style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}">
<div class="flex justify-between items-center my-3"> <div class="flex justify-between items-center my-3">
<div class="flex gap-5 lg:pl-2"> <div class="flex gap-5 lg:pl-2">
@@ -720,8 +760,7 @@ const expanded = ref<number>(null);
</Button> </Button>
</div> </div>
<div :class="isMobile ? 'mt-3 pb-8' : 'overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed'"> <div :class="isMobile ? 'mt-3 pb-8' : 'overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed'">
<TrainingReportForm class="w-full lg:pl-2" <TrainingReportForm class="w-full lg:pl-2" @submit="async (newID) => {
@submit="async (newID) => {
if (isMobile) { if (isMobile) {
await viewTrainingReport(newID); await viewTrainingReport(newID);
mobilePanel = sidePanelState.view; mobilePanel = sidePanelState.view;
@@ -733,23 +772,25 @@ const expanded = ref<number>(null);
</TrainingReportForm> </TrainingReportForm>
</div> </div>
</div> </div>
<div v-if="focusedTrainingReport != null && effectivePanel == sidePanelState.edit" :class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto bg-background px-3 py-3' : 'mt-2 w-full max-w-5xl lg:mt-0 lg:w-3/5 lg:border-l lg:pl-7'" <div v-if="focusedTrainingReport != null && effectivePanel == sidePanelState.edit"
:class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto bg-background px-3 py-3' : 'mt-2 w-full max-w-5xl lg:mt-0 lg:w-3/5 lg:border-l lg:pl-7'"
:style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}"> :style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}">
<div class="flex justify-between items-center my-3"> <div class="flex justify-between items-center my-3">
<div class="flex gap-5 lg:pl-2"> <div class="flex gap-5 lg:pl-2">
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Edit Training Report</p> <p class="scroll-m-20 text-2xl font-semibold tracking-tight">Edit Training Report</p>
</div> </div>
<Button v-if="isMobile" @click="mobilePanel = sidePanelState.view" class="cursor-pointer" variant="outline" size="sm"> <Button v-if="isMobile" @click="mobilePanel = sidePanelState.view" class="cursor-pointer"
variant="outline" size="sm">
<ChevronLeft class="size-4"></ChevronLeft> Back <ChevronLeft class="size-4"></ChevronLeft> Back
</Button> </Button>
<Button v-else @click="router.push(`/trainingReport/${focusedTrainingReport.id}`)" class="cursor-pointer" variant="ghost" size="icon"> <Button v-else @click="router.push(`/trainingReport/${focusedTrainingReport.id}`)"
class="cursor-pointer" variant="ghost" size="icon">
<X class="size-6"></X> <X class="size-6"></X>
</Button> </Button>
</div> </div>
<div :class="isMobile ? 'mt-3 pb-8' : 'overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed'"> <div :class="isMobile ? 'mt-3 pb-8' : 'overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed'">
<TrainingReportForm class="w-full lg:pl-2" mode="edit" :report-id="focusedTrainingReport.id" <TrainingReportForm class="w-full lg:pl-2" mode="edit" :report-id="focusedTrainingReport.id"
:report="focusedTrainingReport" :report="focusedTrainingReport" @submit="async (id) => {
@submit="async (id) => {
await loadTrainingReports(); await loadTrainingReports();
await viewTrainingReport(id); await viewTrainingReport(id);