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:
commit
14aaa16b30
47 changed files with 4208 additions and 0 deletions
123
resources/js/pages/Editor.vue
Normal file
123
resources/js/pages/Editor.vue
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue