Neues Modul Glossar (0.27.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m52s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m6s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m2s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m31s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m58s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 09:52:00 +00:00
parent d148f2fbe2
commit 0bd20a527e
121 changed files with 946 additions and 298 deletions

View file

@ -0,0 +1,74 @@
<script setup>
import { watch } from 'vue';
import { useForm } from '@inertiajs/vue3';
import { LoaderCircle } from '@lucide/vue';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import FormField from '@/components/FormField.vue';
import RichTextEditor from '@/components/RichTextEditor.vue';
/**
* Begriff anlegen oder bearbeiten.
*/
const props = defineProps({
entry: { type: Object, default: null },
});
const open = defineModel('open', { type: Boolean, default: false });
const form = useForm({ term: '', aliases: '', description: '', link_url: '', link_label: '' });
watch(open, (value) => {
if (!value) return;
form.clearErrors();
form.defaults({
term: props.entry?.term ?? '',
aliases: props.entry?.aliases ?? '',
description: props.entry?.description ?? '',
link_url: props.entry?.link_url ?? '',
link_label: props.entry?.link_label ?? '',
});
form.reset();
});
function submit() {
const options = { preserveScroll: true, onSuccess: () => (open.value = false) };
props.entry ? form.put(`/glossar/${props.entry.id}`, options) : form.post('/glossar', options);
}
</script>
<template>
<Dialog v-model:open="open">
<DialogContent class="sm:max-w-xl">
<DialogHeader>
<DialogTitle>{{ entry ? 'Begriff bearbeiten' : 'Begriff hinzufügen' }}</DialogTitle>
</DialogHeader>
<form class="grid gap-4" @submit.prevent="submit">
<div class="grid gap-4 sm:grid-cols-[minmax(0,1fr)_12rem]">
<FormField id="gl-term" label="Begriff" :error="form.errors.term">
<Input id="gl-term" v-model="form.term" maxlength="150" autofocus placeholder="z. B. Dienstvereinbarung" />
</FormField>
<FormField id="gl-aliases" label="Abkürzung / Synonyme" :error="form.errors.aliases">
<Input id="gl-aliases" v-model="form.aliases" maxlength="255" placeholder="z. B. DV" />
</FormField>
</div>
<FormField id="gl-description" label="Erklärung" :error="form.errors.description">
<RichTextEditor v-model="form.description" bordered min-height="9rem" placeholder="Was bedeutet der Begriff? Wo spielt er eine Rolle?" />
</FormField>
<div class="grid gap-4 sm:grid-cols-2">
<FormField id="gl-link" label="Weiterlesen (optional)" :error="form.errors.link_url">
<Input id="gl-link" v-model="form.link_url" maxlength="1000" placeholder="https://… oder /seiten/…" />
</FormField>
<FormField id="gl-link-label" label="Linktext" :error="form.errors.link_label">
<Input id="gl-link-label" v-model="form.link_label" maxlength="100" placeholder="z. B. Zur Dienstvereinbarung" :disabled="!form.link_url" />
</FormField>
</div>
<DialogFooter>
<Button type="button" variant="outline" @click="open = false">Abbrechen</Button>
<Button type="submit" :disabled="form.processing || !form.term.trim()"><LoaderCircle v-if="form.processing" class="animate-spin" /> Speichern</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
</template>

View file

@ -0,0 +1,227 @@
<script setup>
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { router, usePage } from '@inertiajs/vue3';
import { BookOpen, ExternalLink, Link2, PencilLine, Plus, Search, Trash2, X } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import EmptyState from '@/components/EmptyState.vue';
import PageHeader from '@/components/PageHeader.vue';
import AppLayout from '@/layouts/AppLayout.vue';
import EntryDialog from '../components/EntryDialog.vue';
/**
* Glossar: Begriffe alphabetisch, mit A–Z-Leiste, die beim Scrollen oben mitläuft.
*/
const props = defineProps({
entries: { type: Array, required: true },
canManage: { type: Boolean, default: false },
});
const page = usePage();
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
const LETTERS = [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '#'];
// Suche: Groß-/Kleinschreibung und Umlaute egal
const query = ref('');
const normalize = (text) => String(text ?? '').replace(/<[^>]+>/g, ' ').toLocaleLowerCase('de-DE').normalize('NFD').replace(/[̀-ͯ]/g, '').replace(/ß/g, 'ss');
const visible = computed(() => {
const term = normalize(query.value.trim());
if (!term) return props.entries;
return props.entries.filter((e) => normalize(`${e.term} ${e.aliases ?? ''} ${e.description ?? ''}`).includes(term));
});
const sections = computed(() => LETTERS.map((letter) => ({ letter, entries: visible.value.filter((e) => e.letter === letter) })).filter((s) => s.entries.length));
const available = computed(() => new Set(sections.value.map((s) => s.letter)));
// Aktueller Buchstabe beim Scrollen
const active = ref(null);
let jumpedTo = null;
function onScroll() {
// Nach einem Klick in der Leiste bleibt der Buchstabe markiert, bis selbst gescrollt wird –
// die letzten Buchstaben können am Seitenende nicht ganz nach oben rücken.
if (jumpedTo) {
active.value = jumpedTo;
return;
}
let current = sections.value[0]?.letter ?? null;
for (const section of sections.value) {
const el = document.getElementById(`buchstabe-${section.letter === '#' ? 'ziffern' : section.letter}`);
if (el && el.getBoundingClientRect().top <= 150) current = section.letter;
}
active.value = current;
}
function jump(letter) {
if (!available.value.has(letter)) return;
jumpedTo = letter;
active.value = letter;
document.getElementById(`buchstabe-${letter === '#' ? 'ziffern' : letter}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
// Direktlink auf einen Begriff (z. B. aus der Suche): hinscrollen und kurz hervorheben
const highlighted = ref(null);
function openHash() {
const match = window.location.hash.match(/^#begriff-(\d+)$/);
if (!match) return;
nextTick(() => {
document.getElementById(`begriff-${match[1]}`)?.scrollIntoView({ block: 'center' });
highlighted.value = Number(match[1]);
setTimeout(() => (highlighted.value = null), 2500);
});
}
const releaseJump = () => (jumpedTo = null);
// Auf schmalen Bildschirmen scrollt die Leiste selbst – aktiven Buchstaben sichtbar halten
const bar = ref(null);
watch(active, (letter) => {
const button = bar.value?.querySelector(`[data-letter="${letter}"]`);
const list = bar.value;
if (button && list && list.scrollWidth > list.clientWidth) {
list.scrollTo({ left: button.offsetLeft - list.clientWidth / 2 + button.clientWidth / 2, behavior: 'smooth' });
}
});
onMounted(() => {
window.addEventListener('scroll', onScroll, { passive: true });
['wheel', 'touchstart', 'keydown'].forEach((type) => window.addEventListener(type, releaseJump, { passive: true }));
onScroll();
openHash();
});
onBeforeUnmount(() => {
window.removeEventListener('scroll', onScroll);
['wheel', 'touchstart', 'keydown'].forEach((type) => window.removeEventListener(type, releaseJump));
});
watch(sections, () => nextTick(onScroll));
// Pflege
const dialog = ref({ open: false, entry: null });
function remove(entry) {
if (window.confirm(`„${entry.term}“ aus dem Glossar löschen?`)) {
router.delete(`/glossar/${entry.id}`, { preserveScroll: true });
}
}
async function copyLink(entry) {
try {
await navigator.clipboard.writeText(`${window.location.origin}/glossar#${entry.anchor}`);
toast.success('Link kopiert');
} catch {
toast.error('Kopieren nicht möglich');
}
}
const isExternal = (url) => /^https?:\/\//i.test(url ?? '');
</script>
<template>
<AppLayout title="Glossar">
<PageHeader title="Glossar" :description="`${entries.length} ${entries.length === 1 ? 'Begriff' : 'Begriffe'} und Abkürzungen – kurz erklärt.`">
<template #actions>
<div class="relative w-full sm:w-72">
<Search class="pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground" />
<input
v-model="query"
type="search"
placeholder="Begriff suchen …"
aria-label="Glossar durchsuchen"
class="h-10 w-full rounded-md border border-input bg-card pr-9 pl-9 text-sm shadow-xs focus-visible:border-brand-400 focus-visible:ring-3 focus-visible:ring-ring/30 focus-visible:outline-none [&::-webkit-search-cancel-button]:hidden"
/>
<button v-if="query" type="button" class="absolute top-1/2 right-2.5 -translate-y-1/2 text-muted-foreground hover:text-foreground" aria-label="Suche leeren" @click="query = ''"><X class="size-4" /></button>
</div>
<Button v-if="canManage" class="h-10" @click="dialog = { open: true, entry: null }"><Plus /> Begriff</Button>
</template>
</PageHeader>
<!-- A–Z-Leiste: klebt beim Scrollen unter der Kopfzeile -->
<nav class="sticky top-16 z-30 -mx-4 mb-6 border-y bg-background/95 px-4 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/80 lg:-mx-6 lg:px-6" aria-label="Alphabet">
<ol ref="bar" class="relative flex gap-1 overflow-x-auto [scrollbar-width:none] lg:justify-between [&::-webkit-scrollbar]:hidden">
<li v-for="letter in LETTERS" :key="letter" class="shrink-0">
<button
type="button"
class="grid size-8 place-items-center rounded-md text-sm font-semibold transition-colors"
:class="[
!available.has(letter) ? 'cursor-default text-muted-foreground/40' : active === letter ? 'bg-brand text-brand-foreground' : 'text-foreground hover:bg-accent',
]"
:disabled="!available.has(letter)"
:data-letter="letter"
:aria-current="active === letter ? 'location' : undefined"
:aria-label="letter === '#' ? 'Zahlen und Zeichen' : `Buchstabe ${letter}`"
@click="jump(letter)"
>
{{ letter }}
</button>
</li>
</ol>
</nav>
<div v-if="sections.length" class="grid gap-8">
<section
v-for="section in sections"
:id="`buchstabe-${section.letter === '#' ? 'ziffern' : section.letter}`"
:key="section.letter"
class="grid scroll-mt-32 gap-4 md:grid-cols-[4rem_minmax(0,1fr)]"
>
<h2 class="text-3xl leading-none font-semibold text-brand-text md:sticky md:top-36 md:self-start">{{ section.letter }}</h2>
<ul class="divide-y overflow-hidden rounded-lg border bg-card">
<li
v-for="entry in section.entries"
:id="entry.anchor"
:key="entry.id"
class="group scroll-mt-36 px-5 py-4 transition-colors"
:class="{ 'bg-brand-soft/60': highlighted === entry.id }"
>
<div class="flex items-start gap-3">
<h3 class="min-w-0 flex-1 text-base font-semibold break-words">
{{ entry.term }}
<span v-if="entry.aliases" class="ml-1.5 rounded bg-muted px-1.5 py-0.5 align-middle text-xs font-medium text-muted-foreground">{{ entry.aliases }}</span>
</h3>
<div class="flex shrink-0 items-center gap-0.5 opacity-100 transition-opacity md:opacity-0 md:group-focus-within:opacity-100 md:group-hover:opacity-100">
<Button size="icon" variant="ghost" class="size-8 text-muted-foreground" :aria-label="`Link zu ${entry.term} kopieren`" @click="copyLink(entry)"><Link2 /></Button>
<template v-if="canManage">
<Button size="icon" variant="ghost" class="size-8 text-muted-foreground" :aria-label="`${entry.term} bearbeiten`" @click="dialog = { open: true, entry }"><PencilLine /></Button>
<Button size="icon" variant="ghost" class="size-8 text-muted-foreground hover:text-destructive" :aria-label="`${entry.term} löschen`" @click="remove(entry)"><Trash2 /></Button>
</template>
</div>
</div>
<div v-if="entry.description" class="prose prose-sm mt-1.5 max-w-none break-words text-foreground/90 dark:prose-invert" v-html="entry.description" />
<a
v-if="entry.link_url"
:href="entry.link_url"
:target="isExternal(entry.link_url) ? '_blank' : undefined"
:rel="isExternal(entry.link_url) ? 'noopener' : undefined"
class="mt-2 inline-flex items-center gap-1 text-[13px] font-medium text-brand-text hover:underline"
>
{{ entry.link_label || 'Weiterlesen' }} <ExternalLink class="size-3.5" />
</a>
</li>
</ul>
</section>
</div>
<div v-else class="rounded-lg border border-dashed bg-card">
<EmptyState
:icon="BookOpen"
:title="query ? 'Nichts gefunden' : 'Noch keine Begriffe'"
:text="query ? `Kein Begriff passt zu „${query}“.` : canManage ? 'Mit „Begriff“ oben rechts den ersten Eintrag anlegen.' : 'Hier erscheinen bald Begriffe und Abkürzungen.'"
/>
</div>
<EntryDialog v-if="canManage" v-model:open="dialog.open" :entry="dialog.entry" />
</AppLayout>
</template>