Phase 4: Seiten mit Pagebuilder, Redaktion und Freigaben
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m2s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m40s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m56s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 2m2s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 2m9s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 2m40s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 2m35s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 2m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 2m38s
CI / Build-Artefakte aktuell (pull_request) Successful in 55s
- Seiten-Plugin: Seitenbaum mit Adressen, Seitennavigation, Brotkrumen und optional Hauptnavigation; Sichtbarkeit vererbt sich auf Unterseiten - Pagebuilder (Block-Registry im Kern, Plugins tragen Blöcke bei): Abschnitt, Spalten, Tabs, Akkordeon, Box, Überschrift, Text (TipTap), Zitat, Schaltflächen, Symbolliste, Tabelle, Trennlinie, Abstand, Bild, Galerie, Video (erst nach Klick), Titelbild, Ansprechpartner, Downloads, Unterseiten, Neuigkeiten, Termine; Sichtbarkeit je Block; Bereinigung beim Speichern - Editor im Portal: Ziehen und Ablegen, Autospeichern als Entwurf, Rückgängig, Gerätevorschau, Versionen, Zeitsteuerung, Bearbeitungssperre, Freigabe anfordern - Rechte „inkl. Unterseiten“ werden im Rechte-Cache aufgelöst - Neuigkeiten: Schreiben im Portal, Freigabe-Workflow mit Benachrichtigungen - Bereich „Redaktion“, Benachrichtigungen im Portal - storage/.migrations-fingerprint nicht mehr ausliefern Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6269d3302c
commit
f3987e8386
328 changed files with 10618 additions and 389 deletions
26
plugins-core/pages/resources/js/blocks/Downloads.vue
Normal file
26
plugins-core/pages/resources/js/blocks/Downloads.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup>
|
||||
import { Download, FileText } from '@lucide/vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
|
||||
const formatSize = (bytes) => (bytes > 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1).replace('.', ',')} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h3 v-if="block.data.title" class="mb-3 text-lg font-semibold">{{ block.data.title }}</h3>
|
||||
<ul class="divide-y rounded-lg border bg-card">
|
||||
<li v-for="file in block.props?.files ?? []" :key="file.id">
|
||||
<a :href="file.url" class="group flex items-center gap-3 px-4 py-3 hover:bg-accent/50">
|
||||
<span class="grid size-10 shrink-0 place-items-center rounded-md bg-brand-soft text-brand-text"><FileText class="size-5" /></span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-sm font-medium group-hover:underline">{{ file.name }}</span>
|
||||
<span class="block text-xs text-muted-foreground">{{ file.extension || 'Datei' }} · {{ formatSize(file.size) }}</span>
|
||||
</span>
|
||||
<Download class="size-4 shrink-0 text-muted-foreground" />
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="!(block.props?.files ?? []).length" class="px-4 py-3 text-sm text-muted-foreground">Noch keine Dateien.</li>
|
||||
</ul>
|
||||
</section>
|
||||
</template>
|
||||
26
plugins-core/pages/resources/js/blocks/Subpages.vue
Normal file
26
plugins-core/pages/resources/js/blocks/Subpages.vue
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ChevronRight, FileText } from '@lucide/vue';
|
||||
|
||||
defineProps({ block: { type: Object, required: true } });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<h3 v-if="block.data.title" class="mb-3 text-lg font-semibold">{{ block.data.title }}</h3>
|
||||
<div :class="block.data.layout === 'list' ? 'divide-y rounded-lg border bg-card' : 'grid gap-3 @xl:grid-cols-2 @4xl:grid-cols-3'">
|
||||
<Link
|
||||
v-for="page in block.props?.pages ?? []"
|
||||
:key="page.id"
|
||||
:href="page.url"
|
||||
class="group flex items-center gap-3 hover:bg-accent/50"
|
||||
:class="block.data.layout === 'list' ? 'px-4 py-3' : 'rounded-lg border bg-card p-4'"
|
||||
>
|
||||
<FileText class="size-5 shrink-0 text-brand-text" />
|
||||
<span class="min-w-0 flex-1 truncate font-medium group-hover:underline">{{ page.title }}</span>
|
||||
<ChevronRight class="size-4 text-muted-foreground" />
|
||||
</Link>
|
||||
<p v-if="!(block.props?.pages ?? []).length" class="text-sm text-muted-foreground" :class="block.data.layout === 'list' ? 'px-4 py-3' : ''">Keine veröffentlichten Unterseiten.</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
47
plugins-core/pages/resources/js/components/NewPageDialog.vue
Normal file
47
plugins-core/pages/resources/js/components/NewPageDialog.vue
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { useForm } from '@inertiajs/vue3';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
const props = defineProps({
|
||||
parentId: { type: Number, default: null },
|
||||
parentTitle: { type: String, default: '' },
|
||||
});
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['before-create']);
|
||||
const form = useForm({ title: '', parent_id: null });
|
||||
|
||||
watch(open, (value) => value && (form.reset(), form.clearErrors()));
|
||||
|
||||
async function create() {
|
||||
emit('before-create');
|
||||
form.parent_id = props.parentId;
|
||||
form.post('/redaktion/seiten');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ parentId ? 'Unterseite anlegen' : 'Neue Seite' }}</DialogTitle>
|
||||
<DialogDescription v-if="parentId">Unter „{{ parentTitle }}“. Die Seite ist erst nach dem Veröffentlichen sichtbar.</DialogDescription>
|
||||
<DialogDescription v-else>Auf der obersten Ebene. Die Seite ist erst nach dem Veröffentlichen sichtbar.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form class="grid gap-4" @submit.prevent="create">
|
||||
<label class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Titel</span>
|
||||
<Input v-model="form.title" maxlength="200" autofocus :aria-invalid="!!form.errors.title" />
|
||||
<span v-if="form.errors.title" class="text-[13px] text-destructive">{{ form.errors.title }}</span>
|
||||
</label>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" @click="open = false">Abbrechen</Button>
|
||||
<Button type="submit" :disabled="form.processing || !form.title.trim()">Anlegen und bearbeiten</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
const props = defineProps({
|
||||
page: { type: Object, required: true },
|
||||
base: { type: String, required: true },
|
||||
});
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['saved']);
|
||||
|
||||
const form = ref({ slug: '', in_navigation: false });
|
||||
const errors = ref({});
|
||||
const busy = ref(false);
|
||||
|
||||
watch(open, (value) => {
|
||||
if (value) {
|
||||
form.value = { slug: props.page.slug, in_navigation: props.page.in_navigation };
|
||||
errors.value = {};
|
||||
}
|
||||
});
|
||||
|
||||
async function save() {
|
||||
busy.value = true;
|
||||
|
||||
try {
|
||||
emit('saved', await http.put(`${props.base}/einstellungen`, form.value));
|
||||
open.value = false;
|
||||
} catch (error) {
|
||||
errors.value = error.fieldErrors ?? {};
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Seiteneinstellungen</DialogTitle>
|
||||
<DialogDescription>Sichtbarkeit und Rechte pflegen Sie in der Administration unter „Seiten“.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form class="grid gap-4" @submit.prevent="save">
|
||||
<label class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Kürzel in der Adresse</span>
|
||||
<Input v-model="form.slug" maxlength="120" :aria-invalid="!!errors.slug" />
|
||||
<span v-if="errors.slug" class="text-[13px] text-destructive">{{ errors.slug }}</span>
|
||||
<span v-else class="text-xs text-muted-foreground">Ändert auch die Adressen aller Unterseiten. Alte Links funktionieren dann nicht mehr.</span>
|
||||
</label>
|
||||
<label v-if="page.can.navigation" class="flex items-center justify-between gap-3 text-[13px] font-medium">
|
||||
In der Hauptnavigation anzeigen
|
||||
<Switch v-model="form.in_navigation" />
|
||||
</label>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" @click="open = false">Abbrechen</Button>
|
||||
<Button type="submit" :disabled="busy">Speichern</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
27
plugins-core/pages/resources/js/components/PageTreeNav.vue
Normal file
27
plugins-core/pages/resources/js/components/PageTreeNav.vue
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
|
||||
defineProps({
|
||||
items: { type: Array, required: true },
|
||||
current: { type: String, required: true },
|
||||
depth: { type: Number, default: 0 },
|
||||
});
|
||||
|
||||
const contains = (item, url) => item.url === url || item.children.some((child) => contains(child, url));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="grid gap-0.5" :class="depth ? 'mt-0.5 ml-3 border-l pl-2' : 'mt-1'">
|
||||
<li v-for="item in items" :key="item.id">
|
||||
<Link
|
||||
:href="item.url"
|
||||
class="block rounded-md px-3 py-1.5 text-sm"
|
||||
:class="item.url === current ? 'bg-brand-soft font-medium text-brand-soft-foreground' : 'text-foreground/80 hover:bg-accent hover:text-foreground'"
|
||||
:aria-current="item.url === current ? 'page' : undefined"
|
||||
>
|
||||
{{ item.title }}
|
||||
</Link>
|
||||
<PageTreeNav v-if="item.children.length && contains(item, current)" :items="item.children" :current="current" :depth="depth + 1" />
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
78
plugins-core/pages/resources/js/components/PublishDialog.vue
Normal file
78
plugins-core/pages/resources/js/components/PublishDialog.vue
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { CalendarClock, Send } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Input } from '@/components/ui/input';
|
||||
|
||||
const props = defineProps({
|
||||
scheduledAt: { type: String, default: null },
|
||||
});
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['publish']);
|
||||
|
||||
const mode = ref('now');
|
||||
const when = ref('');
|
||||
const busy = ref(false);
|
||||
|
||||
function localValue(date) {
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
}
|
||||
|
||||
watch(open, (value) => {
|
||||
if (value) {
|
||||
mode.value = 'now';
|
||||
const next = new Date(Date.now() + 24 * 3600 * 1000);
|
||||
next.setHours(7, 0, 0, 0);
|
||||
when.value = localValue(next);
|
||||
busy.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
async function submit() {
|
||||
busy.value = true;
|
||||
emit('publish', mode.value === 'later' ? new Date(when.value).toISOString() : null);
|
||||
setTimeout(() => (busy.value = false), 800);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Seite veröffentlichen</DialogTitle>
|
||||
<DialogDescription>Der aktuelle Stand wird für alle sichtbar, die die Seite sehen dürfen. Frühere Stände bleiben unter „Versionen“ erhalten.</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<p v-if="props.scheduledAt" class="rounded-md bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:bg-amber-950/50 dark:text-amber-100">
|
||||
Es ist bereits eine Veröffentlichung geplant. Sie wird durch diese ersetzt.
|
||||
</p>
|
||||
|
||||
<fieldset class="grid gap-2">
|
||||
<legend class="sr-only">Zeitpunkt</legend>
|
||||
<label class="flex cursor-pointer items-start gap-3 rounded-md border p-3 has-checked:border-brand-400 has-checked:bg-brand-soft/60">
|
||||
<input v-model="mode" type="radio" value="now" class="mt-1 accent-[var(--brand)]" />
|
||||
<span><span class="block text-sm font-medium">Jetzt veröffentlichen</span><span class="block text-xs text-muted-foreground">Sofort sichtbar.</span></span>
|
||||
</label>
|
||||
<label class="flex cursor-pointer items-start gap-3 rounded-md border p-3 has-checked:border-brand-400 has-checked:bg-brand-soft/60">
|
||||
<input v-model="mode" type="radio" value="later" class="mt-1 accent-[var(--brand)]" />
|
||||
<span class="grid flex-1 gap-2">
|
||||
<span><span class="block text-sm font-medium">Zeitgesteuert</span><span class="block text-xs text-muted-foreground">Der aktuelle Stand geht zum gewählten Zeitpunkt online.</span></span>
|
||||
<Input v-if="mode === 'later'" v-model="when" type="datetime-local" :min="localValue(new Date())" aria-label="Zeitpunkt der Veröffentlichung" />
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="open = false">Abbrechen</Button>
|
||||
<Button :disabled="busy || (mode === 'later' && !when)" @click="submit">
|
||||
<CalendarClock v-if="mode === 'later'" /><Send v-else />
|
||||
{{ mode === 'later' ? 'Planen' : 'Veröffentlichen' }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
39
plugins-core/pages/resources/js/components/ReviewDialog.vue
Normal file
39
plugins-core/pages/resources/js/components/ReviewDialog.vue
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { Send } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['submit']);
|
||||
const message = ref('');
|
||||
const busy = ref(false);
|
||||
|
||||
watch(open, (value) => value && ((message.value = ''), (busy.value = false)));
|
||||
|
||||
function submit() {
|
||||
busy.value = true;
|
||||
emit('submit', message.value);
|
||||
setTimeout(() => (busy.value = false), 1500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Freigabe anfordern</DialogTitle>
|
||||
<DialogDescription>Ihre Änderungen sind als Entwurf gespeichert. Die Personen, die diese Seite veröffentlichen dürfen, werden benachrichtigt.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<label class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Nachricht (freiwillig)</span>
|
||||
<Textarea v-model="message" rows="3" maxlength="1000" placeholder="z. B. Bitte bis Freitag veröffentlichen." />
|
||||
</label>
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="open = false">Abbrechen</Button>
|
||||
<Button :disabled="busy" @click="submit"><Send /> Anfordern</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { History, LoaderCircle } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import PageContent from '@/pagebuilder/PageContent.vue';
|
||||
import { http } from '@/lib/http';
|
||||
import { formatRelative } from '@/lib/format';
|
||||
|
||||
const props = defineProps({
|
||||
base: { type: String, required: true },
|
||||
readOnly: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['restored']);
|
||||
|
||||
const revisions = ref(null);
|
||||
const active = ref(null);
|
||||
const preview = ref(null);
|
||||
const loading = ref(false);
|
||||
|
||||
watch(open, async (value) => {
|
||||
if (!value) return;
|
||||
|
||||
revisions.value = null;
|
||||
preview.value = null;
|
||||
active.value = null;
|
||||
revisions.value = (await http.get(`${props.base}/versionen`)).revisions;
|
||||
|
||||
if (revisions.value.length) show(revisions.value[0]);
|
||||
});
|
||||
|
||||
async function show(revision) {
|
||||
active.value = revision;
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
preview.value = await http.get(`${props.base}/versionen/${revision.id}`);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function restore() {
|
||||
try {
|
||||
emit('restored', await http.post(`${props.base}/versionen/${active.value.id}/wiederherstellen`));
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="flex h-[85vh] max-w-5xl flex-col gap-0 p-0 sm:max-w-5xl">
|
||||
<DialogHeader class="border-b px-5 py-4">
|
||||
<DialogTitle>Versionen</DialogTitle>
|
||||
<DialogDescription>Jede Veröffentlichung wird gespeichert. Eine ältere Version lässt sich als Entwurf zurückholen.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<ul class="w-64 shrink-0 overflow-y-auto border-r p-2">
|
||||
<li v-if="revisions === null" class="grid place-items-center py-10"><LoaderCircle class="size-5 animate-spin text-muted-foreground" /></li>
|
||||
<li v-else-if="!revisions.length" class="px-3 py-6 text-center text-sm text-muted-foreground">Noch keine veröffentlichten Versionen.</li>
|
||||
<li v-for="revision in revisions ?? []" :key="revision.id">
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded-md px-3 py-2 text-left"
|
||||
:class="active?.id === revision.id ? 'bg-brand-soft text-brand-soft-foreground' : 'hover:bg-accent'"
|
||||
@click="show(revision)"
|
||||
>
|
||||
<span class="block text-sm font-medium">{{ formatRelative(revision.created_at) }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ revision.action }}<template v-if="revision.user"> · {{ revision.user }}</template></span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="flex min-w-0 flex-1 flex-col">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto bg-background p-6">
|
||||
<div v-if="loading" class="grid place-items-center py-16"><LoaderCircle class="size-6 animate-spin text-muted-foreground" /></div>
|
||||
<template v-else-if="preview">
|
||||
<h1 class="mb-6 text-2xl font-semibold tracking-tight">{{ preview.title }}</h1>
|
||||
<PageContent :content="preview.content" />
|
||||
</template>
|
||||
</div>
|
||||
<div v-if="active" class="flex items-center justify-between gap-3 border-t px-5 py-3">
|
||||
<span class="text-xs text-muted-foreground">{{ new Date(active.created_at).toLocaleString('de-DE', { dateStyle: 'medium', timeStyle: 'short' }) }}</span>
|
||||
<Button :disabled="readOnly" @click="restore"><History /> Als Entwurf wiederherstellen</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
45
plugins-core/pages/resources/js/editorial/EditorialPages.vue
Normal file
45
plugins-core/pages/resources/js/editorial/EditorialPages.vue
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Lock, Plus } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import { formatRelative } from '@/lib/format';
|
||||
import NewPageDialog from '../components/NewPageDialog.vue';
|
||||
|
||||
defineProps({
|
||||
pages: { type: Array, required: true },
|
||||
canCreate: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const creating = ref(false);
|
||||
|
||||
const statuses = {
|
||||
published: { label: 'Veröffentlicht', class: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200' },
|
||||
draft: { label: 'Entwurf', class: 'bg-brand-soft text-brand-soft-foreground' },
|
||||
scheduled: { label: 'Geplant', class: 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200' },
|
||||
new: { label: 'Neu', class: 'bg-muted text-muted-foreground' },
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Seiten">
|
||||
<template #actions>
|
||||
<Button v-if="canCreate" size="sm" variant="outline" @click="creating = true"><Plus /> Neue Seite</Button>
|
||||
</template>
|
||||
<ul v-if="pages.length" class="-mx-5 divide-y border-t">
|
||||
<li v-for="page in pages" :key="page.id" class="flex items-center gap-3 py-2.5 pr-5" :style="{ paddingLeft: `${1.25 + Math.min(page.depth, 4) * 1.25}rem` }">
|
||||
<div class="min-w-0 flex-1" :class="page.depth ? 'border-l pl-3' : ''">
|
||||
<Link :href="page.edit_url" class="block truncate text-sm font-medium hover:underline">{{ page.title }}</Link>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ page.url }}<template v-if="page.changed_at"> · {{ formatRelative(page.changed_at) }}</template>
|
||||
</p>
|
||||
</div>
|
||||
<span v-if="page.locked_by" class="inline-flex items-center gap-1 text-xs text-muted-foreground" :title="`${page.locked_by} bearbeitet gerade`"><Lock class="size-3.5" /> {{ page.locked_by }}</span>
|
||||
<span class="shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium" :class="statuses[page.status].class">{{ statuses[page.status].label }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-else class="text-sm text-muted-foreground">Sie dürfen noch keine Seiten bearbeiten.</p>
|
||||
<NewPageDialog v-model:open="creating" />
|
||||
</Panel>
|
||||
</template>
|
||||
636
plugins-core/pages/resources/js/pages/Editor.vue
Normal file
636
plugins-core/pages/resources/js/pages/Editor.vue
Normal file
|
|
@ -0,0 +1,636 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, provide, reactive, ref, watch } from 'vue';
|
||||
import { Head, Link, router } from '@inertiajs/vue3';
|
||||
import {
|
||||
ArrowLeft,
|
||||
CalendarClock,
|
||||
CircleCheck,
|
||||
CloudAlert,
|
||||
EllipsisVertical,
|
||||
Eye,
|
||||
FilePlus2,
|
||||
History,
|
||||
LoaderCircle,
|
||||
Lock,
|
||||
Monitor,
|
||||
Redo2,
|
||||
Send,
|
||||
Settings2,
|
||||
Smartphone,
|
||||
Tablet,
|
||||
Trash2,
|
||||
Undo2,
|
||||
} from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Toaster } from '@/components/ui/sonner';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet';
|
||||
import BlockPalette from '@/pagebuilder/editor/BlockPalette.vue';
|
||||
import BlockSettings from '@/pagebuilder/editor/BlockSettings.vue';
|
||||
import EditorBlockList from '@/pagebuilder/editor/EditorBlockList.vue';
|
||||
import { clone, createBlock, duplicate as duplicateBlock, locate, walk } from '@/pagebuilder/editor/tree';
|
||||
import { http } from '@/lib/http';
|
||||
import { formatTime } from '@/lib/format';
|
||||
import PublishDialog from '../components/PublishDialog.vue';
|
||||
import RevisionsDialog from '../components/RevisionsDialog.vue';
|
||||
import PageSettingsDialog from '../components/PageSettingsDialog.vue';
|
||||
import ReviewDialog from '../components/ReviewDialog.vue';
|
||||
import NewPageDialog from '../components/NewPageDialog.vue';
|
||||
|
||||
const props = defineProps({
|
||||
page: { type: Object, required: true },
|
||||
working: { type: Object, required: true },
|
||||
lockedBy: { type: Object, default: null },
|
||||
blockTypes: { type: Array, required: true },
|
||||
blockGroups: { type: Object, required: true },
|
||||
files: { type: Array, default: () => [] },
|
||||
audienceOptions: { type: Object, required: true },
|
||||
breadcrumbs: { type: Array, default: () => [] },
|
||||
uploadsUrl: { type: String, required: true },
|
||||
});
|
||||
|
||||
const base = `/redaktion/seiten/${props.page.id}`;
|
||||
const types = Object.fromEntries(props.blockTypes.map((type) => [type.key, type]));
|
||||
|
||||
const page = ref(props.page);
|
||||
const working = reactive(clone(props.working));
|
||||
const selectedId = ref(null);
|
||||
const hoveredId = ref(null);
|
||||
const previews = reactive({});
|
||||
const files = ref(props.files);
|
||||
const readOnly = ref(!!props.lockedBy);
|
||||
const lockedBy = ref(props.lockedBy);
|
||||
const device = ref('desktop');
|
||||
const sheetOpen = ref(false);
|
||||
const sidebarTab = ref('blocks');
|
||||
|
||||
const selected = computed(() => (selectedId.value ? locate(working.content.blocks, selectedId.value)?.block ?? null : null));
|
||||
|
||||
watch(selectedId, (id) => {
|
||||
sidebarTab.value = id ? 'block' : 'blocks';
|
||||
});
|
||||
|
||||
// ——— Aktionen am Blockbaum ———
|
||||
function select(id) {
|
||||
selectedId.value = id ?? null;
|
||||
}
|
||||
|
||||
function insert(list, index, type) {
|
||||
if (readOnly.value) return;
|
||||
|
||||
const block = createBlock(type);
|
||||
list.splice(index, 0, block);
|
||||
select(block.id);
|
||||
}
|
||||
|
||||
function insertFromPalette(type) {
|
||||
const found = selected.value ? locate(working.content.blocks, selected.value.id) : null;
|
||||
found ? insert(found.list, found.index + 1, type) : insert(working.content.blocks, working.content.blocks.length, type);
|
||||
sheetOpen.value = false;
|
||||
requestAnimationFrame(() => document.querySelector(`[data-block-id="${selectedId.value}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' }));
|
||||
}
|
||||
|
||||
function remove(id) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
|
||||
if (!found) return;
|
||||
|
||||
found.list.splice(found.index, 1);
|
||||
|
||||
if (selectedId.value === id) select(null);
|
||||
}
|
||||
|
||||
function move(id, direction) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
const target = found ? found.index + direction : -1;
|
||||
|
||||
if (found && target >= 0 && target < found.list.length) {
|
||||
found.list.splice(target, 0, found.list.splice(found.index, 1)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
function duplicate(id) {
|
||||
const found = locate(working.content.blocks, id);
|
||||
|
||||
if (!found) return;
|
||||
|
||||
const copy = duplicateBlock(found.block);
|
||||
found.list.splice(found.index + 1, 0, copy);
|
||||
Object.assign(previews, { [copy.id]: previews[id] });
|
||||
select(copy.id);
|
||||
}
|
||||
|
||||
function containsActive(item) {
|
||||
const candidates = [selected.value, hoveredId.value ? locate(working.content.blocks, hoveredId.value)?.block : null].filter(Boolean);
|
||||
|
||||
return candidates.some((block) => block.items?.includes(item) || locate(item.blocks, block.id));
|
||||
}
|
||||
|
||||
// ——— Hochladen ———
|
||||
async function uploadImage(file) {
|
||||
const body = new FormData();
|
||||
body.append('image', file);
|
||||
|
||||
return http.post(`${base}/bilder`, body);
|
||||
}
|
||||
|
||||
async function uploadFile(file) {
|
||||
const body = new FormData();
|
||||
body.append('file', file);
|
||||
const result = await http.post(`${base}/dateien`, body);
|
||||
files.value = [result.file, ...files.value];
|
||||
|
||||
return result.file;
|
||||
}
|
||||
|
||||
const peopleCache = reactive({});
|
||||
|
||||
provide('pagebuilder:editor', {
|
||||
types,
|
||||
groups: props.blockGroups,
|
||||
selectedId,
|
||||
hoveredId,
|
||||
previews,
|
||||
readOnly,
|
||||
files,
|
||||
peopleCache,
|
||||
audienceOptions: props.audienceOptions,
|
||||
select,
|
||||
insert,
|
||||
remove,
|
||||
move,
|
||||
duplicate,
|
||||
containsActive,
|
||||
uploadImage,
|
||||
uploadFile,
|
||||
imageUrl: (path) => `${props.uploadsUrl}/${path}`,
|
||||
});
|
||||
provide('pagebuilder:list', EditorBlockList);
|
||||
provide('pagebuilder:types', types);
|
||||
provide('pagebuilder:editing', computed(() => !readOnly.value));
|
||||
|
||||
// ——— Vorschau dynamischer Blöcke (Bild-URLs, Personen, aktuelle Beiträge) ———
|
||||
const previewHashes = {};
|
||||
let previewTimer;
|
||||
|
||||
function refreshPreviews() {
|
||||
const changed = [];
|
||||
|
||||
walk(working.content.blocks, (block) => {
|
||||
if (!types[block.type]?.dynamic) return;
|
||||
|
||||
const hash = JSON.stringify(block.data);
|
||||
|
||||
if (previewHashes[block.id] !== hash) {
|
||||
previewHashes[block.id] = hash;
|
||||
changed.push({ id: block.id, type: block.type, data: block.data });
|
||||
}
|
||||
});
|
||||
|
||||
if (changed.length) {
|
||||
http.post(`${base}/vorschau`, { blocks: changed.slice(0, 100) })
|
||||
.then((data) => Object.assign(previews, data.props))
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
// ——— Speichern: laufend als Entwurf ———
|
||||
const saveState = ref('saved');
|
||||
const savedAt = ref(page.value.draft_updated_at);
|
||||
let saveTimer;
|
||||
let lastSaved = JSON.stringify(working);
|
||||
|
||||
function serialize() {
|
||||
return { title: working.title, content: working.content };
|
||||
}
|
||||
|
||||
async function save() {
|
||||
clearTimeout(saveTimer);
|
||||
|
||||
if (readOnly.value) return;
|
||||
|
||||
const snapshot = JSON.stringify(working);
|
||||
|
||||
if (snapshot === lastSaved) {
|
||||
saveState.value = 'saved';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
saveState.value = 'saving';
|
||||
|
||||
try {
|
||||
const data = await http.put(`${base}/entwurf`, serialize());
|
||||
lastSaved = snapshot;
|
||||
page.value = data.page;
|
||||
savedAt.value = new Date().toISOString();
|
||||
saveState.value = JSON.stringify(working) === lastSaved ? 'saved' : 'dirty';
|
||||
|
||||
if (saveState.value === 'dirty') scheduleSave();
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
saveState.value = 'error';
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleSave(delay = 1200) {
|
||||
clearTimeout(saveTimer);
|
||||
saveTimer = setTimeout(save, delay);
|
||||
}
|
||||
|
||||
function handleError(error) {
|
||||
if (error.status === 423) {
|
||||
readOnly.value = true;
|
||||
lockedBy.value = error.data.lockedBy;
|
||||
toast.error(error.message);
|
||||
} else if (error.status === 422 && error.data?.errors?.title) {
|
||||
toast.error(error.data.errors.title[0]);
|
||||
} else {
|
||||
toast.error(error.message || 'Speichern fehlgeschlagen. Bitte die Verbindung prüfen.');
|
||||
}
|
||||
}
|
||||
|
||||
// ——— Rückgängig / Wiederholen ———
|
||||
const undoStack = ref([]);
|
||||
const redoStack = ref([]);
|
||||
let historyBase = JSON.stringify(working);
|
||||
let applyingHistory = false;
|
||||
let historyTimer;
|
||||
|
||||
function recordHistory() {
|
||||
const current = JSON.stringify(working);
|
||||
|
||||
if (current !== historyBase) {
|
||||
undoStack.value = [...undoStack.value.slice(-49), historyBase];
|
||||
redoStack.value = [];
|
||||
historyBase = current;
|
||||
}
|
||||
}
|
||||
|
||||
function applySnapshot(snapshot) {
|
||||
applyingHistory = true;
|
||||
const state = JSON.parse(snapshot);
|
||||
working.title = state.title;
|
||||
working.content = state.content;
|
||||
historyBase = snapshot;
|
||||
|
||||
if (selectedId.value && !locate(working.content.blocks, selectedId.value)) select(null);
|
||||
|
||||
setTimeout(() => (applyingHistory = false));
|
||||
}
|
||||
|
||||
function undo() {
|
||||
recordHistory();
|
||||
|
||||
if (!undoStack.value.length) return;
|
||||
|
||||
redoStack.value = [...redoStack.value, JSON.stringify(working)];
|
||||
applySnapshot(undoStack.value.at(-1));
|
||||
undoStack.value = undoStack.value.slice(0, -1);
|
||||
}
|
||||
|
||||
function redo() {
|
||||
if (!redoStack.value.length) return;
|
||||
|
||||
undoStack.value = [...undoStack.value, JSON.stringify(working)];
|
||||
applySnapshot(redoStack.value.at(-1));
|
||||
redoStack.value = redoStack.value.slice(0, -1);
|
||||
}
|
||||
|
||||
watch(working, () => {
|
||||
if (readOnly.value) return;
|
||||
|
||||
saveState.value = 'dirty';
|
||||
scheduleSave();
|
||||
clearTimeout(previewTimer);
|
||||
previewTimer = setTimeout(refreshPreviews, 500);
|
||||
|
||||
if (!applyingHistory) {
|
||||
clearTimeout(historyTimer);
|
||||
historyTimer = setTimeout(recordHistory, 700);
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
function onKeydown(event) {
|
||||
const target = event.target;
|
||||
const typing = target.closest?.('input, textarea, select, [contenteditable="true"]');
|
||||
|
||||
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 's') {
|
||||
event.preventDefault();
|
||||
save();
|
||||
} else if (!typing && (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'z') {
|
||||
event.preventDefault();
|
||||
event.shiftKey ? redo() : undo();
|
||||
} else if (!typing && (event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'y') {
|
||||
event.preventDefault();
|
||||
redo();
|
||||
} else if (event.key === 'Escape' && !typing) {
|
||||
select(null);
|
||||
}
|
||||
}
|
||||
|
||||
// ——— Bearbeitungssperre ———
|
||||
let lockTimer;
|
||||
|
||||
async function heartbeat(takeover = false) {
|
||||
try {
|
||||
await http.post(`${base}/sperre`, { takeover });
|
||||
|
||||
if (takeover) {
|
||||
readOnly.value = false;
|
||||
lockedBy.value = null;
|
||||
toast.success('Sie bearbeiten die Seite jetzt.');
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status === 423) {
|
||||
readOnly.value = true;
|
||||
lockedBy.value = error.data.lockedBy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function takeOver() {
|
||||
await heartbeat(true);
|
||||
router.reload({ only: ['working', 'page'], onSuccess: () => Object.assign(working, clone(props.working)) });
|
||||
}
|
||||
|
||||
function leave() {
|
||||
if (readOnly.value) return;
|
||||
|
||||
if (JSON.stringify(working) !== lastSaved) {
|
||||
fetch(`${base}/entwurf`, {
|
||||
method: 'PUT',
|
||||
keepalive: true,
|
||||
credentials: 'same-origin',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'X-XSRF-TOKEN': decodeURIComponent(document.cookie.match(/XSRF-TOKEN=([^;]*)/)?.[1] ?? '') },
|
||||
body: JSON.stringify(serialize()),
|
||||
});
|
||||
}
|
||||
|
||||
http.post(`${base}/sperre/freigeben`, {}, { keepalive: true }).catch(() => {});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
refreshPreviews();
|
||||
window.addEventListener('keydown', onKeydown);
|
||||
window.addEventListener('pagehide', leave);
|
||||
lockTimer = setInterval(() => !readOnly.value && heartbeat(), 45_000);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', onKeydown);
|
||||
window.removeEventListener('pagehide', leave);
|
||||
clearInterval(lockTimer);
|
||||
clearTimeout(saveTimer);
|
||||
leave();
|
||||
});
|
||||
|
||||
// ——— Veröffentlichen & Co. ———
|
||||
const dialogs = reactive({ publish: false, review: false, revisions: false, settings: false, newPage: false });
|
||||
|
||||
async function publish(scheduledAt) {
|
||||
clearTimeout(saveTimer);
|
||||
|
||||
try {
|
||||
const data = await http.post(`${base}/veroeffentlichen`, { ...serialize(), scheduled_at: scheduledAt || null });
|
||||
page.value = data.page;
|
||||
lastSaved = JSON.stringify(working);
|
||||
saveState.value = 'saved';
|
||||
dialogs.publish = false;
|
||||
toast.success(scheduledAt ? `Veröffentlichung geplant für ${new Date(scheduledAt).toLocaleString('de-DE', { dateStyle: 'medium', timeStyle: 'short' })}` : 'Seite veröffentlicht', {
|
||||
action: scheduledAt ? undefined : { label: 'Ansehen', onClick: () => router.visit(page.value.url) },
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function requestReview(message) {
|
||||
await save();
|
||||
|
||||
try {
|
||||
const data = await http.post(`${base}/freigabe`, { message });
|
||||
dialogs.review = false;
|
||||
toast.success(`Freigabe angefordert – ${data.recipients} ${data.recipients === 1 ? 'Person wurde' : 'Personen wurden'} benachrichtigt.`);
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function simpleAction(method, url, confirmText, success) {
|
||||
if (confirmText && !window.confirm(confirmText)) return;
|
||||
|
||||
try {
|
||||
const data = await http[method](url);
|
||||
|
||||
if (data.page) page.value = data.page;
|
||||
|
||||
if (data.working) {
|
||||
applySnapshot(JSON.stringify(data.working));
|
||||
lastSaved = JSON.stringify(working);
|
||||
}
|
||||
|
||||
if (data.redirect) {
|
||||
router.visit(data.redirect);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
toast.success(success);
|
||||
} catch (error) {
|
||||
toast.error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function restored(data) {
|
||||
page.value = data.page;
|
||||
applySnapshot(JSON.stringify(data.working));
|
||||
lastSaved = JSON.stringify(working);
|
||||
Object.keys(previewHashes).forEach((key) => delete previewHashes[key]);
|
||||
refreshPreviews();
|
||||
dialogs.revisions = false;
|
||||
toast.success('Version als Entwurf wiederhergestellt');
|
||||
}
|
||||
|
||||
const status = computed(() => {
|
||||
if (page.value.scheduled_at) return { label: `Geplant: ${new Date(page.value.scheduled_at).toLocaleString('de-DE', { dateStyle: 'short', timeStyle: 'short' })}`, class: 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200' };
|
||||
if (!page.value.is_published) return { label: 'Nicht veröffentlicht', class: 'bg-muted text-muted-foreground' };
|
||||
if (page.value.has_draft) return { label: 'Entwurf mit Änderungen', class: 'bg-brand-soft text-brand-soft-foreground' };
|
||||
|
||||
return { label: 'Veröffentlicht', class: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200' };
|
||||
});
|
||||
|
||||
const devices = [
|
||||
{ key: 'desktop', label: 'Desktop', icon: Monitor, width: 'max-w-[1100px]' },
|
||||
{ key: 'tablet', label: 'Tablet', icon: Tablet, width: 'max-w-[768px]' },
|
||||
{ key: 'mobile', label: 'Smartphone', icon: Smartphone, width: 'max-w-[390px]' },
|
||||
];
|
||||
const canvasWidth = computed(() => devices.find((d) => d.key === device.value).width);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="`Bearbeiten: ${working.title}`" />
|
||||
|
||||
<div class="flex h-dvh flex-col bg-background">
|
||||
<!-- Kopfleiste -->
|
||||
<header class="z-30 flex h-14 shrink-0 items-center gap-2 border-b bg-card px-2 sm:px-3">
|
||||
<Link :href="page.is_published ? page.url : '/redaktion'" class="grid size-9 shrink-0 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground" title="Zurück">
|
||||
<ArrowLeft class="size-5" />
|
||||
</Link>
|
||||
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="truncate text-sm font-semibold">{{ working.title || 'Ohne Titel' }}</span>
|
||||
<span class="hidden shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium sm:inline" :class="status.class">{{ status.label }}</span>
|
||||
</div>
|
||||
<p class="flex items-center gap-1 truncate text-xs text-muted-foreground" aria-live="polite">
|
||||
<template v-if="readOnly"><Lock class="size-3" /> Nur lesen</template>
|
||||
<template v-else-if="saveState === 'saving'"><LoaderCircle class="size-3 animate-spin" /> Speichert …</template>
|
||||
<template v-else-if="saveState === 'error'"><CloudAlert class="size-3 text-destructive" /> Nicht gespeichert</template>
|
||||
<template v-else-if="saveState === 'dirty'">Ungespeicherte Änderungen</template>
|
||||
<template v-else-if="savedAt"><CircleCheck class="size-3" /> Entwurf gespeichert {{ formatTime(savedAt) }}</template>
|
||||
<template v-else>{{ page.url }}</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="hidden items-center gap-0.5 md:flex">
|
||||
<button type="button" class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40" title="Rückgängig (Strg+Z)" :disabled="!undoStack.length || readOnly" @click="undo"><Undo2 class="size-4" /></button>
|
||||
<button type="button" class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40" title="Wiederholen (Strg+Y)" :disabled="!redoStack.length || readOnly" @click="redo"><Redo2 class="size-4" /></button>
|
||||
<span class="mx-1 h-6 w-px bg-border" />
|
||||
<div class="flex rounded-md border p-0.5" role="group" aria-label="Vorschau">
|
||||
<button
|
||||
v-for="d in devices"
|
||||
:key="d.key"
|
||||
type="button"
|
||||
class="grid size-8 place-items-center rounded"
|
||||
:class="device === d.key ? 'bg-brand-soft text-brand-soft-foreground' : 'text-muted-foreground hover:bg-accent'"
|
||||
:title="d.label"
|
||||
:aria-pressed="device === d.key"
|
||||
@click="device = d.key"
|
||||
>
|
||||
<component :is="d.icon" class="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger class="grid size-9 place-items-center rounded-md text-muted-foreground hover:bg-accent" aria-label="Weitere Aktionen">
|
||||
<EllipsisVertical class="size-5" />
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end" class="w-64">
|
||||
<DropdownMenuItem v-if="page.is_published" as-child><a :href="page.url" target="_blank"><Eye /> Veröffentlichte Seite ansehen</a></DropdownMenuItem>
|
||||
<DropdownMenuItem @select="dialogs.revisions = true"><History /> Versionen</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="page.can.configure" @select="dialogs.settings = true"><Settings2 /> Seiteneinstellungen</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="page.can.create_child" @select="dialogs.newPage = true"><FilePlus2 /> Unterseite anlegen</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
v-if="page.has_draft && page.is_published && !readOnly"
|
||||
@select="simpleAction('delete', `${base}/entwurf`, 'Alle Änderungen seit der letzten Veröffentlichung verwerfen?', 'Entwurf verworfen')"
|
||||
>
|
||||
<Undo2 /> Entwurf verwerfen
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="page.scheduled_at && page.can.publish" @select="simpleAction('delete', `${base}/planung`, null, 'Planung aufgehoben – der Stand ist wieder ein Entwurf')">
|
||||
<CalendarClock /> Geplante Veröffentlichung aufheben
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="page.is_published && page.can.publish" @select="simpleAction('post', `${base}/zurueckziehen`, 'Seite offline nehmen? Der Inhalt bleibt als Entwurf erhalten.', 'Seite ist offline')">
|
||||
<Lock /> Veröffentlichung zurückziehen
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem v-if="page.can.delete" class="text-destructive" @select="simpleAction('delete', base, 'Seite endgültig löschen? Versionen und Dateien werden entfernt.', 'Seite gelöscht')">
|
||||
<Trash2 /> Seite löschen
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
<Button v-if="page.can.publish" :disabled="readOnly" @click="dialogs.publish = true">
|
||||
<Send /> <span class="hidden sm:inline">Veröffentlichen</span>
|
||||
</Button>
|
||||
<Button v-else :disabled="readOnly" @click="dialogs.review = true">
|
||||
<Send /> <span class="hidden sm:inline">Freigabe anfordern</span>
|
||||
</Button>
|
||||
</header>
|
||||
|
||||
<div v-if="readOnly" class="flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-amber-200 bg-amber-50 px-4 py-2.5 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950/50 dark:text-amber-100">
|
||||
<Lock class="size-4 shrink-0" />
|
||||
<span class="flex-1">{{ lockedBy?.name ?? 'Jemand anderes' }} bearbeitet diese Seite gerade. Sie sehen den zuletzt gespeicherten Stand.</span>
|
||||
<Button size="sm" variant="outline" class="bg-card" @click="takeOver">Bearbeitung übernehmen</Button>
|
||||
</div>
|
||||
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<!-- Arbeitsfläche -->
|
||||
<main class="min-w-0 flex-1 overflow-y-auto" @click="select(null)">
|
||||
<div class="mx-auto px-4 py-8 transition-[max-width] duration-300 sm:px-8" :class="canvasWidth">
|
||||
<nav v-if="breadcrumbs.length" class="mb-2 flex flex-wrap gap-1 text-xs text-muted-foreground" aria-label="Brotkrumen">
|
||||
<span v-for="crumb in breadcrumbs" :key="crumb.url">{{ crumb.title }} /</span>
|
||||
</nav>
|
||||
<input
|
||||
v-model="working.title"
|
||||
class="mb-6 w-full bg-transparent text-3xl font-semibold tracking-tight outline-none placeholder:text-muted-foreground/60"
|
||||
placeholder="Titel der Seite"
|
||||
maxlength="200"
|
||||
aria-label="Titel der Seite"
|
||||
:readonly="readOnly"
|
||||
@click.stop
|
||||
/>
|
||||
<div class="@container">
|
||||
<EditorBlockList :item="working.content" root />
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Seitenleiste -->
|
||||
<aside class="hidden w-[340px] shrink-0 flex-col border-l bg-card lg:flex">
|
||||
<div class="flex shrink-0 border-b px-2" role="tablist">
|
||||
<button
|
||||
v-for="tab in [{ key: 'blocks', label: 'Blöcke' }, { key: 'block', label: 'Ausgewählter Block' }]"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="relative px-3 py-3 text-sm font-medium disabled:opacity-40"
|
||||
:class="sidebarTab === tab.key ? 'text-foreground' : 'text-muted-foreground hover:text-foreground'"
|
||||
:aria-selected="sidebarTab === tab.key"
|
||||
:disabled="tab.key === 'block' && !selected"
|
||||
@click="sidebarTab = tab.key"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span v-if="sidebarTab === tab.key" class="absolute inset-x-2 bottom-0 h-[3px] rounded-t-full bg-brand" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-4">
|
||||
<BlockSettings v-if="sidebarTab === 'block' && selected" :key="selected.id" :block="selected" />
|
||||
<template v-else>
|
||||
<p class="mb-4 text-xs text-muted-foreground">Klicken fügt den Block unter dem ausgewählten ein. Blöcke lassen sich auch an jede Stelle ziehen.</p>
|
||||
<BlockPalette @pick="insertFromPalette" />
|
||||
</template>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<!-- Kleine Bildschirme: Seitenleiste als Blatt -->
|
||||
<div class="fixed right-4 bottom-4 z-30 flex gap-2 lg:hidden">
|
||||
<Button variant="outline" class="bg-card shadow-md" :disabled="readOnly" @click="sidebarTab = 'blocks'; sheetOpen = true">Block hinzufügen</Button>
|
||||
<Button v-if="selected" class="shadow-md" @click="sidebarTab = 'block'; sheetOpen = true">Einstellungen</Button>
|
||||
</div>
|
||||
<Sheet v-model:open="sheetOpen">
|
||||
<SheetContent side="right" class="w-[340px] overflow-y-auto p-4 sm:max-w-[340px]">
|
||||
<SheetHeader class="p-0"><SheetTitle>{{ sidebarTab === 'block' ? 'Block' : 'Blöcke' }}</SheetTitle></SheetHeader>
|
||||
<BlockSettings v-if="sidebarTab === 'block' && selected" :key="selected.id" :block="selected" />
|
||||
<BlockPalette v-else @pick="insertFromPalette" />
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
|
||||
<PublishDialog v-model:open="dialogs.publish" :scheduled-at="page.scheduled_at" @publish="publish" />
|
||||
<ReviewDialog v-model:open="dialogs.review" @submit="requestReview" />
|
||||
<RevisionsDialog v-model:open="dialogs.revisions" :base="base" :read-only="readOnly" @restored="restored" />
|
||||
<PageSettingsDialog v-model:open="dialogs.settings" :page="page" :base="base" @saved="(data) => (page = data.page)" />
|
||||
<NewPageDialog v-model:open="dialogs.newPage" :parent-id="page.id" :parent-title="page.title" @before-create="save" />
|
||||
</div>
|
||||
|
||||
<Toaster position="bottom-left" />
|
||||
</template>
|
||||
55
plugins-core/pages/resources/js/pages/Index.vue
Normal file
55
plugins-core/pages/resources/js/pages/Index.vue
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ChevronRight, FileText, FolderOpen, Plus } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import NewPageDialog from '../components/NewPageDialog.vue';
|
||||
|
||||
defineProps({
|
||||
tree: { type: Array, required: true },
|
||||
canCreate: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
const creating = ref(false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Seiten">
|
||||
<div class="mb-6 flex flex-wrap items-end justify-between gap-4">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold tracking-tight">Seiten</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">Informationen der Bereiche, Abteilungen und Gremien.</p>
|
||||
</div>
|
||||
<Button v-if="canCreate" @click="creating = true"><Plus /> Neue Seite</Button>
|
||||
</div>
|
||||
|
||||
<div v-if="tree.length" class="grid gap-5 md:grid-cols-2 xl:grid-cols-3">
|
||||
<section v-for="section in tree" :key="section.id" class="rounded-lg border bg-card">
|
||||
<Link :href="section.url" class="flex items-center gap-3 border-b px-5 py-4 hover:bg-accent/50">
|
||||
<span class="grid size-10 shrink-0 place-items-center rounded-lg bg-brand-soft text-brand-text">
|
||||
<FolderOpen v-if="section.children.length" class="size-5" />
|
||||
<FileText v-else class="size-5" />
|
||||
</span>
|
||||
<span class="min-w-0 flex-1 truncate font-semibold">{{ section.title }}</span>
|
||||
<ChevronRight class="size-4 text-muted-foreground" />
|
||||
</Link>
|
||||
<ul v-if="section.children.length" class="grid p-2">
|
||||
<li v-for="child in section.children.slice(0, 8)" :key="child.id">
|
||||
<Link :href="child.url" class="flex items-center justify-between rounded-md px-3 py-2 text-sm hover:bg-accent">
|
||||
<span class="truncate">{{ child.title }}</span>
|
||||
<span v-if="child.children.length" class="text-xs text-muted-foreground">{{ child.children.length }}</span>
|
||||
</Link>
|
||||
</li>
|
||||
<li v-if="section.children.length > 8" class="px-3 py-1.5 text-[13px]">
|
||||
<Link :href="section.url" class="font-medium text-brand-text hover:underline">Alle {{ section.children.length }} Seiten</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
<div v-else class="rounded-lg border bg-card"><EmptyState :icon="FileText" title="Noch keine Seiten" text="Hier erscheinen Seiten, sobald sie veröffentlicht sind." /></div>
|
||||
|
||||
<NewPageDialog v-model:open="creating" />
|
||||
</AppLayout>
|
||||
</template>
|
||||
72
plugins-core/pages/resources/js/pages/Show.vue
Normal file
72
plugins-core/pages/resources/js/pages/Show.vue
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ChevronRight, CalendarClock, PencilLine } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import PageContent from '@/pagebuilder/PageContent.vue';
|
||||
import { formatDate } from '@/lib/format';
|
||||
import PageTreeNav from '../components/PageTreeNav.vue';
|
||||
|
||||
const props = defineProps({
|
||||
page: { type: Object, required: true },
|
||||
content: { type: Object, required: true },
|
||||
breadcrumbs: { type: Array, default: () => [] },
|
||||
section: { type: Object, required: true },
|
||||
editor: { type: Object, default: null },
|
||||
});
|
||||
|
||||
const hasSectionNav = props.section.children.length > 0;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="page.title">
|
||||
<div class="grid gap-8" :class="hasSectionNav ? 'lg:grid-cols-[260px_minmax(0,1fr)]' : ''">
|
||||
<aside v-if="hasSectionNav" class="hidden lg:block">
|
||||
<nav class="sticky top-24 rounded-lg border bg-card p-2" aria-label="Seiten in diesem Bereich">
|
||||
<Link
|
||||
:href="section.url"
|
||||
class="block rounded-md px-3 py-2 text-sm font-semibold"
|
||||
:class="section.active ? 'bg-brand-soft text-brand-soft-foreground' : 'hover:bg-accent'"
|
||||
>
|
||||
{{ section.title }}
|
||||
</Link>
|
||||
<PageTreeNav :items="section.children" :current="page.url" />
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<article class="min-w-0" :class="hasSectionNav ? '' : 'mx-auto w-full max-w-5xl'">
|
||||
<nav v-if="breadcrumbs.length" class="mb-3 flex flex-wrap items-center gap-1 text-[13px] text-muted-foreground" aria-label="Brotkrumen">
|
||||
<template v-for="crumb in breadcrumbs" :key="crumb.url">
|
||||
<Link :href="crumb.url" class="hover:text-foreground hover:underline">{{ crumb.title }}</Link>
|
||||
<ChevronRight class="size-3.5" />
|
||||
</template>
|
||||
<span class="text-foreground">{{ page.title }}</span>
|
||||
</nav>
|
||||
|
||||
<header class="mb-8 flex flex-wrap items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<h1 class="text-3xl leading-tight font-semibold tracking-tight">{{ page.title }}</h1>
|
||||
<p v-if="page.published_at" class="mt-1.5 text-[13px] text-muted-foreground">Zuletzt aktualisiert am {{ formatDate(page.published_at) }}</p>
|
||||
</div>
|
||||
<Button v-if="editor" variant="outline" as-child>
|
||||
<Link :href="editor.url"><PencilLine /> Bearbeiten</Link>
|
||||
</Button>
|
||||
</header>
|
||||
|
||||
<div v-if="editor && (!page.is_published || editor.has_draft || editor.scheduled_at)" class="mb-6 flex items-start gap-3 rounded-lg border border-brand-200 bg-brand-soft px-4 py-3 text-sm">
|
||||
<CalendarClock v-if="editor.scheduled_at" class="mt-0.5 size-4 shrink-0 text-brand-text" />
|
||||
<PencilLine v-else class="mt-0.5 size-4 shrink-0 text-brand-text" />
|
||||
<p>
|
||||
<template v-if="!page.is_published">Diese Seite ist noch nicht veröffentlicht. Nur Redakteure sehen sie.</template>
|
||||
<template v-else-if="editor.scheduled_at">Eine neue Fassung wird am {{ new Date(editor.scheduled_at).toLocaleString('de-DE', { dateStyle: 'medium', timeStyle: 'short' }) }} veröffentlicht.</template>
|
||||
<template v-else>Es gibt unveröffentlichte Änderungen an dieser Seite.</template>
|
||||
<Link :href="editor.url" class="ml-1 font-medium text-brand-text hover:underline">Im Editor öffnen</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<PageContent :content="content" />
|
||||
<p v-if="!content.blocks.length" class="rounded-lg border border-dashed px-6 py-12 text-center text-sm text-muted-foreground">Diese Seite hat noch keinen Inhalt.</p>
|
||||
</article>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue