QM-Texterkennung: Imagick nur mit Ghostscript als verfügbar melden
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 3m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 3m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 3m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 2m56s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m4s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 4m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m39s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m10s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 3m18s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 3m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 3m0s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 2m56s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 4m4s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 4m1s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 3m41s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 3m39s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m10s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5a360d3cc7
commit
b50d089946
117 changed files with 1747 additions and 2 deletions
113
plugins-core/speiseplan/resources/js/components/ManagePanel.vue
Normal file
113
plugins-core/speiseplan/resources/js/components/ManagePanel.vue
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { router, useForm } from '@inertiajs/vue3';
|
||||
import { FileText, LoaderCircle, Trash2, Upload } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import FormField from '@/components/FormField.vue';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import { pdfToImage } from '../pdfToImage';
|
||||
|
||||
const props = defineProps({
|
||||
manage: { type: Object, required: true },
|
||||
allergens: { type: Object, default: null },
|
||||
});
|
||||
|
||||
const form = useForm({ week: props.manage.suggested, image: null });
|
||||
const converting = ref(false);
|
||||
const dragging = ref(false);
|
||||
const fileInput = ref(null);
|
||||
const allergenInput = ref(null);
|
||||
|
||||
async function upload(file) {
|
||||
if (!file) return;
|
||||
|
||||
let image = file;
|
||||
|
||||
if (file.type === 'application/pdf' || /\.pdf$/i.test(file.name)) {
|
||||
converting.value = true;
|
||||
try {
|
||||
image = await pdfToImage(file);
|
||||
} catch {
|
||||
toast.error('Das PDF ließ sich nicht umwandeln. Bitte als Bild hochladen.');
|
||||
|
||||
return;
|
||||
} finally {
|
||||
converting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
form.image = image;
|
||||
form.post('/speiseplan/wochen', {
|
||||
forceFormData: true,
|
||||
preserveScroll: true,
|
||||
onError: (errors) => toast.error(Object.values(errors)[0]),
|
||||
onSuccess: () => {
|
||||
form.image = null;
|
||||
form.week = props.manage.suggested;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function uploadAllergens(file) {
|
||||
if (!file) return;
|
||||
router.post('/speiseplan/allergene', { file }, { forceFormData: true, preserveScroll: true, onError: (e) => toast.error(Object.values(e)[0]) });
|
||||
}
|
||||
|
||||
function remove(plan) {
|
||||
if (window.confirm(`Speiseplan ${plan.label} entfernen?`)) router.delete(`/speiseplan/wochen/${plan.id}`, { preserveScroll: true });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mt-10 rounded-lg border bg-card print:hidden">
|
||||
<h2 class="border-b px-5 py-3 text-base font-semibold">Speiseplan hochladen</h2>
|
||||
<div class="grid gap-6 p-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
|
||||
<div class="grid content-start gap-4">
|
||||
<FormField id="sp-week" label="Woche" :error="form.errors.week">
|
||||
<NativeSelect id="sp-week" v-model="form.week" :options="manage.options" />
|
||||
</FormField>
|
||||
<button
|
||||
type="button"
|
||||
class="grid place-items-center rounded-lg border-2 border-dashed px-6 py-10 text-center transition-colors"
|
||||
:class="dragging ? 'border-brand-400 bg-brand-soft/60' : 'hover:border-brand-300'"
|
||||
:disabled="form.processing || converting"
|
||||
@click="fileInput?.click()"
|
||||
@dragover.prevent="dragging = true"
|
||||
@dragleave.prevent="dragging = false"
|
||||
@drop.prevent="dragging = false; upload($event.dataTransfer.files[0])"
|
||||
>
|
||||
<LoaderCircle v-if="form.processing || converting" class="size-7 animate-spin text-muted-foreground" />
|
||||
<Upload v-else class="size-7 text-muted-foreground" />
|
||||
<span class="mt-2 text-sm font-medium">{{ converting ? 'PDF wird umgewandelt …' : form.processing ? 'Wird hochgeladen …' : 'PDF oder Bild hierher ziehen oder klicken' }}</span>
|
||||
<span class="mt-1 text-xs text-muted-foreground">Ein PDF wird automatisch zum Bild (erste Seite, A4). Ist für die Woche schon ein Plan da, wird er ersetzt.</span>
|
||||
</button>
|
||||
<input ref="fileInput" type="file" accept="application/pdf,image/jpeg,image/png,image/webp" class="hidden" @change="upload($event.target.files[0]); $event.target.value = ''" />
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-md bg-muted/50 px-3 py-2.5 text-sm">
|
||||
<FileText class="size-4 text-muted-foreground" />
|
||||
<span class="min-w-0 flex-1 truncate">{{ allergens ? allergens.name : 'Noch keine Allergie-Informationen hinterlegt' }}</span>
|
||||
<Button size="sm" variant="outline" @click="allergenInput?.click()">{{ allergens ? 'Ersetzen' : 'PDF hochladen' }}</Button>
|
||||
<Button v-if="allergens" size="icon" variant="ghost" class="size-8" aria-label="Allergie-Informationen entfernen" @click="router.delete('/speiseplan/allergene', { preserveScroll: true })"><Trash2 /></Button>
|
||||
<input ref="allergenInput" type="file" accept="application/pdf" class="hidden" @change="uploadAllergens($event.target.files[0]); $event.target.value = ''" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p class="mb-2 text-sm font-medium">Hochgeladene Wochen</p>
|
||||
<ul v-if="manage.uploaded.length" class="grid grid-cols-[repeat(auto-fill,minmax(7rem,1fr))] gap-3">
|
||||
<li v-for="plan in manage.uploaded" :key="plan.id" class="group relative">
|
||||
<a :href="plan.image_url" target="_blank" class="block overflow-hidden rounded-md border bg-white" :class="{ 'opacity-60': plan.past }">
|
||||
<img :src="plan.image_url" :alt="plan.label" class="aspect-[210/297] w-full object-cover object-top" loading="lazy" />
|
||||
</a>
|
||||
<p class="mt-1 text-xs font-medium">KW {{ plan.week }}</p>
|
||||
<p class="text-[11px] text-muted-foreground">{{ plan.past ? 'vergangen' : plan.label.split('· ')[1] }}</p>
|
||||
<button type="button" class="absolute top-1 right-1 grid size-7 place-items-center rounded-md bg-card/90 text-destructive opacity-0 shadow-xs ring-1 ring-border group-hover:opacity-100 focus-visible:opacity-100" :aria-label="`KW ${plan.week} entfernen`" @click="remove(plan)"><Trash2 class="size-3.5" /></button>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="text-sm text-muted-foreground">Noch keine Pläne hochgeladen.</p>
|
||||
<p class="mt-3 text-xs text-muted-foreground">Vergangene Wochen werden nach {{ manage.keepWeeks }} Wochen automatisch gelöscht.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue