Verleih 1.0.0: Verleihsystem für Inhaus

Übersicht mit Status und Standort, Anfragen im Portal (Benachrichtigung +
E-Mail ans Team), Zusagen/Absagen mit automatischem Eintrag, Zurücknehmen,
Recht „Verleih verwalten“, einstellbare Bezeichnungen und Übernahme aus dem
WordPress-Plugin „FL-Verleihsystem“ (WXR mit Bildern).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-28 15:17:47 +00:00
commit 14aaa16b30
47 changed files with 4208 additions and 0 deletions

12
resources/css/style.css Normal file
View file

@ -0,0 +1,12 @@
/* Tailwind mit den Design-Tokens des Portals – Klassen mit Präfix „ih:“, z. B. ih:bg-brand, ih:text-muted-foreground, ih:rounded-lg */
@import "../../inhaus-sdk/theme.css";
@source "../js";
/* Beschreibung (bereinigtes HTML aus dem Editor bzw. aus WordPress) */
.verleih-text p { margin: 0.5rem 0; }
.verleih-text p:first-child { margin-top: 0; }
.verleih-text p:last-child { margin-bottom: 0; }
.verleih-text ul { list-style: disc; padding-left: 1.25rem; margin: 0.5rem 0; }
.verleih-text ol { list-style: decimal; padding-left: 1.25rem; margin: 0.5rem 0; }
.verleih-text h2, .verleih-text h3 { font-weight: 600; margin: 1rem 0 0.5rem; }
.verleih-text a { color: var(--color-brand-text); text-decoration: underline; }

View file

@ -0,0 +1,26 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { ImageOff, MapPin } from '@lucide/vue';
import StatusBadge from './StatusBadge.vue';
defineProps({
item: { type: Object, required: true },
});
</script>
<template>
<article class="ih:group ih:flex ih:flex-col ih:overflow-hidden ih:rounded-lg ih:border ih:bg-card ih:shadow-xs ih:transition-shadow ih:hover:shadow-md">
<!-- Kunstwerke nicht beschneiden: ganzes Bild auf ruhigem Grund -->
<Link :href="item.url" prefetch class="ih:relative ih:grid ih:aspect-[4/3] ih:place-items-center ih:overflow-hidden ih:bg-muted ih:p-3">
<img v-if="item.thumb_url" :src="item.thumb_url" :alt="item.title" loading="lazy" class="ih:max-h-full ih:max-w-full ih:object-contain ih:shadow-sm ih:transition-transform ih:duration-300 ih:group-hover:scale-[1.02]" />
<ImageOff v-else class="ih:size-8 ih:text-muted-foreground" :stroke-width="1.5" />
<StatusBadge :lent="item.lent" class="ih:absolute ih:top-2 ih:left-2" />
</Link>
<div class="ih:flex ih:flex-1 ih:flex-col ih:gap-1 ih:p-3">
<Link :href="item.url" prefetch class="ih:line-clamp-2 ih:text-[15px] ih:leading-snug ih:font-semibold ih:hover:underline">{{ item.title }}</Link>
<p v-if="item.location" class="ih:mt-auto ih:flex ih:items-center ih:gap-1 ih:pt-1 ih:text-xs ih:text-muted-foreground">
<MapPin class="ih:size-3.5 ih:shrink-0" /><span class="ih:truncate">{{ item.location }}</span>
</p>
</div>
</article>
</template>

View file

@ -0,0 +1,62 @@
<script setup>
import { useForm } from '@inertiajs/vue3';
import { LoaderCircle, Send } from '@lucide/vue';
import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FormField, Input, Textarea } from '@inhaus/ui';
const props = defineProps({
item: { type: Object, required: true },
labels: { type: Object, required: true },
defaultLocation: { type: String, default: null },
});
const open = defineModel('open', { type: Boolean, default: false });
const today = new Date().toISOString().slice(0, 10);
const form = useForm({ location: props.defaultLocation ?? '', from: '', until: '', message: '' });
function submit() {
form.post(`/verleih/${props.item.id}/anfragen`, {
preserveScroll: true,
onSuccess: () => {
open.value = false;
form.reset('from', 'until', 'message');
},
});
}
</script>
<template>
<Dialog v-model:open="open">
<DialogContent class="ih:sm:max-w-lg">
<DialogHeader>
<DialogTitle>„{{ item.title }}“ anfragen</DialogTitle>
<DialogDescription>
Das Team bekommt Ihre Anfrage im Portal und per E-Mail und meldet sich bei Ihnen.
<template v-if="item.lent"> Gerade ist es verliehen – Sie können es trotzdem für später anfragen.</template>
</DialogDescription>
</DialogHeader>
<form id="verleih-anfrage" class="ih:grid ih:gap-4" @submit.prevent="submit">
<FormField id="vl-location" label="Wo soll es hin?" :error="form.errors.location">
<Input id="vl-location" v-model="form.location" maxlength="200" placeholder="z. B. Verwaltung, Besprechungsraum 2. OG" required />
</FormField>
<div class="ih:grid ih:gap-4 ih:sm:grid-cols-2">
<FormField id="vl-from" label="Ab (optional)" :error="form.errors.from">
<Input id="vl-from" v-model="form.from" type="date" :min="today" />
</FormField>
<FormField id="vl-until" label="Bis (optional)" :error="form.errors.until">
<Input id="vl-until" v-model="form.until" type="date" :min="form.from || today" />
</FormField>
</div>
<FormField id="vl-message" label="Nachricht (optional)" :error="form.errors.message">
<Textarea id="vl-message" v-model="form.message" rows="3" maxlength="2000" placeholder="z. B. Anlass, Ansprechperson vor Ort …" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="open = false">Abbrechen</Button>
<Button type="submit" form="verleih-anfrage" :disabled="form.processing || !form.location.trim()">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /><Send v-else /> Anfrage senden
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</template>

View file

@ -0,0 +1,15 @@
<script setup>
defineProps({
lent: { type: Boolean, required: true },
});
</script>
<template>
<span
class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:px-2 ih:py-0.5 ih:text-[11px] ih:font-semibold ih:shadow-xs"
:class="lent ? 'ih:bg-card ih:text-muted-foreground' : 'ih:bg-brand ih:text-brand-foreground'"
>
<span class="ih:size-1.5 ih:rounded-full" :class="lent ? 'ih:bg-muted-foreground' : 'ih:bg-brand-foreground'" aria-hidden="true" />
{{ lent ? 'Verliehen' : 'Verfügbar' }}
</span>
</template>

View file

@ -0,0 +1,22 @@
<script setup>
import { Link } from '@inertiajs/vue3';
import { Panel, formatRelative } from '@inhaus/ui';
defineProps({ pending: { type: Array, required: true } });
</script>
<template>
<Panel title="Verleih – offene Anfragen" action-label="Zu den Anfragen" action-href="/verleih/anfragen">
<ul v-if="pending.length" class="ih:-mx-5 ih:divide-y ih:border-t">
<li v-for="r in pending" :key="r.id" class="ih:flex ih:items-center ih:gap-3 ih:px-5 ih:py-2.5">
<img v-if="r.item?.thumb_url" :src="r.item.thumb_url" alt="" class="ih:size-10 ih:rounded ih:bg-muted ih:object-contain" />
<div class="ih:min-w-0 ih:flex-1">
<Link :href="r.item?.url ?? '/verleih/anfragen'" class="ih:block ih:truncate ih:text-sm ih:font-medium ih:hover:underline">{{ r.item?.title }}</Link>
<p class="ih:truncate ih:text-xs ih:text-muted-foreground">{{ r.user?.name }} · nach {{ r.location }}</p>
</div>
<span class="ih:shrink-0 ih:text-xs ih:text-muted-foreground">{{ formatRelative(r.created_at) }}</span>
</li>
</ul>
<p v-else class="ih:text-sm ih:text-muted-foreground">Keine offenen Anfragen.</p>
</Panel>
</template>

View file

@ -0,0 +1,123 @@
<script setup>
import { computed, ref } from 'vue';
import { Link, useForm } from '@inertiajs/vue3';
import { ChevronLeft, ImagePlus, LoaderCircle, Trash2 } from '@lucide/vue';
import { AppLayout, Button, FormField, Input, PageHeader, Panel, RichTextEditor } from '@inhaus/ui';
const props = defineProps({
item: { type: Object, default: null },
labels: { type: Object, required: true },
});
const it = props.item;
const form = useForm({
title: it?.title ?? '',
description: it?.description ?? '',
lent: it?.lent ?? false,
location: it?.location ?? '',
image: null,
remove_image: false,
});
const preview = ref(it?.image_url ?? null);
const fileInput = ref(null);
const dragging = ref(false);
function choose(files) {
const file = [...files].find((f) => f.type.startsWith('image/'));
if (!file) return;
form.image = file;
form.remove_image = false;
preview.value = URL.createObjectURL(file);
}
function removeImage() {
form.image = null;
form.remove_image = true;
preview.value = null;
}
const title = computed(() => (it ? `${props.labels.singular} bearbeiten` : `${props.labels.singular} erfassen`));
function submit() {
form.transform((data) => ({ ...data, lent: data.lent ? 1 : 0, remove_image: data.remove_image ? 1 : 0 }))
.post(it ? `/verleih/${it.id}` : '/verleih', { forceFormData: true });
}
</script>
<template>
<AppLayout :title="title">
<Link :href="it ? it.url : '/verleih'" class="ih:mb-4 ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground">
<ChevronLeft class="ih:size-4" /> {{ it ? it.title : labels.title }}
</Link>
<PageHeader :title="title" />
<form class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_20rem]" @submit.prevent="submit">
<div class="ih:grid ih:min-w-0 ih:content-start ih:gap-6">
<Panel>
<div class="ih:grid ih:gap-5">
<FormField id="vl-title" label="Titel" :error="form.errors.title">
<Input id="vl-title" v-model="form.title" maxlength="200" required placeholder="z. B. „Sommerwiese“, Acryl auf Leinwand" />
</FormField>
<FormField id="vl-description" label="Beschreibung" :error="form.errors.description" hint="Z. B. Künstlerin oder Künstler, Maße, Technik – alles, was bei der Auswahl hilft.">
<RichTextEditor id="vl-description" v-model="form.description" bordered min-height="12rem" :headings="[2, 3]" placeholder="Beschreibung …" />
</FormField>
</div>
</Panel>
</div>
<aside class="ih:grid ih:content-start ih:gap-6">
<Panel>
<div class="ih:grid ih:gap-3">
<p class="ih:text-[13px] ih:font-medium">Foto</p>
<div
class="ih:relative ih:grid ih:aspect-[4/3] ih:place-items-center ih:overflow-hidden ih:rounded-md ih:border ih:border-dashed ih:bg-muted ih:p-2"
:class="dragging ? 'ih:border-brand ih:bg-brand-soft' : ''"
@dragover.prevent="dragging = true"
@dragleave="dragging = false"
@drop.prevent="dragging = false; choose($event.dataTransfer.files)"
>
<img v-if="preview" :src="preview" alt="Vorschau" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<button v-else type="button" class="ih:grid ih:justify-items-center ih:gap-1 ih:text-sm ih:text-muted-foreground" @click="fileInput.click()">
<ImagePlus class="ih:size-8" :stroke-width="1.5" /> Foto wählen oder hierher ziehen
</button>
</div>
<input ref="fileInput" type="file" accept="image/jpeg,image/png,image/webp" class="ih:hidden" @change="choose($event.target.files)" />
<div v-if="preview" class="ih:flex ih:gap-2">
<Button type="button" variant="outline" size="sm" @click="fileInput.click()"><ImagePlus /> Anderes Foto</Button>
<Button type="button" variant="ghost" size="sm" class="ih:text-destructive" @click="removeImage"><Trash2 /> Entfernen</Button>
</div>
<p v-if="form.errors.image" class="ih:text-[13px] ih:text-destructive">{{ form.errors.image }}</p>
<p v-if="form.progress" class="ih:text-[13px] ih:text-muted-foreground">Wird hochgeladen … {{ form.progress.percentage }} %</p>
</div>
</Panel>
<Panel>
<fieldset class="ih:grid ih:gap-4">
<legend class="ih:mb-2 ih:text-[13px] ih:font-medium">Verleihstatus</legend>
<div class="ih:grid ih:grid-cols-2 ih:gap-1 ih:rounded-md ih:bg-muted ih:p-1" role="radiogroup" aria-label="Verleihstatus">
<button
v-for="option in [{ value: false, label: 'Verfügbar' }, { value: true, label: 'Verliehen' }]"
:key="option.label"
type="button"
role="radio"
:aria-checked="form.lent === option.value"
class="ih:rounded ih:py-1.5 ih:text-sm ih:font-medium"
:class="form.lent === option.value ? 'ih:bg-card ih:shadow-xs' : 'ih:text-muted-foreground'"
@click="form.lent = option.value"
>{{ option.label }}</button>
</div>
<FormField id="vl-location" :label="form.lent ? 'Verliehen an / Ort' : 'Aktueller Standort'" :error="form.errors.location">
<Input id="vl-location" v-model="form.location" maxlength="200" :placeholder="form.lent ? 'z. B. Verwaltung, Flur 1. OG' : 'z. B. Lager Künstlerteam'" />
</FormField>
</fieldset>
</Panel>
<Button type="submit" size="lg" :disabled="form.processing || !form.title.trim()">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /> Speichern
</Button>
</aside>
</form>
</AppLayout>
</template>

View file

@ -0,0 +1,114 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, router, usePage } from '@inertiajs/vue3';
import { Images, Inbox, Plus, Search, Settings2 } from '@lucide/vue';
import { AppLayout, Button, EmptyState, PageHeader, formatDate, toast } from '@inhaus/ui';
import ItemCard from '../components/ItemCard.vue';
const props = defineProps({
items: { type: Array, required: true },
filters: { type: Object, required: true },
counts: { type: Object, required: true },
labels: { type: Object, required: true },
canManage: { type: Boolean, default: false },
pendingRequests: { type: Number, default: null },
myRequests: { type: Array, default: () => [] },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const query = ref(props.filters.q);
let timer;
watch(query, (value) => {
clearTimeout(timer);
timer = setTimeout(() => apply({ q: value }), 300);
});
function apply(changes) {
const params = { ...props.filters, ...changes };
router.get('/verleih', Object.fromEntries(Object.entries(params).filter(([, v]) => v)), { preserveState: true, preserveScroll: true, replace: true });
}
const tabs = [
{ value: null, label: 'Alle', count: 'all' },
{ value: 'verfuegbar', label: 'Verfügbar', count: 'available' },
{ value: 'verliehen', label: 'Verliehen', count: 'lent' },
];
const cancel = (request) => window.confirm('Anfrage zurückziehen?') && router.delete(`/verleih/anfragen/${request.id}`, { preserveScroll: true });
</script>
<template>
<AppLayout :title="labels.title">
<PageHeader :title="labels.title" :description="`Alle ${labels.plural} auf einen Blick – verfügbar oder verliehen, und wo sie gerade sind.`">
<template #actions>
<template v-if="canManage">
<Button variant="outline" as-child>
<Link href="/verleih/anfragen"><Inbox /> Anfragen<span v-if="pendingRequests" class="ih:rounded-full ih:bg-brand ih:px-1.5 ih:text-[11px] ih:text-brand-foreground">{{ pendingRequests }}</span></Link>
</Button>
<Button as-child><Link href="/verleih/neu"><Plus /> {{ labels.singular }} erfassen</Link></Button>
</template>
</template>
</PageHeader>
<!-- Eigene Anfragen -->
<section v-if="myRequests.length" class="ih:mb-6 ih:rounded-lg ih:border ih:bg-card ih:p-4" aria-labelledby="meine-anfragen">
<h2 id="meine-anfragen" class="ih:mb-2 ih:text-sm ih:font-semibold">Ihre Anfragen</h2>
<ul class="ih:divide-y">
<li v-for="request in myRequests" :key="request.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:py-2 ih:text-sm">
<Link :href="request.item.url" class="ih:font-medium ih:hover:underline">{{ request.item.title }}</Link>
<span class="ih:text-muted-foreground">nach {{ request.location }}</span>
<span
class="ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium"
:class="request.status === 'accepted' ? 'ih:bg-brand ih:text-brand-foreground' : request.status === 'pending' ? 'ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-muted ih:text-muted-foreground'"
>{{ request.status_label }}</span>
<span v-if="request.note" class="ih:text-muted-foreground">„{{ request.note }}“</span>
<span class="ih:ml-auto ih:text-xs ih:text-muted-foreground">{{ formatDate(request.created_at) }}</span>
<button v-if="request.status === 'pending'" type="button" class="ih:text-xs ih:font-medium ih:text-muted-foreground ih:hover:text-destructive" @click="cancel(request)">Zurückziehen</button>
</li>
</ul>
</section>
<div class="ih:mb-5 ih:flex ih:flex-wrap ih:items-center ih:gap-3">
<nav class="ih:flex ih:flex-wrap ih:gap-1.5" aria-label="Status">
<button
v-for="tab in tabs"
:key="tab.label"
type="button"
class="ih:inline-flex ih:items-center ih:gap-1.5 ih:rounded-full ih:border ih:px-3 ih:py-1 ih:text-[13px]"
:class="filters.status === tab.value ? 'ih:border-brand ih:bg-brand ih:text-brand-foreground' : 'ih:bg-card ih:hover:bg-accent'"
:aria-pressed="filters.status === tab.value"
@click="apply({ status: tab.value })"
>
{{ tab.label }} <span class="ih:tabular-nums ih:opacity-75">{{ counts[tab.count] }}</span>
</button>
</nav>
<div class="ih:relative ih:ml-auto ih:w-full ih:sm:w-64">
<Search class="ih:pointer-events-none ih:absolute ih:top-1/2 ih:left-2.5 ih:size-4 ih:-translate-y-1/2 ih:text-muted-foreground" />
<input
v-model="query"
type="search"
:placeholder="`${labels.plural} oder Orte suchen`"
:aria-label="`${labels.plural} durchsuchen`"
class="ih:h-9 ih:w-full ih:rounded-md ih:border ih:border-input ih:bg-card ih:pr-3 ih:pl-8 ih:text-sm ih:shadow-xs ih:focus-visible:ring-3 ih:focus-visible:ring-ring/30 ih:focus-visible:outline-none"
/>
</div>
</div>
<div v-if="items.length" class="ih:grid ih:grid-cols-2 ih:gap-3 ih:sm:gap-4 ih:md:grid-cols-3 ih:xl:grid-cols-4">
<ItemCard v-for="item in items" :key="item.id" :item="item" />
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
<EmptyState
:icon="Images"
:title="filters.q || filters.status ? `Keine passenden ${labels.plural}` : `Noch keine ${labels.plural}`"
:text="canManage && !filters.q && !filters.status ? `Legen Sie mit „${labels.singular} erfassen“ los – oder übernehmen Sie den Bestand aus WordPress (Administration → Portal → Verleih).` : ''"
/>
</div>
<p v-if="canManage" class="ih:mt-6 ih:flex ih:items-center ih:gap-1.5 ih:text-xs ih:text-muted-foreground">
<Settings2 class="ih:size-3.5" /> Bezeichnungen und Übernahme aus WordPress: Administration → Portal → Verleih
</p>
</AppLayout>
</template>

View file

@ -0,0 +1,128 @@
<script setup>
import { ref, watch } from 'vue';
import { Link, useForm, usePage } from '@inertiajs/vue3';
import { CalendarDays, Check, ChevronLeft, ImageOff, Inbox, LoaderCircle, MapPin, MessageSquareText, X } from '@lucide/vue';
import {
AppLayout,
Button,
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
EmptyState,
FormField,
PageHeader,
PersonAvatar,
Textarea,
formatDate,
formatRelative,
toast,
} from '@inhaus/ui';
import StatusBadge from '../components/StatusBadge.vue';
defineProps({
pending: { type: Array, required: true },
recent: { type: Array, default: () => [] },
labels: { type: Object, required: true },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
// Zusagen / Absagen mit optionalem Hinweis
const deciding = ref(null); // { request, accept }
const form = useForm({ note: '' });
function open(request, accept) {
form.reset();
form.clearErrors();
deciding.value = { request, accept };
}
function submit() {
const { request, accept } = deciding.value;
form.post(`/verleih/anfragen/${request.id}/${accept ? 'zusagen' : 'absagen'}`, { preserveScroll: true, onSuccess: () => (deciding.value = null) });
}
const period = (r) => [r.from ? `ab ${formatDate(r.from)}` : null, r.until ? `bis ${formatDate(r.until)}` : null].filter(Boolean).join(' ');
</script>
<template>
<AppLayout title="Anfragen">
<Link href="/verleih" class="ih:mb-4 ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> {{ labels.title }}</Link>
<PageHeader title="Anfragen" :description="`Zusagen trägt das ${labels.singular} gleich als verliehen ein – mit Wunschort und Person. Die anfragende Person wird benachrichtigt.`" />
<section aria-labelledby="offen" class="ih:mb-8">
<h2 id="offen" class="ih:mb-3 ih:text-sm ih:font-semibold">Offen <span class="ih:text-muted-foreground">({{ pending.length }})</span></h2>
<div v-if="pending.length" class="ih:grid ih:gap-3">
<article v-for="request in pending" :key="request.id" class="ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-4 ih:sm:grid-cols-[7rem_minmax(0,1fr)_auto] ih:sm:items-center">
<Link :href="request.item?.url ?? '#'" class="ih:grid ih:aspect-[4/3] ih:w-28 ih:place-items-center ih:overflow-hidden ih:rounded-md ih:bg-muted">
<img v-if="request.item?.thumb_url" :src="request.item.thumb_url" :alt="request.item.title" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<ImageOff v-else class="ih:size-6 ih:text-muted-foreground" />
</Link>
<div class="ih:grid ih:min-w-0 ih:gap-1.5">
<div class="ih:flex ih:flex-wrap ih:items-center ih:gap-2">
<Link :href="request.item?.url ?? '#'" class="ih:font-semibold ih:hover:underline">{{ request.item?.title }}</Link>
<StatusBadge v-if="request.item" :lent="request.item.lent" class="ih:border" />
</div>
<p class="ih:flex ih:items-center ih:gap-2 ih:text-sm">
<PersonAvatar :person="request.user" class="ih:size-6" />
<span><span class="ih:font-medium">{{ request.user?.name }}</span><span v-if="request.user?.department" class="ih:text-muted-foreground"> · {{ request.user.department }}</span></span>
<span class="ih:text-xs ih:text-muted-foreground">{{ formatRelative(request.created_at) }}</span>
</p>
<p class="ih:flex ih:flex-wrap ih:gap-x-4 ih:gap-y-1 ih:text-sm ih:text-muted-foreground">
<span class="ih:inline-flex ih:items-center ih:gap-1"><MapPin class="ih:size-3.5" /> {{ request.location }}</span>
<span v-if="period(request)" class="ih:inline-flex ih:items-center ih:gap-1"><CalendarDays class="ih:size-3.5" /> {{ period(request) }}</span>
</p>
<p v-if="request.message" class="ih:flex ih:gap-1.5 ih:text-sm"><MessageSquareText class="ih:mt-0.5 ih:size-3.5 ih:shrink-0 ih:text-muted-foreground" /> „{{ request.message }}“</p>
<p v-if="request.item?.lent" class="ih:text-xs ih:text-muted-foreground">Gerade verliehen{{ request.item.location ? ` (${request.item.location})` : '' }} – eine Zusage trägt den neuen Ort ein.</p>
</div>
<div class="ih:flex ih:gap-2 ih:sm:flex-col">
<Button @click="open(request, true)"><Check /> Zusagen</Button>
<Button variant="outline" @click="open(request, false)"><X /> Absagen</Button>
</div>
</article>
</div>
<div v-else class="ih:rounded-lg ih:border ih:bg-card">
<EmptyState :icon="Inbox" title="Keine offenen Anfragen" text="Neue Anfragen kommen im Portal und per E-Mail." />
</div>
</section>
<section v-if="recent.length" aria-labelledby="zuletzt">
<h2 id="zuletzt" class="ih:mb-3 ih:text-sm ih:font-semibold">Zuletzt beantwortet</h2>
<ul class="ih:divide-y ih:rounded-lg ih:border ih:bg-card">
<li v-for="request in recent" :key="request.id" class="ih:flex ih:flex-wrap ih:items-center ih:gap-x-3 ih:gap-y-1 ih:px-4 ih:py-2.5 ih:text-sm">
<Link :href="request.item?.url ?? '#'" class="ih:font-medium ih:hover:underline">{{ request.item?.title }}</Link>
<span class="ih:text-muted-foreground">{{ request.user?.name }} · {{ request.location }}</span>
<span class="ih:rounded-full ih:px-2 ih:py-0.5 ih:text-xs ih:font-medium" :class="request.status === 'accepted' ? 'ih:bg-brand-soft ih:text-brand-text' : 'ih:bg-muted ih:text-muted-foreground'">{{ request.status_label }}</span>
<span class="ih:ml-auto ih:text-xs ih:text-muted-foreground">{{ request.decider ? `${request.decider.name}, ` : '' }}{{ formatDate(request.decided_at ?? request.created_at) }}</span>
</li>
</ul>
</section>
<Dialog :open="!!deciding" @update:open="(v) => !v && (deciding = null)">
<DialogContent v-if="deciding" class="ih:sm:max-w-md">
<DialogHeader>
<DialogTitle>{{ deciding.accept ? 'Zusagen' : 'Absagen' }}: {{ deciding.request.item?.title }}</DialogTitle>
<DialogDescription>
<template v-if="deciding.accept">Wird als verliehen an {{ deciding.request.user?.name }} nach „{{ deciding.request.location }}“ eingetragen.</template>
<template v-else>{{ deciding.request.user?.name }} bekommt die Absage im Portal und per E-Mail.</template>
</DialogDescription>
</DialogHeader>
<form id="verleih-entscheidung" @submit.prevent="submit">
<FormField id="vl-note" label="Hinweis (optional)" :error="form.errors.note || form.errors.status">
<Textarea id="vl-note" v-model="form.note" rows="3" maxlength="1000" :placeholder="deciding.accept ? 'z. B. Wir bringen es am Montag vorbei.' : 'z. B. Ist bis Ende März schon vergeben.'" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="deciding = null">Abbrechen</Button>
<Button type="submit" form="verleih-entscheidung" :variant="deciding.accept ? 'default' : 'destructive'" :disabled="form.processing">
<LoaderCircle v-if="form.processing" class="ih:animate-spin" /> {{ deciding.accept ? 'Zusagen' : 'Absagen' }}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
</AppLayout>
</template>

149
resources/js/pages/Show.vue Normal file
View file

@ -0,0 +1,149 @@
<script setup>
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { Link, router, useForm, usePage } from '@inertiajs/vue3';
import { CalendarDays, ChevronLeft, Clock, ImageOff, LoaderCircle, MapPin, PencilLine, Send, Trash2, Undo2, UserRound, X } from '@lucide/vue';
import { AppLayout, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, FormField, Input, PersonAvatar, formatDate, toast } from '@inhaus/ui';
import RequestDialog from '../components/RequestDialog.vue';
import StatusBadge from '../components/StatusBadge.vue';
const props = defineProps({
item: { type: Object, required: true },
labels: { type: Object, required: true },
canManage: { type: Boolean, default: false },
myRequest: { type: Object, default: null },
defaultLocation: { type: String, default: null },
requests: { type: Array, default: () => [] },
});
const page = usePage();
watch(() => page.props.flash?.status, (status) => status && toast.success(status), { immediate: true });
const item = computed(() => props.item);
const requesting = ref(false);
const zoom = ref(false);
const onKey = (event) => event.key === 'Escape' && (zoom.value = false);
watch(zoom, (open) => (open ? window.addEventListener('keydown', onKey) : window.removeEventListener('keydown', onKey)));
onBeforeUnmount(() => window.removeEventListener('keydown', onKey));
// Team: zurücknehmen mit neuem Standort
const returning = ref(false);
const giveBack = useForm({ location: '' });
const submitReturn = () => giveBack.post(`/verleih/${item.value.id}/zurueck`, { preserveScroll: true, onSuccess: () => (returning.value = false) });
const cancel = () => window.confirm('Anfrage zurückziehen?') && router.delete(`/verleih/anfragen/${props.myRequest.id}`, { preserveScroll: true });
const remove = () => window.confirm(`„${item.value.title}“ endgültig löschen?`) && router.delete(`/verleih/${item.value.id}`);
const period = (from, until) =>
[from ? `ab ${formatDate(from)}` : null, until ? `bis ${formatDate(until)}` : null].filter(Boolean).join(' ');
</script>
<template>
<AppLayout :title="item.title">
<div class="ih:mb-4 ih:flex ih:flex-wrap ih:items-center ih:justify-between ih:gap-3">
<Link href="/verleih" class="ih:inline-flex ih:items-center ih:gap-1 ih:text-sm ih:font-medium ih:text-muted-foreground ih:hover:text-foreground"><ChevronLeft class="ih:size-4" /> {{ labels.title }}</Link>
<div v-if="canManage" class="ih:flex ih:gap-2">
<Button variant="outline" size="sm" as-child><Link :href="`/verleih/${item.id}/bearbeiten`"><PencilLine /> Bearbeiten</Link></Button>
<Button variant="ghost" size="sm" class="ih:text-destructive ih:hover:text-destructive" @click="remove"><Trash2 /> Löschen</Button>
</div>
</div>
<div class="ih:grid ih:gap-6 ih:lg:grid-cols-[minmax(0,1fr)_22rem]">
<!-- Bild: ganz, ohne Zuschnitt -->
<div class="ih:grid ih:min-w-0 ih:content-start ih:gap-6">
<button
v-if="item.image_url"
type="button"
class="ih:grid ih:place-items-center ih:rounded-lg ih:border ih:bg-muted ih:p-4 ih:sm:p-8"
:aria-label="`${item.title} vergrößern`"
@click="zoom = true"
>
<img :src="item.image_url" :alt="item.title" class="ih:max-h-[70vh] ih:w-auto ih:max-w-full ih:object-contain ih:shadow-md" />
</button>
<div v-else class="ih:grid ih:aspect-[4/3] ih:place-items-center ih:rounded-lg ih:border ih:bg-muted ih:text-muted-foreground">
<ImageOff class="ih:size-10" :stroke-width="1.5" />
</div>
<section v-if="item.description" class="ih:rounded-lg ih:border ih:bg-card ih:p-5">
<!-- serverseitig bereinigtes HTML -->
<div class="verleih-text ih:text-[15px] ih:leading-relaxed" v-html="item.description" />
</section>
</div>
<aside class="ih:grid ih:content-start ih:gap-4 ih:lg:sticky ih:lg:top-24">
<section class="ih:grid ih:gap-4 ih:rounded-lg ih:border ih:bg-card ih:p-5">
<div class="ih:grid ih:gap-2">
<StatusBadge :lent="item.lent" class="ih:w-fit ih:border" />
<h1 class="ih:text-xl ih:leading-snug ih:font-semibold">{{ item.title }}</h1>
</div>
<dl class="ih:grid ih:gap-2 ih:text-sm">
<div class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Aktueller Standort</dt>
<MapPin class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd>{{ item.location || 'Standort nicht angegeben' }}</dd>
</div>
<div v-if="item.lent && (item.lent_since || item.lent_until)" class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Zeitraum</dt>
<CalendarDays class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd>Verliehen {{ period(item.lent_since, item.lent_until) }}</dd>
</div>
<div v-if="item.lent_to" class="ih:flex ih:gap-2">
<dt class="ih:sr-only">Ausgeliehen von</dt>
<UserRound class="ih:mt-0.5 ih:size-4 ih:shrink-0 ih:text-muted-foreground" aria-hidden="true" />
<dd><Link :href="`/personen/${item.lent_to.id}`" class="ih:hover:underline">{{ item.lent_to.name }}</Link></dd>
</div>
</dl>
<div v-if="myRequest" class="ih:grid ih:gap-2 ih:rounded-md ih:bg-brand-soft ih:p-3 ih:text-sm ih:text-brand-text">
<p class="ih:flex ih:items-center ih:gap-1.5 ih:font-medium"><Clock class="ih:size-4" /> Angefragt am {{ formatDate(myRequest.created_at) }}</p>
<p>Nach „{{ myRequest.location }}“ {{ period(myRequest.from, myRequest.until) }} – das Team meldet sich.</p>
<button type="button" class="ih:w-fit ih:text-xs ih:font-medium ih:underline" @click="cancel">Anfrage zurückziehen</button>
</div>
<Button v-else size="lg" class="ih:w-full" @click="requesting = true"><Send /> {{ labels.singular }} anfragen</Button>
<Button v-if="canManage && item.lent" variant="outline" class="ih:w-full" @click="returning = true"><Undo2 /> Zurückgenommen</Button>
</section>
<!-- Team: Anfragen zu diesem Objekt -->
<section v-if="canManage && requests.length" class="ih:rounded-lg ih:border ih:bg-card ih:p-5">
<h2 class="ih:mb-3 ih:text-sm ih:font-semibold">Anfragen</h2>
<ul class="ih:grid ih:gap-3">
<li v-for="request in requests" :key="request.id" class="ih:flex ih:gap-3 ih:text-sm">
<PersonAvatar :person="request.user" class="ih:size-8" />
<div class="ih:min-w-0">
<p><span class="ih:font-medium">{{ request.user?.name }}</span> · {{ request.location }}</p>
<p class="ih:text-xs ih:text-muted-foreground">{{ request.status_label }} · {{ formatDate(request.created_at) }}</p>
</div>
</li>
</ul>
<Link href="/verleih/anfragen" class="ih:mt-3 ih:inline-block ih:text-sm ih:font-medium ih:text-brand-text ih:hover:underline">Alle Anfragen</Link>
</section>
</aside>
</div>
<RequestDialog v-model:open="requesting" :item="item" :labels="labels" :default-location="defaultLocation" />
<Dialog v-model:open="returning">
<DialogContent class="ih:sm:max-w-md">
<DialogHeader>
<DialogTitle>„{{ item.title }}“ zurückgenommen</DialogTitle>
<DialogDescription>Danach ist es wieder verfügbar. Wo ist es jetzt?</DialogDescription>
</DialogHeader>
<form id="verleih-zurueck" @submit.prevent="submitReturn">
<FormField id="vl-return" label="Neuer Standort" :error="giveBack.errors.location">
<Input id="vl-return" v-model="giveBack.location" maxlength="200" placeholder="z. B. Lager Künstlerteam" />
</FormField>
</form>
<DialogFooter>
<Button variant="outline" @click="returning = false">Abbrechen</Button>
<Button type="submit" form="verleih-zurueck" :disabled="giveBack.processing"><LoaderCircle v-if="giveBack.processing" class="ih:animate-spin" /> Speichern</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<!-- Vergrößerung -->
<div v-if="zoom" class="ih:fixed ih:inset-0 ih:z-50 ih:grid ih:place-items-center ih:bg-black/85 ih:p-4" role="dialog" aria-modal="true" :aria-label="item.title" @click="zoom = false">
<img :src="item.image_url" :alt="item.title" class="ih:max-h-full ih:max-w-full ih:object-contain" />
<button type="button" class="ih:absolute ih:top-4 ih:right-4 ih:grid ih:size-10 ih:place-items-center ih:rounded-full ih:bg-white/15 ih:text-white" aria-label="Schließen" @click.stop="zoom = false"><X /></button>
</div>
</AppLayout>
</template>

View file

@ -0,0 +1,19 @@
<!doctype html>
<html lang="de">
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title>{{ $mailSubject }}</title></head>
<body style="margin:0;background:#f4f5f7;font-family:-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;color:#1a1d21">
<div style="max-width:600px;margin:0 auto;padding:24px">
<p style="margin:0 0 16px;font-size:15px;font-weight:700;color:{{ $color }}">{{ $portalName }} · {{ $area }}</p>
<div style="background:#fff;border:1px solid #e3e5e8;border-radius:8px;padding:24px">
<h1 style="margin:0 0 16px;font-size:18px">{{ $heading }}</h1>
@foreach ($lines as $line)
<p style="margin:0 0 8px;font-size:15px;line-height:1.5">{{ $line }}</p>
@endforeach
<p style="margin:20px 0 0"><a href="{{ $action[1] }}" style="display:inline-block;background:{{ $color }};color:#fff;text-decoration:none;font-weight:600;font-size:14px;padding:10px 18px;border-radius:6px">{{ $action[0] }}</a></p>
</div>
@if ($replyPerson)
<p style="margin:12px 0 0;font-size:12px;color:#5f6670">Antworten auf diese E-Mail gehen direkt an {{ $replyPerson->name }}.</p>
@endif
</div>
</body>
</html>