Compare commits
10 Commits
main
...
Mobile-Enh
| Author | SHA1 | Date | |
|---|---|---|---|
| b64891c2a2 | |||
| a05b48cd4c | |||
| 191bc6f428 | |||
| 87bdd30a19 | |||
| bae5578afb | |||
| 676e09aef5 | |||
| b40e4f3ec7 | |||
| 0e37a8bc9c | |||
| 045de2fe98 | |||
| a1ca07e6fd |
@@ -6,8 +6,11 @@
|
|||||||
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
import AlertDescription from './components/ui/alert/AlertDescription.vue';
|
||||||
import Navbar from './components/Navigation/Navbar.vue';
|
import Navbar from './components/Navigation/Navbar.vue';
|
||||||
import { cancelLOA } from './api/loa';
|
import { cancelLOA } from './api/loa';
|
||||||
|
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const headerRef = ref<HTMLDivElement | null>(null);
|
||||||
|
let resizeObserver: ResizeObserver | null = null;
|
||||||
|
|
||||||
function formatDate(dateStr) {
|
function formatDate(dateStr) {
|
||||||
if (!dateStr) return "";
|
if (!dateStr) return "";
|
||||||
@@ -22,6 +25,27 @@
|
|||||||
const environment = import.meta.env.VITE_ENVIRONMENT;
|
const environment = import.meta.env.VITE_ENVIRONMENT;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const version = import.meta.env.VITE_APPLICATION_VERSION;
|
const version = import.meta.env.VITE_APPLICATION_VERSION;
|
||||||
|
|
||||||
|
function updateHeaderHeight() {
|
||||||
|
if (!headerRef.value) return;
|
||||||
|
const height = headerRef.value.offsetHeight;
|
||||||
|
document.documentElement.style.setProperty('--app-header-height', `${height}px`);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateHeaderHeight();
|
||||||
|
|
||||||
|
// Gracefully skip observer setup for environments that do not support ResizeObserver.
|
||||||
|
if (typeof ResizeObserver === 'undefined' || !headerRef.value) return;
|
||||||
|
|
||||||
|
resizeObserver = new ResizeObserver(updateHeaderHeight);
|
||||||
|
resizeObserver.observe(headerRef.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
resizeObserver?.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -29,7 +53,7 @@
|
|||||||
background-size: contain;
|
background-size: contain;
|
||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
background-position: center;">
|
background-position: center;">
|
||||||
<div class="sticky top-0 bg-background z-50">
|
<div class="sticky top-0 bg-background z-50" ref="headerRef">
|
||||||
<Navbar class="flex"></Navbar>
|
<Navbar class="flex"></Navbar>
|
||||||
<Alert v-if="environment == 'dev'" class="m-2 mx-auto max-w-5xl" variant="info">
|
<Alert v-if="environment == 'dev'" class="m-2 mx-auto max-w-5xl" variant="info">
|
||||||
<AlertDescription class="flex flex-row items-center text-wrap gap-5 mx-auto">
|
<AlertDescription class="flex flex-row items-center text-wrap gap-5 mx-auto">
|
||||||
|
|||||||
@@ -1,58 +1,193 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { RouterLink } from 'vue-router';
|
import { RouterLink, useRouter } from 'vue-router';
|
||||||
import Separator from '../ui/separator/Separator.vue';
|
import Separator from '../ui/separator/Separator.vue';
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '../ui/dropdown-menu';
|
} from '../ui/dropdown-menu';
|
||||||
import { useUserStore } from '@/stores/user';
|
import { useUserStore } from '@/stores/user';
|
||||||
import Button from '../ui/button/Button.vue';
|
import Button from '../ui/button/Button.vue';
|
||||||
import NavigationMenu from '../ui/navigation-menu/NavigationMenu.vue';
|
import NavigationMenu from '../ui/navigation-menu/NavigationMenu.vue';
|
||||||
import NavigationMenuList from '../ui/navigation-menu/NavigationMenuList.vue';
|
import NavigationMenuList from '../ui/navigation-menu/NavigationMenuList.vue';
|
||||||
import NavigationMenuItem from '../ui/navigation-menu/NavigationMenuItem.vue';
|
import NavigationMenuItem from '../ui/navigation-menu/NavigationMenuItem.vue';
|
||||||
import NavigationMenuLink from '../ui/navigation-menu/NavigationMenuLink.vue';
|
import NavigationMenuLink from '../ui/navigation-menu/NavigationMenuLink.vue';
|
||||||
import NavigationMenuTrigger from '../ui/navigation-menu/NavigationMenuTrigger.vue';
|
import NavigationMenuTrigger from '../ui/navigation-menu/NavigationMenuTrigger.vue';
|
||||||
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
import NavigationMenuContent from '../ui/navigation-menu/NavigationMenuContent.vue';
|
||||||
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
import { navigationMenuTriggerStyle } from '../ui/navigation-menu/'
|
||||||
import { useAuth } from '@/composables/useAuth';
|
import { useAuth } from '@/composables/useAuth';
|
||||||
import { ArrowUpRight, CircleArrowOutUpRight } from 'lucide-vue-next';
|
import { ArrowUpRight, ChevronDown, ChevronUp, CircleArrowOutUpRight, LogIn, LogOut, Menu, Settings, X } from 'lucide-vue-next';
|
||||||
import DropdownMenuGroup from '../ui/dropdown-menu/DropdownMenuGroup.vue';
|
import DropdownMenuGroup from '../ui/dropdown-menu/DropdownMenuGroup.vue';
|
||||||
import DropdownMenuSeparator from '../ui/dropdown-menu/DropdownMenuSeparator.vue';
|
import DropdownMenuSeparator from '../ui/dropdown-menu/DropdownMenuSeparator.vue';
|
||||||
import { MemberState } from '@shared/types/member';
|
import { MemberState } from '@shared/types/member';
|
||||||
|
import { computed, nextTick, ref } from 'vue';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const auth = useAuth();
|
const auth = useAuth();
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const APIHOST = import.meta.env.VITE_APIHOST;
|
const APIHOST = import.meta.env.VITE_APIHOST;
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const DOCHOST = import.meta.env.VITE_DOCHOST;
|
const DOCHOST = import.meta.env.VITE_DOCHOST;
|
||||||
|
|
||||||
async function logout() {
|
async function logout() {
|
||||||
userStore.user = null;
|
userStore.user = null;
|
||||||
window.location.href = APIHOST + "/logout";
|
window.location.href = APIHOST + "/logout";
|
||||||
}
|
}
|
||||||
|
|
||||||
function blurAfter() {
|
function blurAfter() {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
(document.activeElement as HTMLElement)?.blur();
|
(document.activeElement as HTMLElement)?.blur();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NavItem = {
|
||||||
|
title: string;
|
||||||
|
to?: string;
|
||||||
|
href?: string;
|
||||||
|
status?: 'member' | 'guest';
|
||||||
|
isExternal?: boolean;
|
||||||
|
roles?: string[];
|
||||||
|
items?: NavItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const navConfig: NavItem[] = [
|
||||||
|
{
|
||||||
|
title: 'Calendar',
|
||||||
|
to: '/calendar',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Documents',
|
||||||
|
href: 'https://docs.iceberg-gaming.com',
|
||||||
|
status: 'member',
|
||||||
|
isExternal: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Forms',
|
||||||
|
status: 'member',
|
||||||
|
items: [
|
||||||
|
{ title: 'Leave of Absence', to: '/loa' },
|
||||||
|
{ title: 'Training Report', to: '/trainingReport' },
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Administration',
|
||||||
|
status: 'member',
|
||||||
|
roles: ['17th Administrator', '17th HQ', '17th Command', 'Recruiter'],
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
title: 'Leave of Absence',
|
||||||
|
to: '/administration/loa',
|
||||||
|
roles: ['17th Administrator', '17th HQ', '17th Command']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Promotions',
|
||||||
|
to: '/administration/rankChange',
|
||||||
|
roles: ['17th Administrator', '17th HQ', '17th Command']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Recruitment',
|
||||||
|
to: '/administration/applications',
|
||||||
|
roles: ['Recruiter']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Member Management',
|
||||||
|
to: '/administration/members',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Role Management',
|
||||||
|
to: '/administration/roles',
|
||||||
|
roles: ['17th Administrator']
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Developer',
|
||||||
|
to: '/developer',
|
||||||
|
roles: ['Dev']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Join',
|
||||||
|
to: '/join',
|
||||||
|
status: 'guest',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const filteredNav = computed(() => {
|
||||||
|
return navConfig.flatMap(item => {
|
||||||
|
const filtered: NavItem[] = [];
|
||||||
|
|
||||||
|
// 1. Check Login Requirements
|
||||||
|
const isLoggedIn = userStore.isLoggedIn;
|
||||||
|
|
||||||
|
// 2. Determine visibility based on status
|
||||||
|
let shouldShow = false;
|
||||||
|
|
||||||
|
if (!item.status) {
|
||||||
|
// Public items - always show
|
||||||
|
shouldShow = true;
|
||||||
|
} else if (item.status === 'guest') {
|
||||||
|
// Show if NOT logged in OR logged in as guest (but NOT a member)
|
||||||
|
shouldShow = !isLoggedIn || auth.accountStatus.value === MemberState.Guest;
|
||||||
|
} else if (item.status === 'member') {
|
||||||
|
// Show ONLY if logged in as member
|
||||||
|
shouldShow = isLoggedIn && auth.accountStatus.value === MemberState.Member;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Check Role Requirements (if status check passed)
|
||||||
|
if (shouldShow && item.roles) {
|
||||||
|
shouldShow = auth.hasAnyRole(item.roles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldShow) {
|
||||||
|
if (item.items) {
|
||||||
|
const filteredItems = item.items.filter(subItem =>
|
||||||
|
!subItem.roles || auth.hasAnyRole(subItem.roles)
|
||||||
|
);
|
||||||
|
filtered.push({ ...item, items: filteredItems });
|
||||||
|
} else {
|
||||||
|
filtered.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
const isMobileMenuOpen = ref(false);
|
||||||
|
const expandedMenu = ref(null);
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
function openMobileMenu() {
|
||||||
|
expandedMenu.value = null;
|
||||||
|
isMobileMenuOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeMobileMenu() {
|
||||||
|
isMobileMenuOpen.value = false;
|
||||||
|
expandedMenu.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mobileNavigateTo(to: string) {
|
||||||
|
closeMobileMenu();
|
||||||
|
router.push(to);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full border-b">
|
<div class="w-full border-b">
|
||||||
<div class="max-w-screen-3xl w-full mx-auto flex items-center justify-between pr-10 pl-7">
|
<div class="hidden lg:flex max-w-screen-3xl w-full mx-auto items-center justify-between pr-10 pl-7">
|
||||||
<!-- left side -->
|
<!-- left side -->
|
||||||
<div class="flex items-center gap-7">
|
<div class="flex items-center gap-7">
|
||||||
<RouterLink to="/">
|
<RouterLink to="/">
|
||||||
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<!-- Member navigation -->
|
<!-- Member navigation -->
|
||||||
<div v-if="auth.accountStatus.value == MemberState.Member" class="h-15 flex items-center justify-center">
|
<div v-if="auth.accountStatus.value == MemberState.Member"
|
||||||
|
class="h-15 flex items-center justify-center">
|
||||||
<NavigationMenu>
|
<NavigationMenu>
|
||||||
<NavigationMenuList class="gap-3">
|
<NavigationMenuList class="gap-3">
|
||||||
|
|
||||||
@@ -202,6 +337,109 @@ function blurAfter() {
|
|||||||
<a v-else :href="APIHOST + '/login'">Login</a>
|
<a v-else :href="APIHOST + '/login'">Login</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <Separator></Separator> -->
|
|
||||||
|
<!-- mobile navigation -->
|
||||||
|
<div class="flex flex-col lg:hidden w-full" :class="isMobileMenuOpen ? 'h-screen' : ''">
|
||||||
|
<div class="flex items-center justify-between w-full p-2">
|
||||||
|
<!-- <RouterLink to="/">
|
||||||
|
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
||||||
|
</RouterLink> -->
|
||||||
|
<button @click="mobileNavigateTo('/')">
|
||||||
|
<img src="/17RBN_Logo.png" class="w-10 h-10 object-contain"></img>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Button v-if="!isMobileMenuOpen" variant="ghost" size="icon" @click="openMobileMenu()">
|
||||||
|
<Menu class="size-7" />
|
||||||
|
</Button>
|
||||||
|
<Button v-else variant="ghost" size="icon" @click="closeMobileMenu()">
|
||||||
|
<X class="size-7" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div v-if="isMobileMenuOpen" class="flex flex-col h-[calc(100vh-60px)] overflow-hidden">
|
||||||
|
<div class="flex-1 overflow-y-auto px-2 py-3 space-y-0.5">
|
||||||
|
<div v-for="navItem in filteredNav" :key="navItem.title" class="group">
|
||||||
|
|
||||||
|
<template v-if="!navItem.items">
|
||||||
|
<a v-if="navItem.isExternal" :href="navItem.href" target="_blank"
|
||||||
|
class="flex items-center justify-between w-full px-4 py-2.5 text-base font-medium rounded-md hover:bg-accent active:bg-accent transition-colors">
|
||||||
|
<span class="flex items-center gap-2">
|
||||||
|
{{ navItem.title }}
|
||||||
|
<ArrowUpRight class="h-3.5 w-3.5 opacity-50" />
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<button v-else @click="mobileNavigateTo(navItem.to)"
|
||||||
|
class="w-full text-left px-4 py-2.5 text-base font-medium rounded-md hover:bg-accent active:bg-accent transition-colors">
|
||||||
|
{{ navItem.title }}
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div v-else class="space-y-0.5">
|
||||||
|
<button @click="expandedMenu = expandedMenu === navItem.title ? null : navItem.title"
|
||||||
|
class="flex items-center justify-between w-full px-4 py-2.5 text-base font-medium rounded-md transition-colors"
|
||||||
|
:class="expandedMenu === navItem.title ? 'bg-accent/50 text-primary' : 'hover:bg-accent'">
|
||||||
|
{{ navItem.title }}
|
||||||
|
<ChevronDown class="h-4 w-4 transition-transform duration-200"
|
||||||
|
:class="expandedMenu === navItem.title ? 'rotate-180' : ''" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div v-if="expandedMenu === navItem.title"
|
||||||
|
class="ml-4 mr-2 border-l border-border space-y-0.5">
|
||||||
|
<button v-for="subNavItem in navItem.items" :key="subNavItem.title"
|
||||||
|
@click="mobileNavigateTo(subNavItem.to)"
|
||||||
|
class="w-full text-left px-6 py-2 text-sm text-muted-foreground hover:text-foreground active:text-primary transition-colors">
|
||||||
|
{{ subNavItem.title }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-3 border-t bg-background mt-auto">
|
||||||
|
<div v-if="userStore.isLoggedIn" class="space-y-3">
|
||||||
|
<div class="flex items-center justify-between px-2">
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<!-- <div
|
||||||
|
class="size-8 rounded-full bg-primary/10 flex items-center justify-center text-xs font-bold text-primary">
|
||||||
|
{{ userStore.displayName?.charAt(0) }}
|
||||||
|
</div> -->
|
||||||
|
<div class="flex flex-col leading-tight">
|
||||||
|
<span class="text-sm font-semibold">
|
||||||
|
{{ userStore.displayName || userStore.user.member.member_name }}
|
||||||
|
</span>
|
||||||
|
<span v-if="userStore.displayName"
|
||||||
|
class="text-[10px] uppercase tracking-wider text-muted-foreground">
|
||||||
|
{{ userStore.user.member.member_name }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<Button variant="ghost" size="icon" @click="mobileNavigateTo('/profile')">
|
||||||
|
<Settings class="size-6"></Settings>
|
||||||
|
</Button>
|
||||||
|
<Button variant="ghost" size="icon" @click="logout()">
|
||||||
|
<LogOut class="size-6 text-destructive"></LogOut>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<!-- <Button variant="outline" size="xs" class="flex-1 h-8 text-xs"
|
||||||
|
@click="mobileNavigateTo('/profile')">Profile</Button> -->
|
||||||
|
<Button variant="secondary" size="xs" class="flex-1 h-8 text-xs"
|
||||||
|
@click="mobileNavigateTo('/join')">My
|
||||||
|
Application</Button>
|
||||||
|
<Button variant="secondary" size="xs" class="flex-1 h-8 text-xs"
|
||||||
|
@click="mobileNavigateTo('/applications')">Application History</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a v-else :href="APIHOST + '/login'" class="block">
|
||||||
|
<Button class="w-full text-sm h-10">
|
||||||
|
<LogIn></LogIn> Login
|
||||||
|
</Button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -169,16 +169,16 @@ const filteredMembers = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-row-reverse gap-6 mx-auto w-full" :class="!adminMode ? 'max-w-5xl' : 'max-w-5xl'">
|
<div class="mx-auto flex w-full max-w-5xl flex-col gap-4 lg:flex-row-reverse lg:gap-6">
|
||||||
<div v-if="!adminMode" class="flex-1 flex flex-col space-x-4 rounded-md border p-4">
|
<div v-if="!adminMode" class="order-2 flex flex-1 flex-col rounded-md border p-4 lg:order-1">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Policy</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Policy</p>
|
||||||
<div ref="policyRef" class="bookstack-container">
|
<div ref="policyRef" class="bookstack-container">
|
||||||
<!-- LOA policy gets loaded here -->
|
<!-- LOA policy gets loaded here -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 flex flex-col gap-5">
|
<div class="order-1 flex flex-1 flex-col gap-5 lg:order-2">
|
||||||
<form v-if="!formSubmitted" @submit="onSubmit" class="flex flex-col gap-2">
|
<form v-if="!formSubmitted" @submit="onSubmit" class="flex flex-col gap-2">
|
||||||
<div class="flex w-full gap-5">
|
<div class="grid w-full grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-5">
|
||||||
<VeeField v-slot="{ field, errors }" name="member_id">
|
<VeeField v-slot="{ field, errors }" name="member_id">
|
||||||
<Field>
|
<Field>
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
@@ -237,13 +237,13 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-5">
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:gap-5">
|
||||||
<VeeField v-slot="{ field, errors }" name="start_date">
|
<VeeField v-slot="{ field, errors }" name="start_date">
|
||||||
<Field>
|
<Field class="w-full">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>Start Date</FieldLabel>
|
<FieldLabel>Start Date</FieldLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
<div class="relative inline-flex items-center group">
|
<div class="group relative flex w-full items-center">
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button :disabled="!values.type" variant="outline" :class="cn(
|
<Button :disabled="!values.type" variant="outline" :class="cn(
|
||||||
'w-full justify-start text-left font-normal',
|
'w-full justify-start text-left font-normal',
|
||||||
@@ -259,7 +259,7 @@ const filteredMembers = computed(() => {
|
|||||||
text-popover-foreground shadow-md border border-border
|
text-popover-foreground shadow-md border border-border
|
||||||
opacity-0 translate-y-1
|
opacity-0 translate-y-1
|
||||||
group-hover:opacity-100 group-hover:translate-y-0
|
group-hover:opacity-100 group-hover:translate-y-0
|
||||||
transition-opacity transition-transform duration-150">
|
transition-all duration-150">
|
||||||
Select an LOA type first
|
Select an LOA type first
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -277,11 +277,11 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
<VeeField v-slot="{ field, errors }" name="end_date">
|
<VeeField v-slot="{ field, errors }" name="end_date">
|
||||||
<Field>
|
<Field class="w-full">
|
||||||
<FieldContent>
|
<FieldContent>
|
||||||
<FieldLabel>End Date</FieldLabel>
|
<FieldLabel>End Date</FieldLabel>
|
||||||
<Popover>
|
<Popover>
|
||||||
<div class="relative inline-flex items-center group">
|
<div class="group relative flex w-full items-center">
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button :disabled="!values.type" variant="outline" :class="cn(
|
<Button :disabled="!values.type" variant="outline" :class="cn(
|
||||||
'w-full justify-start text-left font-normal',
|
'w-full justify-start text-left font-normal',
|
||||||
@@ -297,7 +297,7 @@ const filteredMembers = computed(() => {
|
|||||||
text-popover-foreground shadow-md border border-border
|
text-popover-foreground shadow-md border border-border
|
||||||
opacity-0 translate-y-1
|
opacity-0 translate-y-1
|
||||||
group-hover:opacity-100 group-hover:translate-y-0
|
group-hover:opacity-100 group-hover:translate-y-0
|
||||||
transition-opacity transition-transform duration-150">
|
transition-all duration-150">
|
||||||
Select an LOA type first
|
Select an LOA type first
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -330,8 +330,8 @@ const filteredMembers = computed(() => {
|
|||||||
</Field>
|
</Field>
|
||||||
</VeeField>
|
</VeeField>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end">
|
<div class="flex justify-stretch sm:justify-end">
|
||||||
<Button type="submit" :disabled="submitting" class="w-35">
|
<Button type="submit" :disabled="submitting" class="w-full sm:w-35">
|
||||||
<span class="flex items-center gap-2" v-if="submitting">
|
<span class="flex items-center gap-2" v-if="submitting">
|
||||||
<Spinner></Spinner> Submitting…
|
<Spinner></Spinner> Submitting…
|
||||||
</span>
|
</span>
|
||||||
@@ -352,7 +352,7 @@ const filteredMembers = computed(() => {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<div class="flex gap-3 mt-4">
|
<div class="mt-4 flex flex-col gap-3 sm:flex-row">
|
||||||
<Button variant="secondary" @click="formSubmitted = false">
|
<Button variant="secondary" @click="formSubmitted = false">
|
||||||
Submit another request
|
Submit another request
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -141,29 +141,125 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Dialog :open="isExtending" @update:open="(val) => isExtending = val">
|
<Dialog :open="isExtending" @update:open="(val) => isExtending = val">
|
||||||
<DialogContent>
|
<DialogContent class="w-[95vw] max-w-[95vw] p-4 sm:max-w-fit sm:p-6">
|
||||||
<DialogHeader>
|
<DialogHeader class="gap-1 pr-12 text-left">
|
||||||
<DialogTitle>Extend {{ targetLOA.name }}'s Leave of Absence </DialogTitle>
|
<DialogTitle class="text-base leading-tight sm:text-lg">Extend Leave of Absence</DialogTitle>
|
||||||
|
<DialogDescription class="truncate text-xs text-muted-foreground sm:text-sm">
|
||||||
|
{{ targetLOA?.name }}
|
||||||
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div class="flex gap-5">
|
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:gap-5">
|
||||||
<Calendar v-model="extendTo" class="rounded-md border shadow-sm w-min" layout="month-and-year"
|
<Calendar v-model="extendTo"
|
||||||
|
class="mx-auto w-min rounded-md border shadow-sm sm:mx-0"
|
||||||
|
layout="month-and-year"
|
||||||
:min-value="toCalendarDate(targetEnd)"
|
:min-value="toCalendarDate(targetEnd)"
|
||||||
:max-value="props.adminMode ? toCalendarDate(targetEnd).add({ years: 1 }) : toCalendarDate(targetEnd).add({ months: 1 })" />
|
:max-value="props.adminMode ? toCalendarDate(targetEnd).add({ years: 1 }) : toCalendarDate(targetEnd).add({ months: 1 })" />
|
||||||
<div class="flex flex-col w-full gap-3 px-2">
|
<div class="flex w-full flex-col gap-2 sm:gap-3">
|
||||||
<p>Quick Options</p>
|
<p class="text-sm font-medium text-muted-foreground">Quick Options</p>
|
||||||
<Button variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ days: 7 })">1
|
<Button class="w-full" variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ days: 7 })">1
|
||||||
Week</Button>
|
Week</Button>
|
||||||
<Button variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ months: 1 })">1
|
<Button class="w-full" variant="outline" @click="extendTo = toCalendarDate(targetEnd).add({ months: 1 })">1
|
||||||
Month</Button>
|
Month</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-end gap-4">
|
<div class="flex flex-row justify-end gap-2 pt-2 sm:gap-4 sm:pt-0">
|
||||||
<Button variant="outline" @click="isExtending = false">Cancel</Button>
|
<Button class="flex-1 sm:flex-none" variant="outline" @click="isExtending = false">Cancel</Button>
|
||||||
<Button @click="commitExtend">Extend</Button>
|
<Button class="flex-1 sm:flex-none" @click="commitExtend">Extend</Button>
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class="max-w-7xl w-full mx-auto">
|
<div class="max-w-7xl w-full mx-auto">
|
||||||
|
<div class="space-y-3 md:hidden">
|
||||||
|
<template v-for="post in LOAList" :key="`mobile-${post.id}`">
|
||||||
|
<div class="rounded-lg border bg-card p-2.5 shadow-sm">
|
||||||
|
<div class="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2">
|
||||||
|
<div class="min-w-0 overflow-hidden">
|
||||||
|
<div class="max-w-[70vw] overflow-hidden whitespace-nowrap">
|
||||||
|
<MemberCard :member-id="post.member_id"></MemberCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Badge v-if="loaStatus(post) === 'Upcoming'" class="shrink-0 bg-blue-400">Upcoming</Badge>
|
||||||
|
<Badge v-else-if="loaStatus(post) === 'Active'" class="shrink-0 bg-green-500">Active</Badge>
|
||||||
|
<Badge v-else-if="loaStatus(post) === 'Extended'" class="shrink-0 bg-green-500">Extended</Badge>
|
||||||
|
<Badge v-else-if="loaStatus(post) === 'Overdue'" class="shrink-0 bg-yellow-400">Overdue</Badge>
|
||||||
|
<Badge v-else class="shrink-0 bg-gray-400">Ended</Badge>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-1 grid grid-cols-2 gap-x-4 gap-y-1">
|
||||||
|
<div>
|
||||||
|
<p class="text-[11px] uppercase tracking-wide text-muted-foreground/90">Start</p>
|
||||||
|
<p class="text-sm font-semibold text-foreground">{{ formatDate(post.start_date) }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="text-right">
|
||||||
|
<p class="text-[11px] uppercase tracking-wide text-muted-foreground/90">End</p>
|
||||||
|
<p class="text-sm font-semibold text-foreground">{{ post.extended_till ? formatDate(post.extended_till) : formatDate(post.end_date) }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-1 flex items-center justify-end gap-1">
|
||||||
|
<Button variant="ghost" class="h-8 px-2 text-xs text-muted-foreground" @click="expanded = expanded === post.id ? null : post.id">
|
||||||
|
<span class="mr-1">Details</span>
|
||||||
|
<ChevronUp v-if="expanded === post.id" class="size-4" />
|
||||||
|
<ChevronDown v-else class="size-4" />
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger class="cursor-pointer">
|
||||||
|
<Button variant="ghost" size="icon" class="size-8 text-muted-foreground">
|
||||||
|
<Ellipsis class="size-5"></Ellipsis>
|
||||||
|
</Button>
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent>
|
||||||
|
<DropdownMenuItem v-if="!post.closed"
|
||||||
|
:disabled="post.extended_till !== null && !props.adminMode"
|
||||||
|
@click="isExtending = true; targetLOA = post">
|
||||||
|
{{ (post.extended_till !== null && !props.adminMode) ? 'Extend (Already Extended)' : 'Extend' }}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem v-if="!post.closed" :variant="'destructive'"
|
||||||
|
@click="cancelAndReload(post.id)">{{ loaStatus(post) === 'Upcoming' ?
|
||||||
|
'Cancel' :
|
||||||
|
'End' }}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<p v-if="post.closed || (!props.adminMode && post.closed)"
|
||||||
|
class="p-2 text-center text-sm">
|
||||||
|
No actions
|
||||||
|
</p>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="expanded === post.id" class="mt-2 space-y-2.5 border-t pt-2 text-sm">
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<span class="text-muted-foreground/90">Type</span>
|
||||||
|
<span class="text-right font-semibold text-foreground">{{ post.type_name }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<span class="text-muted-foreground/90">Posted on</span>
|
||||||
|
<span class="text-right font-semibold text-foreground">{{ formatDate(post.filed_date) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<span class="text-muted-foreground/90">Original end</span>
|
||||||
|
<span class="text-right font-semibold text-foreground">{{ formatDate(post.end_date) }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center justify-between gap-3">
|
||||||
|
<span class="text-muted-foreground/90">Extended to</span>
|
||||||
|
<span class="text-right font-semibold text-foreground">{{ post.extended_till ? formatDate(post.extended_till) : 'N/A' }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h4 class="text-[11px] font-semibold uppercase tracking-wide text-muted-foreground/90">Reason</h4>
|
||||||
|
<p class="mt-1 whitespace-pre-wrap text-sm leading-relaxed text-foreground/90">
|
||||||
|
{{ post.reason || 'No reason provided.' }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden overflow-x-auto md:block">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -242,7 +338,7 @@
|
|||||||
<div class="w-full p-4 mb-6 space-y-4">
|
<div class="w-full p-4 mb-6 space-y-4">
|
||||||
|
|
||||||
<!-- Dates -->
|
<!-- Dates -->
|
||||||
<div class="grid grid-cols-3 gap-4 text-sm">
|
<div class="grid grid-cols-1 gap-4 text-sm lg:grid-cols-3">
|
||||||
<div>
|
<div>
|
||||||
<p class="text-muted-foreground">Start</p>
|
<p class="text-muted-foreground">Start</p>
|
||||||
<p class="font-medium">
|
<p class="font-medium">
|
||||||
@@ -266,16 +362,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Reason -->
|
<!-- Reason -->
|
||||||
<div class="space-y-2">
|
<div class="space-y-2 border-t pt-3">
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<h4 class="text-sm font-semibold text-foreground">
|
<h4 class="text-sm font-semibold text-foreground">
|
||||||
Reason
|
Reason
|
||||||
</h4>
|
</h4>
|
||||||
<Separator class="flex-1" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div class="text-sm leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
||||||
class="rounded-lg border bg-muted/40 px-4 py-3 text-sm leading-relaxed whitespace-pre-wrap text-muted-foreground">
|
|
||||||
{{ post.reason || 'No reason provided.' }}
|
{{ post.reason || 'No reason provided.' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -287,8 +379,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
<div class="mt-5 flex justify-between">
|
</div>
|
||||||
<div></div>
|
<div class="mt-5 flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
:default-page="2" :page="pageNum" @update:page="setPage">
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
<PaginationContent v-slot="{ items }">
|
<PaginationContent v-slot="{ items }">
|
||||||
@@ -303,7 +396,7 @@
|
|||||||
<PaginationNext />
|
<PaginationNext />
|
||||||
</PaginationContent>
|
</PaginationContent>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
<div class="flex items-center gap-3 text-sm">
|
<div class="flex items-center justify-end gap-3 text-sm">
|
||||||
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
||||||
|
|
||||||
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
|
|||||||
@@ -135,11 +135,7 @@ function setAllToday() {
|
|||||||
<div class="w-xl">
|
<div class="w-xl">
|
||||||
<form v-if="!formSubmitted" id="trainingForm" @submit.prevent="submitForm"
|
<form v-if="!formSubmitted" id="trainingForm" @submit.prevent="submitForm"
|
||||||
class="w-full min-w-0 flex flex-col gap-4">
|
class="w-full min-w-0 flex flex-col gap-4">
|
||||||
<div>
|
|
||||||
<FieldLegend class="scroll-m-20 text-2xl font-semibold tracking-tight">
|
|
||||||
Promotion Form
|
|
||||||
</FieldLegend>
|
|
||||||
</div>
|
|
||||||
<VeeFieldArray name="promotions" v-slot="{ fields, push, remove }">
|
<VeeFieldArray name="promotions" v-slot="{ fields, push, remove }">
|
||||||
<FieldSet class="w-full min-w-0">
|
<FieldSet class="w-full min-w-0">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<DialogClose
|
<DialogClose
|
||||||
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
class="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-3.5 right-3.5 inline-flex h-9 w-9 items-center justify-center rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none sm:top-4 sm:right-4 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-5"
|
||||||
>
|
>
|
||||||
<X />
|
<X />
|
||||||
<span class="sr-only">Close</span>
|
<span class="sr-only">Close</span>
|
||||||
|
|||||||
@@ -19,17 +19,20 @@ const showLOADialog = ref(false);
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
<Dialog v-model:open="showLOADialog" v-on:update:open="showLOADialog = false">
|
||||||
<DialogContent class="sm:max-w-fit">
|
<DialogContent class="w-[95vw] max-w-[95vw] max-h-[90dvh] overflow-y-auto p-4 sm:max-w-fit sm:p-6">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>Post LOA</DialogTitle>
|
<DialogTitle>Post LOA</DialogTitle>
|
||||||
<DialogDescription>
|
<DialogDescription>
|
||||||
Post an LOA on behalf of a member.
|
Post an LOA on behalf of a member.
|
||||||
</DialogDescription>
|
</DialogDescription>
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<LoaForm :admin-mode="true" class="my-3"></LoaForm>
|
<LoaForm :admin-mode="true"></LoaForm>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button variant="outline" @click="showLOADialog = false">Cancel</Button>
|
||||||
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<div class="max-w-5xl mx-auto pt-10">
|
<div class="mx-auto max-w-5xl px-3 pt-10 sm:px-4 lg:px-0">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Log</h1>
|
<h1 class="scroll-m-20 text-2xl font-semibold tracking-tight">LOA Log</h1>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,29 +1,48 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { Plus, PlusIcon, X } from 'lucide-vue-next'
|
||||||
|
import PromotionForm from '@/components/promotions/promotionForm.vue'
|
||||||
|
import PromotionList from '@/components/promotions/promotionList.vue'
|
||||||
|
import DialogContent from '@/components/ui/dialog/DialogContent.vue'
|
||||||
|
import Dialog from '@/components/ui/dialog/Dialog.vue'
|
||||||
|
import DialogTrigger from '@/components/ui/dialog/DialogTrigger.vue'
|
||||||
|
import DialogHeader from '@/components/ui/dialog/DialogHeader.vue'
|
||||||
|
import DialogTitle from '@/components/ui/dialog/DialogTitle.vue'
|
||||||
|
import Button from '@/components/ui/button/Button.vue'
|
||||||
|
|
||||||
|
const isFormOpen = ref(false)
|
||||||
|
const listRef = ref(null)
|
||||||
|
|
||||||
|
const isMobileFormOpen = ref(false);
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="mx-auto mt-6 lg:mt-10 px-4 lg:px-8">
|
<div class="mx-auto mt-6 lg:mt-10 px-4 lg:px-8">
|
||||||
|
|
||||||
<div class="flex items-center justify-between mb-6 lg:hidden">
|
<div class="flex flex-col items-center justify-between mb-6 lg:hidden">
|
||||||
<h1 class="text-2xl font-semibold tracking-tight">Promotion History</h1>
|
<div v-if="isMobileFormOpen">
|
||||||
|
<div class="mb-4 flex justify-between items-center">
|
||||||
<Dialog v-model:open="isFormOpen">
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">
|
||||||
<DialogTrigger as-child>
|
Promotion Form
|
||||||
<Button size="sm" class="gap-2">
|
</p>
|
||||||
<Plus class="size-4" />
|
<Button variant="ghost" size="icon" @click="isMobileFormOpen = false">
|
||||||
Promote
|
<X v-if="isMobileFormOpen" class="size-6"></X>
|
||||||
</Button>
|
</Button>
|
||||||
</DialogTrigger>
|
|
||||||
<DialogContent class="w-full h-full max-w-none m-0 rounded-none flex flex-col">
|
|
||||||
<DialogHeader class="flex-row items-center justify-between border-b pb-4">
|
|
||||||
<DialogTitle>New Promotion</DialogTitle>
|
|
||||||
</DialogHeader>
|
|
||||||
|
|
||||||
<div class="flex-1 overflow-y-auto pt-6">
|
|
||||||
<PromotionForm @submitted="handleMobileSubmit" />
|
|
||||||
</div>
|
</div>
|
||||||
</DialogContent>
|
<PromotionForm @submitted="listRef?.refresh" />
|
||||||
</Dialog>
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="flex justify-between w-full">
|
||||||
|
<h1 class="text-2xl font-semibold tracking-tight">Promotion History</h1>
|
||||||
|
<Button @click="isMobileFormOpen = true">
|
||||||
|
<PlusIcon />Submit
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<PromotionList></PromotionList>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col lg:flex-row lg:max-h-[70vh] gap-8">
|
<div class="hidden lg:flex flex-row lg:max-h-[70vh] gap-8">
|
||||||
<div class="flex-1 lg:border-r lg:pr-8 w-full lg:min-w-2xl">
|
<div class="flex-1 lg:border-r lg:pr-8 w-full lg:min-w-2xl">
|
||||||
<p class="hidden lg:block scroll-m-20 text-2xl font-semibold tracking-tight mb-3">
|
<p class="hidden lg:block scroll-m-20 text-2xl font-semibold tracking-tight mb-3">
|
||||||
Promotion History
|
Promotion History
|
||||||
@@ -42,24 +61,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { Plus } from 'lucide-vue-next'
|
|
||||||
import PromotionForm from '@/components/promotions/promotionForm.vue'
|
|
||||||
import PromotionList from '@/components/promotions/promotionList.vue'
|
|
||||||
import DialogContent from '@/components/ui/dialog/DialogContent.vue'
|
|
||||||
import Dialog from '@/components/ui/dialog/Dialog.vue'
|
|
||||||
import DialogTrigger from '@/components/ui/dialog/DialogTrigger.vue'
|
|
||||||
import DialogHeader from '@/components/ui/dialog/DialogHeader.vue'
|
|
||||||
import DialogTitle from '@/components/ui/dialog/DialogTitle.vue'
|
|
||||||
import Button from '@/components/ui/button/Button.vue'
|
|
||||||
|
|
||||||
const isFormOpen = ref(false)
|
|
||||||
const listRef = ref(null)
|
|
||||||
|
|
||||||
const handleMobileSubmit = () => {
|
|
||||||
isFormOpen.value = false // Close the "Whole page" modal
|
|
||||||
listRef.value?.refresh() // Refresh the list behind it
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -11,7 +11,7 @@ const mode = ref<'submit' | 'view'>('submit')
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="max-w-5xl mx-auto flex w-full flex-col mt-4 mb-10">
|
<div class="mx-auto mt-4 mb-10 flex w-full max-w-5xl flex-col px-3 sm:px-4 lg:px-0">
|
||||||
<div class="mb-8">
|
<div class="mb-8">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Leave of Absence</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Leave of Absence</p>
|
||||||
<div class="pt-3">
|
<div class="pt-3">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<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, onMounted, ref, watch } from 'vue';
|
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
TableHeader,
|
TableHeader,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from '@/components/ui/table'
|
} from '@/components/ui/table'
|
||||||
import { ArrowUpDown, ChevronDown, ChevronUp, Funnel, Link, Plus, Search, X } from 'lucide-vue-next';
|
import { ArrowUpDown, ChevronDown, ChevronLeft, ChevronUp, Funnel, Link, 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';
|
||||||
@@ -49,6 +49,21 @@ const sidePanel = computed<sidePanelState>(() => {
|
|||||||
return sidePanelState.closed;
|
return sidePanelState.closed;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const isMobile = ref(false);
|
||||||
|
const mobilePanel = ref<sidePanelState>(sidePanelState.closed);
|
||||||
|
let mobileMediaQuery: MediaQueryList | null = null;
|
||||||
|
|
||||||
|
function syncMobileMode() {
|
||||||
|
isMobile.value = mobileMediaQuery?.matches ?? window.innerWidth < 1024;
|
||||||
|
if (!isMobile.value) {
|
||||||
|
mobilePanel.value = sidePanelState.closed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const effectivePanel = computed<sidePanelState>(() => {
|
||||||
|
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;
|
||||||
@@ -82,6 +97,41 @@ async function closeTrainingReport() {
|
|||||||
focusedTrainingReport.value = null;
|
focusedTrainingReport.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function openTrainingReport(id: number) {
|
||||||
|
if (isMobile.value) {
|
||||||
|
focusedTrainingReport.value = null;
|
||||||
|
TRLoaded.value = false;
|
||||||
|
expanded.value = null;
|
||||||
|
mobilePanel.value = sidePanelState.view;
|
||||||
|
await viewTrainingReport(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
router.push(`/trainingReport/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreatePanel() {
|
||||||
|
if (isMobile.value) {
|
||||||
|
mobilePanel.value = sidePanelState.create;
|
||||||
|
focusedTrainingReport.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
router.push('/trainingReport/new');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function closePanel() {
|
||||||
|
if (isMobile.value) {
|
||||||
|
mobilePanel.value = sidePanelState.closed;
|
||||||
|
focusedTrainingReport.value = null;
|
||||||
|
TRLoaded.value = false;
|
||||||
|
expanded.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await closeTrainingReport();
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -105,12 +155,20 @@ async function loadTrainingReports() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
mobileMediaQuery = window.matchMedia('(max-width: 1023px)');
|
||||||
|
syncMobileMode();
|
||||||
|
mobileMediaQuery.addEventListener('change', syncMobileMode);
|
||||||
|
|
||||||
await loadTrainingReports();
|
await loadTrainingReports();
|
||||||
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(() => {
|
||||||
|
mobileMediaQuery?.removeEventListener('change', syncMobileMode);
|
||||||
|
})
|
||||||
|
|
||||||
const TRLoaded = ref(false);
|
const TRLoaded = ref(false);
|
||||||
|
|
||||||
const pageNum = ref<number>(1);
|
const pageNum = ref<number>(1);
|
||||||
@@ -119,6 +177,16 @@ 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 {
|
||||||
|
if (!date) return '';
|
||||||
|
const dateObj = typeof date === 'string' ? new Date(date) : date;
|
||||||
|
return dateObj.toLocaleDateString('en-US', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function setPageSize(size: number) {
|
function setPageSize(size: number) {
|
||||||
pageSize.value = size
|
pageSize.value = size
|
||||||
pageNum.value = 1;
|
pageNum.value = 1;
|
||||||
@@ -134,21 +202,22 @@ const expanded = ref<number>(null);
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="px-20 mx-auto max-w-[100rem] w-full flex mt-5">
|
<div class="mx-auto mt-5 flex w-full max-w-[100rem] flex-col px-3 sm:px-4 lg:flex-row lg:px-8 xl:px-20">
|
||||||
<!-- training report list -->
|
<!-- training report list -->
|
||||||
<div class="px-4 my-3" :class="sidePanel == sidePanelState.closed ? 'w-full' : 'w-2/5'">
|
<div v-show="!isMobile || effectivePanel === sidePanelState.closed" class="my-3 px-0 lg:px-4"
|
||||||
|
:class="effectivePanel == sidePanelState.closed ? 'w-full' : 'w-full lg:flex-[0_0_26rem] xl:flex-[0_0_30rem]'">
|
||||||
<div class="flex justify-between mb-4">
|
<div class="flex justify-between mb-4">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Reports</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">Training Reports</p>
|
||||||
<Button @click="router.push('/trainingReport/new')">
|
<Button @click="openCreatePanel()">
|
||||||
<Plus></Plus> New Training Report
|
<Plus></Plus> New Training Report
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<!-- search/filter -->
|
<!-- search/filter -->
|
||||||
<div class="flex justify-between">
|
<div class="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
|
||||||
<!-- <Search></Search>
|
<!-- <Search></Search>
|
||||||
<Funnel></Funnel> -->
|
<Funnel></Funnel> -->
|
||||||
<div></div>
|
<div></div>
|
||||||
<div class="flex flex-row gap-5">
|
<div class="flex flex-col gap-3 sm:flex-row sm:gap-5">
|
||||||
<div>
|
<div>
|
||||||
<label class="text-muted-foreground">Search</label>
|
<label class="text-muted-foreground">Search</label>
|
||||||
<Input v-model="searchString" placeholder="Search..."></Input>
|
<Input v-model="searchString" placeholder="Search..."></Input>
|
||||||
@@ -172,7 +241,24 @@ const expanded = ref<number>(null);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="overflow-y-auto max-h-[70vh] mt-5 scrollbar-themed">
|
<div class="mt-5">
|
||||||
|
<div class="space-y-2 md:hidden">
|
||||||
|
<button v-for="report in trainingReports" :key="`mobile-report-${report.event_id}`"
|
||||||
|
class="w-full rounded-lg border bg-card px-3 py-2 text-left transition-colors hover:bg-muted/40"
|
||||||
|
@click="openTrainingReport(report.event_id)">
|
||||||
|
<p class="font-semibold text-foreground">
|
||||||
|
{{ report.course_name.length > 35 ? report.course_shortname : report.course_name }}
|
||||||
|
</p>
|
||||||
|
<p class="mt-1 text-sm text-muted-foreground">{{ formatDate(report.date) }}</p>
|
||||||
|
<div class="mt-2 flex items-center gap-2 text-xs text-muted-foreground">
|
||||||
|
<span class="font-medium">Posted by:</span>
|
||||||
|
<MemberCard v-if="report.created_by" :member-id="report.created_by"></MemberCard>
|
||||||
|
<span v-else>Unknown User</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden md:block">
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader class="">
|
<TableHeader class="">
|
||||||
<TableRow>
|
<TableRow>
|
||||||
@@ -187,12 +273,12 @@ const expanded = ref<number>(null);
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<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="router.push(`/trainingReport/${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">
|
||||||
<MemberCard v-if="report.created_by_name" :member-id="report.created_by"></MemberCard>
|
<MemberCard v-if="report.created_by" :member-id="report.created_by"></MemberCard>
|
||||||
<span v-else>Unknown User</span>
|
<span v-else>Unknown User</span>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<!-- <TableCell class="text-right">{{ report.created_by_name === null ? "Unknown User" :
|
<!-- <TableCell class="text-right">{{ report.created_by_name === null ? "Unknown User" :
|
||||||
@@ -202,9 +288,10 @@ const expanded = ref<number>(null);
|
|||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5 flex justify-between"
|
</div>
|
||||||
:class="sidePanel !== sidePanelState.closed ? 'flex-col items-center' : 'items-center justify-between'">
|
<div class="mt-5 flex flex-col gap-3 md:flex-row md:items-center md:justify-between"
|
||||||
<div></div>
|
:class="effectivePanel !== sidePanelState.closed ? 'items-center' : ''">
|
||||||
|
<div class="hidden md:block"></div>
|
||||||
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
<Pagination v-slot="{ page }" :items-per-page="pageData?.pageSize || 10" :total="pageData?.total || 10"
|
||||||
:default-page="2" :page="pageNum" @update:page="setPage">
|
:default-page="2" :page="pageNum" @update:page="setPage">
|
||||||
<PaginationContent v-slot="{ items }">
|
<PaginationContent v-slot="{ items }">
|
||||||
@@ -219,8 +306,9 @@ const expanded = ref<number>(null);
|
|||||||
<PaginationNext />
|
<PaginationNext />
|
||||||
</PaginationContent>
|
</PaginationContent>
|
||||||
</Pagination>
|
</Pagination>
|
||||||
<div class="flex items-center gap-3 text-sm" :class="sidePanel !== sidePanelState.closed ? 'mt-3' : ''">
|
<div class="flex flex-wrap items-center justify-end gap-2 text-sm"
|
||||||
<p class="text-muted-foreground text-nowrap">Per page:</p>
|
:class="effectivePanel !== sidePanelState.closed ? 'w-full justify-center md:w-auto md:justify-end' : ''">
|
||||||
|
<p class="text-muted-foreground">Per page:</p>
|
||||||
|
|
||||||
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
<button v-for="size in pageSizeOptions" :key="size" @click="setPageSize(size)"
|
||||||
class="px-2 py-1 rounded transition-colors" :class="{
|
class="px-2 py-1 rounded transition-colors" :class="{
|
||||||
@@ -234,53 +322,95 @@ const expanded = ref<number>(null);
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- view training report section -->
|
<!-- view training report section -->
|
||||||
<div v-if="focusedTrainingReport != null && sidePanel == sidePanelState.view" class="pl-9 my-3 border-l w-3/5">
|
<div v-if="focusedTrainingReport != null && effectivePanel == sidePanelState.view"
|
||||||
|
:class="isMobile ? 'fixed inset-0 z-[60] overflow-y-auto px-3 py-3' : 'my-3 mt-2 w-full min-w-0 lg:mt-0 lg:flex-1 lg:border-l lg:pl-9'"
|
||||||
|
:style="isMobile ? { top: 'var(--app-header-height, 60px)' } : {}">
|
||||||
<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 class="cursor-pointer" variant="ghost" size="icon" @click="CopyLink()">
|
<Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm">
|
||||||
|
<ChevronLeft class="size-4"></ChevronLeft> Back
|
||||||
|
</Button>
|
||||||
|
<Button v-else class="cursor-pointer" variant="ghost" size="icon" @click="CopyLink()">
|
||||||
<Link class="size-4" />
|
<Link class="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
<Button v-if="!isMobile" @click="closePanel" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<X class="size-6"></X>
|
<X class="size-6"></X>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="TRLoaded" class="max-h-[70vh] overflow-auto scrollbar-themed my-5">
|
<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>
|
||||||
<div class="flex gap-10 items-center">
|
<div class="mt-2 flex flex-col gap-2 text-sm sm:flex-row sm:items-center sm:gap-10">
|
||||||
<p class="text-muted-foreground">{{ focusedTrainingReport.event_date.split('T')[0] }}</p>
|
<p class="text-muted-foreground">{{ formatDate(focusedTrainingReport.event_date) }}</p>
|
||||||
<p class="flex gap-2 items-center">Created by:
|
<div class="flex gap-2 items-center">Created by:
|
||||||
<MemberCard v-if="focusedTrainingReport.created_by"
|
<MemberCard v-if="focusedTrainingReport.created_by"
|
||||||
:member-id="focusedTrainingReport.created_by" />
|
:member-id="focusedTrainingReport.created_by" />
|
||||||
<p v-else>{{ focusedTrainingReport.created_by_name === null ? "Unknown User" :
|
<span v-else>Unknown User</span>
|
||||||
focusedTrainingReport.created_by_name
|
</div>
|
||||||
}}</p>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-8 ">
|
<div class="flex flex-col gap-8 ">
|
||||||
<!-- Trainers -->
|
<!-- Trainers -->
|
||||||
<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">
|
||||||
|
<article v-for="person in focusedTrainingTrainers" :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="min-w-0">
|
||||||
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
|
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
||||||
|
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
||||||
|
</div>
|
||||||
|
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
|
||||||
|
variant="ghost" size="icon" class="shrink-0">
|
||||||
|
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
||||||
|
<ChevronUp v-else class="size-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 grid grid-cols-1 gap-2 text-xs">
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2">
|
||||||
|
<p class="text-muted-foreground">Role</p>
|
||||||
|
<p class="font-medium text-foreground">{{ person.role.name }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2">
|
||||||
|
<p class="text-muted-foreground">Remarks</p>
|
||||||
|
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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 v-if="person.remarks"
|
||||||
|
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
|
{{ person.remarks }}
|
||||||
|
</p>
|
||||||
|
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
||||||
|
None provided
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
<div class="mt-2 hidden md:block">
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-[1fr_1fr_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b">
|
class="grid grid-cols-[minmax(0,1.6fr)_minmax(0,1fr)_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b gap-x-2">
|
||||||
<span>Name</span>
|
<span>Name</span>
|
||||||
<span class="">Role</span>
|
<span>Role</span>
|
||||||
<span class="text-right">Remarks</span>
|
<span class="text-right">Remarks</span>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
<div v-for="person in focusedTrainingTrainers" class=" items-center border-b last:border-none"
|
<div v-for="person in focusedTrainingTrainers" :key="person.attendee_id ?? person.attendee_name"
|
||||||
|
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-[1fr_1fr_2fr_3rem] items-center py-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>
|
<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"></MemberCard>
|
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
||||||
<p v-else>{{ person.attendee_name }}</p>
|
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="">{{ 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"
|
||||||
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
||||||
{{ person.remarks == "" ?
|
{{ person.remarks == "" ?
|
||||||
@@ -313,39 +443,85 @@ const expanded = ref<number>(null);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<!-- trainees -->
|
<!-- trainees -->
|
||||||
<div>
|
<div>
|
||||||
<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">
|
||||||
|
<article v-for="person in focusedTrainingTrainees" :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="min-w-0">
|
||||||
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
|
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
||||||
|
<p v-else class="font-medium whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
||||||
|
</div>
|
||||||
|
<Button @click.stop="expanded === person.attendee_id ? expanded = null : expanded = person.attendee_id"
|
||||||
|
variant="ghost" size="icon" class="shrink-0">
|
||||||
|
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
||||||
|
<ChevronUp v-else class="size-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 grid grid-cols-2 gap-2 text-xs">
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
|
<p class="text-muted-foreground">Bookwork</p>
|
||||||
|
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasBookwork ? 'N/A' : (person.passed_bookwork ? 'Pass' : 'Fail') }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
|
<p class="text-muted-foreground">Qual</p>
|
||||||
|
<p class="font-semibold text-foreground">{{ !focusedTrainingReport.course.hasQual ? 'N/A' : (person.passed_qual ? 'Pass' : 'Fail') }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
||||||
|
<p class="text-muted-foreground">Remarks</p>
|
||||||
|
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<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 v-if="person.remarks"
|
||||||
|
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
|
{{ person.remarks }}
|
||||||
|
</p>
|
||||||
|
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
||||||
|
None provided
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
<div class="hidden md:block">
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b px-2">
|
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b px-2 gap-x-2">
|
||||||
<span>Name</span>
|
<span>Name</span>
|
||||||
<span class="text-center">Bookwork</span>
|
<span class="text-center">Bookwork</span>
|
||||||
<span class="text-center">Qual</span>
|
<span class="text-center">Qual</span>
|
||||||
<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>
|
<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" 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-[1fr_5rem_5rem_2fr_3rem] py-2 items-center mx-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>
|
<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"></MemberCard>
|
class="justify-self-start max-w-full whitespace-nowrap overflow-hidden text-ellipsis"></MemberCard>
|
||||||
<p v-else>{{ person.attendee_name }}</p>
|
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
||||||
</div>
|
</div>
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasBookwork" class="mx-auto"
|
<div class="flex justify-center">
|
||||||
|
<Tooltip :open="!focusedTrainingReport.course.hasBookwork"
|
||||||
message="This course does not have bookwork">
|
message="This course does not have bookwork">
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasBookwork"
|
<Checkbox :disabled="!focusedTrainingReport.course.hasBookwork"
|
||||||
:model-value="person.passed_bookwork" class="pointer-events-none">
|
:model-value="person.passed_bookwork" class="pointer-events-none">
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :open="!focusedTrainingReport.course.hasQual" class="mx-auto"
|
</div>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<Tooltip :open="!focusedTrainingReport.course.hasQual"
|
||||||
message="This course does not have a qualification">
|
message="This course does not have a qualification">
|
||||||
<Checkbox :disabled="!focusedTrainingReport.course.hasQual"
|
<Checkbox :disabled="!focusedTrainingReport.course.hasQual"
|
||||||
:model-value="person.passed_qual" class="pointer-events-none ml-1">
|
:model-value="person.passed_qual" class="pointer-events-none">
|
||||||
</Checkbox>
|
</Checkbox>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
</div>
|
||||||
<p class="text-right truncate"
|
<p class="text-right truncate"
|
||||||
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
:class="person.remarks == '' ? 'text-muted-foreground' : ''">
|
||||||
{{ person.remarks == "" ?
|
{{ person.remarks == "" ?
|
||||||
@@ -378,6 +554,8 @@ const expanded = ref<number>(null);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- No Shows -->
|
<!-- No Shows -->
|
||||||
<div v-if="focusedNoShows.length != 0">
|
<div v-if="focusedNoShows.length != 0">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
@@ -385,29 +563,76 @@ const expanded = ref<number>(null);
|
|||||||
No Shows
|
No Shows
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
<div class="mt-3 space-y-2 md:hidden">
|
||||||
|
<article v-for="person in focusedNoShows" :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="min-w-0">
|
||||||
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
|
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>
|
||||||
|
</div>
|
||||||
|
<Button variant="ghost" size="icon" class="shrink-0" @click.stop="expanded === person.attendee_id
|
||||||
|
? expanded = null
|
||||||
|
: expanded = person.attendee_id">
|
||||||
|
<ChevronDown v-if="expanded !== person.attendee_id" class="size-5" />
|
||||||
|
<ChevronUp v-else class="size-5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="mt-3 grid grid-cols-2 gap-2 text-xs">
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
|
<p class="text-muted-foreground">Bookwork</p>
|
||||||
|
<p class="font-semibold text-foreground">N/A</p>
|
||||||
|
</div>
|
||||||
|
<div class="rounded-lg bg-muted px-3 py-2 text-center">
|
||||||
|
<p class="text-muted-foreground">Qual</p>
|
||||||
|
<p class="font-semibold text-foreground">N/A</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-span-2 rounded-lg bg-muted px-3 py-2">
|
||||||
|
<p class="text-muted-foreground">Remarks</p>
|
||||||
|
<p class="font-medium text-foreground truncate">{{ person.remarks || '--' }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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 v-if="person.remarks"
|
||||||
|
class="mt-1 text-sm text-muted-foreground leading-relaxed whitespace-pre-wrap max-h-72 overflow-y-auto">
|
||||||
|
{{ person.remarks }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p v-else class="mt-1 text-sm text-muted-foreground italic">
|
||||||
|
None provided
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden md:block">
|
||||||
<div
|
<div
|
||||||
class="grid grid-cols-[1fr_5rem_5rem_2fr_3rem] py-2 text-sm font-medium text-muted-foreground border-b">
|
class="grid grid-cols-[minmax(0,1.6fr)_4.25rem_4.25rem_minmax(0,1.4fr)_2.5rem] py-2 text-sm font-medium text-muted-foreground border-b gap-x-2">
|
||||||
<span>Name</span>
|
<span>Name</span>
|
||||||
<span></span>
|
<span class="text-center">Bookwork</span>
|
||||||
<span></span>
|
<span class="text-center">Qual</span>
|
||||||
<span class="text-right">Remarks</span>
|
<span class="text-right">Remarks</span>
|
||||||
<span></span>
|
<span></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<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'">
|
||||||
<!-- Row -->
|
<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-[1fr_5rem_5rem_2fr_3rem] py-2 items-center">
|
<div class="min-w-0">
|
||||||
<!-- Name -->
|
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id"
|
||||||
<div>
|
class="max-w-full whitespace-nowrap overflow-hidden text-ellipsis" />
|
||||||
<MemberCard v-if="person.attendee_id" :member-id="person.attendee_id" />
|
<p v-else class="whitespace-nowrap overflow-hidden text-ellipsis">{{ person.attendee_name }}</p>
|
||||||
<p v-else>{{ person.attendee_name }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div></div>
|
<p class="text-center text-muted-foreground">-</p>
|
||||||
<div></div>
|
<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 || '--' }}
|
||||||
@@ -438,7 +663,8 @@ const expanded = ref<number>(null);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Remarks</label>
|
<label class="scroll-m-20 text-xl font-semibold tracking-tight">Remarks</label>
|
||||||
@@ -452,18 +678,30 @@ const expanded = ref<number>(null);
|
|||||||
<Spinner class="size-8"></Spinner>
|
<Spinner class="size-8"></Spinner>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="sidePanel == sidePanelState.create" class="pl-7 border-l w-3/5 max-w-5xl">
|
<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)' } : {}">
|
||||||
<div class="flex justify-between items-center my-3">
|
<div class="flex justify-between items-center my-3">
|
||||||
<div class="flex pl-2 gap-5">
|
<div class="flex gap-5 lg:pl-2">
|
||||||
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
<p class="scroll-m-20 text-2xl font-semibold tracking-tight">New Training Report</p>
|
||||||
</div>
|
</div>
|
||||||
<Button @click="closeTrainingReport" class="cursor-pointer" variant="ghost" size="icon">
|
<Button v-if="isMobile" @click="closePanel" class="cursor-pointer" variant="outline" size="sm">
|
||||||
|
<ChevronLeft class="size-4"></ChevronLeft> Back
|
||||||
|
</Button>
|
||||||
|
<Button v-else @click="closePanel" class="cursor-pointer" variant="ghost" size="icon">
|
||||||
<X class="size-6"></X>
|
<X class="size-6"></X>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="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 pl-2"
|
<TrainingReportForm class="w-full lg:pl-2"
|
||||||
@submit="(newID) => { router.push(`/trainingReport/${newID}`); loadTrainingReports() }">
|
@submit="async (newID) => {
|
||||||
|
if (isMobile) {
|
||||||
|
await viewTrainingReport(newID);
|
||||||
|
mobilePanel = sidePanelState.view;
|
||||||
|
} else {
|
||||||
|
router.push(`/trainingReport/${newID}`);
|
||||||
|
}
|
||||||
|
loadTrainingReports()
|
||||||
|
}">
|
||||||
</TrainingReportForm>
|
</TrainingReportForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user