Loheide-eu-mitarbeiterplatt.../resources/js/components/apps/AppLauncher.vue
Friederich Loheide a618927a52
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m7s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 7m30s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 8m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m21s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 17m13s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 17m12s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m52s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 9m29s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 47s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m23s
Schnellzugriffe mit Logo, Kategorien und Sichtbar für (0.51.0)
Untertitel, Logo, Kategorie, Rollen und Anheften je Eintrag; Knopf
„Anwendungen“ in der Kopfzeile mit allen sichtbaren Einträgen.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 18:44:53 +00:00

87 lines
4.4 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, ref, watch } from 'vue';
import { Link, usePage } from '@inertiajs/vue3';
import { ArrowUpRight, LayoutGrid, Search } from '@lucide/vue';
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
import AppMark from '@/components/apps/AppMark.vue';
import { appsOpen } from '@/lib/apps';
/**
* „Anwendungen“ in der Kopfzeile: alle Schnellzugriffe, die die Person sehen darf –
* nach Kategorien geordnet, ab neun Einträgen mit Suche.
*/
const page = usePage();
const apps = computed(() => page.props.apps ?? []);
const query = ref('');
watch(appsOpen, (open) => open || (query.value = ''));
const filtered = computed(() => {
const q = query.value.trim().toLowerCase();
return q ? apps.value.filter((app) => `${app.label} ${app.subtitle} ${app.category}`.toLowerCase().includes(q)) : apps.value;
});
const groups = computed(() => {
const map = new Map();
for (const app of filtered.value) {
const key = app.category || '';
if (!map.has(key)) map.set(key, []);
map.get(key).push(app);
}
// Ohne Kategorie zuerst, dann in der Reihenfolge des ersten Auftretens
return [...map.entries()].sort(([a], [b]) => (a === '' ? -1 : b === '' ? 1 : 0)).map(([name, items]) => ({ name, items }));
});
const wide = computed(() => apps.value.length > 6);
const isInternal = (app) => app.url.startsWith('/') && !app.new_tab;
</script>
<template>
<Popover v-if="apps.length" v-model:open="appsOpen">
<PopoverTrigger
class="grid size-10 place-items-center rounded-md text-foreground/70 hover:bg-accent hover:text-foreground data-[state=open]:bg-accent"
aria-label="Anwendungen"
title="Anwendungen"
>
<LayoutGrid class="size-5" />
</PopoverTrigger>
<PopoverContent align="end" class="max-h-[min(36rem,calc(100dvh-6rem))] overflow-y-auto p-3" :class="wide ? 'w-[min(34rem,calc(100vw-2rem))]' : 'w-[min(22rem,calc(100vw-2rem))]'">
<div class="grid gap-3">
<div class="flex items-center justify-between px-1">
<p class="text-sm font-semibold">Anwendungen</p>
<span class="text-xs text-muted-foreground">{{ apps.length }}</span>
</div>
<label v-if="apps.length > 8" class="flex h-9 items-center gap-2 rounded-md border px-2.5 text-sm text-muted-foreground focus-within:ring-2 focus-within:ring-ring">
<Search class="size-4" />
<input v-model="query" type="search" placeholder="Anwendung suchen" class="min-w-0 flex-1 bg-transparent text-foreground outline-none" />
</label>
<section v-for="group in groups" :key="group.name" class="grid gap-1">
<h3 v-if="group.name" class="px-1 pt-1 text-xs font-semibold tracking-wide text-muted-foreground uppercase">{{ group.name }}</h3>
<div class="grid gap-1" :class="wide ? 'grid-cols-3' : 'grid-cols-2'">
<component
:is="isInternal(app) ? Link : 'a'"
v-for="app in group.items"
:key="app.label + app.url"
:href="app.url"
:target="app.new_tab ? '_blank' : undefined"
:rel="app.new_tab ? 'noopener' : undefined"
class="group relative flex flex-col items-center gap-2 rounded-lg px-2 py-3 text-center hover:bg-accent"
@click="appsOpen = false"
>
<AppMark :app="app" class="size-11" />
<span class="grid gap-0.5">
<span class="text-[13px] leading-tight font-medium">{{ app.label }}</span>
<span v-if="app.subtitle" class="text-[11px] leading-tight text-muted-foreground">{{ app.subtitle }}</span>
</span>
<ArrowUpRight v-if="app.new_tab" class="absolute top-2 right-2 size-3.5 text-muted-foreground opacity-0 group-hover:opacity-100" aria-label="öffnet in neuem Tab" />
</component>
</div>
</section>
<p v-if="!filtered.length" class="px-1 py-4 text-center text-sm text-muted-foreground">Nichts gefunden.</p>
</div>
</PopoverContent>
</Popover>
</template>