Loheide-eu-mitarbeiterplatt.../resources/js/layouts/AppLayout.vue
Friederich Loheide 800e267e1c
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m29s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m31s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 9m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 9m36s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m33s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m56s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 12m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m58s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 50s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m13s
Neue Seitenköpfe, global wählbar (0.48.0)
- PageHeader: Kopfband (Standard, kompakt), Kopfband mit Symbol, mit Symbol,
  kräftiger Titel – Einstellung page_header im Erscheinungsbild
- Symbol vom passenden Menüpunkt (aktiv oder per Adresse), Prop icon
- In Spalten (z. B. Downloads) schlichte Form statt Band
- Zurück-Links als breadcrumbs (IT-Service), Profil bearbeiten mit PageHeader
- Plugin-Assets: Fingerabdruck berücksichtigt Änderungszeiten der Dateien

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 20:05:37 +00:00

344 lines
21 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { Head, Link, router, usePage } from '@inertiajs/vue3';
import { ChevronDown, LogOut, Menu, Monitor, Moon, Search, Settings, Sun, UserRound, UserRoundPen } from '@lucide/vue';
import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu';
import { Toaster } from '@/components/ui/sonner';
import BrandLogo from '@/components/BrandLogo.vue';
import NotificationBell from '@/components/NotificationBell.vue';
import PersonAvatar from '@/components/PersonAvatar.vue';
import NavLink from '@/components/nav/NavLink.vue';
import AppIcon from '@/components/AppIcon.vue';
import GlobalSearchBox from '@/components/GlobalSearchBox.vue';
import PageContent from '@/pagebuilder/PageContent.vue';
import { pluginComponent } from '@/lib/pluginComponents';
import { useThemePreference } from '@/composables/useThemePreference';
defineProps({
title: { type: String, default: '' },
});
const page = usePage();
const user = computed(() => page.props.auth.user);
const branding = computed(() => page.props.branding);
// Kopfzeilen-Symbole aus Plugins: mitgelieferte aus plugins-core/*/resources/js/header, sonst Kunden-Plugins
const coreHeaderComponents = Object.fromEntries(Object.entries(import.meta.glob('../../../plugins-core/*/resources/js/header/*.vue')).map(([path, loader]) => [
`${path.match(/plugins-core\/([^/]+)\//)[1]}::${path.split('/').pop().replace('.vue', '')}`,
defineAsyncComponent(loader),
]));
const headerItems = computed(() => (page.props.headerItems ?? [])
.map((item) => ({ ...item, is: coreHeaderComponents[item.component] ?? pluginComponent(item.component, 'header') }))
.filter((item) => item.is));
// Frei gestaltete Fußzeile (Backend → Startseite & Menü → Fußzeile gestalten)
const footerContent = computed(() => (page.props.footerContent?.blocks?.length ? page.props.footerContent : null));
const headerStyle = computed(() => branding.value.header_style ?? 'light');
// Erscheinungsbild → „Hauptmenü am PC“: Burger-Menü auch auf großen Bildschirmen
const burgerOnDesktop = computed(() => branding.value.nav_style === 'burger');
const navigation = computed(() => page.props.navigation);
// Was nicht in die Kopfzeile passt, kommt unter „Mehr“. Gemessen wird an einer
// unsichtbaren Kopie der Menüpunkte – so passt es bei jeder Breite und Beschriftung.
const navBox = ref(null);
const navMeasure = ref(null);
const navFit = ref(navigation.value.length);
const MORE_WIDTH = 84;
function measureNav() {
const box = navBox.value;
const items = navMeasure.value ? [...navMeasure.value.children] : [];
if (!box || !items.length) return;
const widths = items.map((el) => el.getBoundingClientRect().width + 4);
const available = box.clientWidth;
if (widths.reduce((sum, w) => sum + w, 0) <= available) {
navFit.value = widths.length;
return;
}
let used = MORE_WIDTH;
let fit = 0;
for (const width of widths) {
if (used + width > available) break;
used += width;
fit++;
}
navFit.value = Math.max(1, fit);
}
let navObserver;
onMounted(() => {
navObserver = new ResizeObserver(measureNav);
if (navBox.value) navObserver.observe(navBox.value);
nextTick(measureNav);
document.fonts?.ready.then(measureNav);
});
onBeforeUnmount(() => navObserver?.disconnect());
watch(navigation, () => nextTick(measureNav));
const navVisible = computed(() => navigation.value.slice(0, navFit.value));
const navMore = computed(() => navigation.value.slice(navFit.value));
const { preference, setPreference } = useThemePreference();
const mobileNavOpen = ref(false);
// Auf der Ergebnisseite den Suchbegriff im Feld stehen lassen
const searchQuery = page.url.startsWith('/suche?') ? (new URLSearchParams(page.url.split('?')[1]).get('q') ?? '') : '';
const themeOptions = [
{ value: 'system', label: 'Wie im System', icon: Monitor },
{ value: 'light', label: 'Hell', icon: Sun },
{ value: 'dark', label: 'Dunkel', icon: Moon },
];
</script>
<template>
<Head v-if="title" :title="title" />
<!-- Tastatur und Screenreader: direkt zum Inhalt, ohne sich durch das Menü zu arbeiten -->
<a
href="#inhalt"
class="sr-only z-[100] rounded-md border bg-card text-sm font-semibold text-foreground shadow-lg focus:not-sr-only focus:fixed focus:top-3 focus:left-3 focus:px-4 focus:py-2.5"
>Zum Inhalt springen</a>
<div class="flex min-h-screen flex-col overflow-x-clip">
<!-- Administration sieht das Portal als andere Person -->
<div
v-if="page.props.impersonation"
class="fixed bottom-4 left-1/2 z-[60] flex max-w-[calc(100vw-2rem)] -translate-x-1/2 items-center gap-3 rounded-pill bg-amber-400 py-2 pr-2 pl-4 text-[13px] font-medium text-amber-950 shadow-lg"
role="status"
>
<span class="min-w-0 truncate">Angemeldet als <strong>{{ page.props.impersonation.name }}</strong></span>
<button type="button" class="shrink-0 rounded-pill bg-amber-950 px-3 py-1 text-xs font-semibold text-amber-50 hover:bg-amber-900" @click="router.post('/anmelden-als/beenden')">
Zurück zu meinem Konto
</button>
</div>
<div v-if="branding.preview" class="flex flex-wrap items-center justify-center gap-x-3 gap-y-1 bg-amber-400 px-4 py-1.5 text-center text-[13px] font-medium text-amber-950">
Vorschau des Entwurfs – so sieht das Portal nach dem Veröffentlichen aus.
<a href="?vorschau=aus" class="underline">Vorschau beenden</a>
</div>
<header
class="sticky top-0 z-40 border-b"
:class="headerStyle === 'light' ? 'bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/85' : ''"
:data-header="headerStyle"
>
<div class="mx-auto flex h-16 max-w-[1440px] items-center gap-2 px-4 lg:gap-6 lg:px-6">
<Sheet v-model:open="mobileNavOpen">
<SheetTrigger
class="-ml-2 flex h-10 min-w-10 items-center justify-center gap-2 rounded-md text-foreground/80 hover:bg-accent"
:class="burgerOnDesktop ? 'lg:px-3 lg:text-sm lg:font-medium' : 'lg:hidden'"
aria-label="Menü öffnen"
>
<Menu class="size-5" /><span v-if="burgerOnDesktop" class="hidden lg:inline">Menü</span>
</SheetTrigger>
<SheetContent side="left" class="w-72 p-0" :class="{ 'lg:w-80': burgerOnDesktop }">
<SheetHeader class="border-b px-5 py-4">
<SheetTitle class="text-left"><BrandLogo /></SheetTitle>
</SheetHeader>
<nav class="grid gap-1 overflow-y-auto p-3" aria-label="Hauptnavigation">
<template v-for="item in navigation" :key="item.key">
<NavLink
v-if="item.href"
:item="item"
class="flex items-center gap-2.5 rounded-md px-3 py-2.5 text-[15px] font-medium"
:class="item.active && !item.children.some((c) => c.active) ? 'bg-brand-soft text-brand-soft-foreground' : 'text-foreground/80 hover:bg-accent'"
@click="mobileNavOpen = false"
>
<AppIcon v-if="item.icon" :name="item.icon" class="size-[18px] opacity-80" />{{ item.label }}
</NavLink>
<p v-else class="px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted-foreground uppercase">{{ item.label }}</p>
<div v-if="item.children.length" class="mb-1 ml-3 grid gap-0.5 border-l pl-2">
<NavLink
v-for="child in item.children"
:key="child.key"
:item="child"
class="flex items-center gap-2 rounded-md px-3 py-2 text-sm"
:class="child.active ? 'bg-brand-soft font-medium text-brand-soft-foreground' : 'text-foreground/75 hover:bg-accent'"
@click="mobileNavOpen = false"
>
<AppIcon v-if="child.icon" :name="child.icon" class="size-4 opacity-70" />{{ child.label }}
</NavLink>
</div>
</template>
</nav>
</SheetContent>
</Sheet>
<Link href="/" class="shrink-0 text-foreground" aria-label="Startseite">
<BrandLogo :inverted="headerStyle !== 'light'" compact />
</Link>
<nav ref="navBox" class="relative hidden h-full min-w-0 flex-1" :class="{ 'lg:block': !burgerOnDesktop }" aria-label="Hauptnavigation">
<!-- Unsichtbare Kopie zum Messen der Breiten -->
<div class="pointer-events-none invisible absolute inset-0 overflow-hidden" aria-hidden="true">
<ul ref="navMeasure" class="flex w-max gap-1">
<li v-for="item in navigation" :key="item.key" class="flex items-center gap-1.5 px-3 text-sm font-medium whitespace-nowrap">
<AppIcon v-if="item.icon" :name="item.icon" class="size-4" />{{ item.label }}<ChevronDown v-if="item.children.length" class="size-4" />
</li>
</ul>
</div>
<ul class="flex h-full items-stretch gap-1">
<li v-for="item in navVisible" :key="item.key" class="flex">
<DropdownMenu v-if="item.children.length">
<DropdownMenuTrigger
class="relative flex items-center gap-1.5 px-3 text-sm font-medium whitespace-nowrap transition-colors outline-none"
:class="item.active ? 'text-foreground' : 'text-foreground/70 hover:text-foreground'"
>
<AppIcon v-if="item.icon" :name="item.icon" class="size-4 opacity-80" />{{ item.label }} <ChevronDown class="size-4 opacity-70" />
<span v-if="item.active" class="nav-underline absolute inset-x-3 bottom-0 h-[3px] rounded-t-full bg-brand" />
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="min-w-56">
<template v-if="item.href">
<DropdownMenuItem as-child>
<NavLink :item="item" :class="item.active && !item.children.some((c) => c.active) ? 'font-semibold text-brand-text' : 'font-medium'">{{ item.label }} – Übersicht</NavLink>
</DropdownMenuItem>
<DropdownMenuSeparator />
</template>
<DropdownMenuItem v-for="child in item.children" :key="child.key" as-child>
<NavLink :item="child" :class="child.active ? 'font-semibold text-brand-text' : ''">
<AppIcon v-if="child.icon" :name="child.icon" class="size-4 text-muted-foreground" />{{ child.label }}
</NavLink>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<NavLink
v-else
:item="item"
class="relative flex items-center gap-1.5 px-3 text-sm font-medium whitespace-nowrap transition-colors"
:class="item.active ? 'text-foreground' : 'text-foreground/70 hover:text-foreground'"
:aria-current="item.active ? 'page' : undefined"
>
<AppIcon v-if="item.icon" :name="item.icon" class="size-4 opacity-80" />{{ item.label }}
<span v-if="item.active" class="nav-underline absolute inset-x-3 bottom-0 h-[3px] rounded-t-full bg-brand" />
</NavLink>
</li>
<li v-if="navMore.length" class="flex">
<DropdownMenu>
<DropdownMenuTrigger
class="relative flex items-center gap-1 px-3 text-sm font-medium whitespace-nowrap transition-colors outline-none"
:class="navMore.some((i) => i.active) ? 'text-foreground' : 'text-foreground/70 hover:text-foreground'"
>
Mehr <ChevronDown class="size-4" />
<span v-if="navMore.some((i) => i.active)" class="nav-underline absolute inset-x-3 bottom-0 h-[3px] rounded-t-full bg-brand" />
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="min-w-48">
<template v-for="(item, index) in navMore" :key="item.key">
<template v-if="item.children.length">
<DropdownMenuSeparator v-if="index" />
<DropdownMenuLabel class="text-xs text-muted-foreground">{{ item.label }}</DropdownMenuLabel>
<DropdownMenuItem v-if="item.href" as-child><NavLink :item="item">Übersicht</NavLink></DropdownMenuItem>
<DropdownMenuItem v-for="child in item.children" :key="child.key" as-child>
<NavLink :item="child" :class="child.active ? 'font-semibold text-brand-text' : ''">
<AppIcon v-if="child.icon" :name="child.icon" class="size-4 text-muted-foreground" />{{ child.label }}
</NavLink>
</DropdownMenuItem>
</template>
<DropdownMenuItem v-else as-child>
<NavLink :item="item" :class="item.active ? 'font-semibold text-brand-text' : ''">
<AppIcon v-if="item.icon" :name="item.icon" class="size-4 text-muted-foreground" />{{ item.label }}
</NavLink>
</DropdownMenuItem>
</template>
</DropdownMenuContent>
</DropdownMenu>
</li>
</ul>
</nav>
<div class="ml-auto flex shrink-0 items-center gap-1">
<GlobalSearchBox :initial="searchQuery" class="mr-2 hidden w-64 md:block xl:w-80" />
<Link href="/suche" class="grid size-10 place-items-center rounded-md text-foreground/70 hover:bg-accent hover:text-foreground md:hidden" aria-label="Portal durchsuchen">
<Search class="size-5" />
</Link>
<component :is="item.is" v-for="item in headerItems" :key="item.key" v-bind="item.props" />
<NotificationBell />
<a
v-if="user.can_admin"
href="/admin"
class="grid size-10 place-items-center rounded-md text-foreground/70 hover:bg-accent hover:text-foreground"
aria-label="Administration"
title="Administration"
>
<Settings class="size-5" />
</a>
<DropdownMenu>
<DropdownMenuTrigger
class="ml-1 flex items-center gap-1.5 rounded-full py-1 pr-1.5 pl-1 hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/40 focus-visible:outline-none"
:aria-label="`Menü für ${user.name}`"
>
<PersonAvatar :person="user" class="size-9" />
<ChevronDown class="size-4 text-muted-foreground" />
</DropdownMenuTrigger>
<DropdownMenuContent align="end" class="w-72">
<DropdownMenuLabel class="flex items-center gap-3 py-2 font-normal">
<PersonAvatar :person="user" class="size-10" />
<div class="min-w-0">
<div class="truncate text-sm font-semibold">{{ user.name }}</div>
<div class="truncate text-xs text-muted-foreground">{{ user.email }}</div>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem as-child>
<Link :href="`/personen/${user.id}`"><UserRound /> Mein Profil</Link>
</DropdownMenuItem>
<DropdownMenuItem as-child>
<Link href="/profil/bearbeiten"><UserRoundPen /> Profil bearbeiten</Link>
</DropdownMenuItem>
<DropdownMenuItem v-if="user.can_admin" as-child>
<a href="/admin"><Settings /> Administration</a>
</DropdownMenuItem>
<template v-if="!branding.color_mode">
<DropdownMenuSeparator />
<DropdownMenuLabel class="text-xs font-medium text-muted-foreground">Darstellung</DropdownMenuLabel>
<DropdownMenuRadioGroup :model-value="preference" @update:model-value="setPreference">
<DropdownMenuRadioItem v-for="option in themeOptions" :key="option.value" :value="option.value">
<component :is="option.icon" class="size-4 text-muted-foreground" />
{{ option.label }}
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</template>
<DropdownMenuSeparator />
<DropdownMenuItem as-child>
<Link href="/logout" method="post" as="button" class="w-full"><LogOut /> Abmelden</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</header>
<main id="inhalt" tabindex="-1" class="mx-auto w-full max-w-[1440px] flex-1 px-4 py-6 outline-none lg:px-6 lg:py-7">
<slot />
</main>
<footer v-if="footerContent || branding.footer.text || branding.footer.links.length" class="border-t" :class="{ 'bg-card': footerContent }">
<div v-if="footerContent" class="@container mx-auto max-w-[1440px] px-4 pt-10 pb-6 lg:px-6">
<PageContent :content="footerContent" />
</div>
<div v-if="branding.footer.text || branding.footer.links.length" class="mx-auto flex max-w-[1440px] flex-wrap items-center justify-between gap-x-6 gap-y-2 px-4 py-5 text-[13px] text-muted-foreground lg:px-6" :class="{ 'border-t': footerContent }">
<p v-if="branding.footer.text">{{ branding.footer.text }}</p>
<nav v-if="branding.footer.links.length" class="flex flex-wrap gap-x-5 gap-y-1" aria-label="Fußzeile">
<a v-for="link in branding.footer.links" :key="link.url" :href="link.url" class="hover:text-foreground hover:underline">{{ link.label }}</a>
</nav>
</div>
</footer>
</div>
<Toaster position="bottom-right" />
</template>