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>
135 lines
6.7 KiB
Vue
135 lines
6.7 KiB
Vue
<script setup>
|
|
import { computed, inject, watch } from 'vue';
|
|
import { ArrowDown, ArrowUp, EyeOff, Plus, Trash2 } from '@lucide/vue';
|
|
import { Input } from '@/components/ui/input';
|
|
import FieldInput from './FieldInput.vue';
|
|
import { blockIcon } from './icons';
|
|
import { syncColumns, uid } from './tree';
|
|
|
|
const props = defineProps({
|
|
block: { type: Object, required: true },
|
|
});
|
|
|
|
const editor = inject('pagebuilder:editor');
|
|
const type = computed(() => editor.types[props.block.type]);
|
|
|
|
// Formatierter Text wird direkt im Block bearbeitet.
|
|
const fields = computed(() => (type.value?.fields ?? []).filter((field) => field.type !== 'html'));
|
|
|
|
watch(() => props.block.data.layout, () => {
|
|
if (props.block.type === 'columns') syncColumns(props.block);
|
|
});
|
|
|
|
function addItem() {
|
|
props.block.items.push({ id: uid(), title: `${type.value.container.label} ${props.block.items.length + 1}`, blocks: [] });
|
|
}
|
|
|
|
function moveItem(index, direction) {
|
|
const items = props.block.items;
|
|
const target = index + direction;
|
|
|
|
if (target >= 0 && target < items.length) {
|
|
[items[index], items[target]] = [items[target], items[index]];
|
|
}
|
|
}
|
|
|
|
function removeItem(index) {
|
|
const item = props.block.items[index];
|
|
|
|
if (item.blocks.length && !window.confirm(`„${item.title || type.value.container.label}“ enthält Inhalte. Trotzdem entfernen?`)) return;
|
|
|
|
props.block.items.splice(index, 1);
|
|
}
|
|
|
|
// Sichtbarkeit einzelner Blöcke
|
|
const visibility = computed(() => props.block.visibility ?? {});
|
|
const restricted = computed(() => Object.values(visibility.value).some((values) => values?.length));
|
|
|
|
function toggleRule(rule, value) {
|
|
const current = new Set(visibility.value[rule] ?? []);
|
|
current.has(value) ? current.delete(value) : current.add(value);
|
|
props.block.visibility = { ...visibility.value, [rule]: [...current] };
|
|
}
|
|
|
|
const ruleGroups = computed(() => [
|
|
{ key: 'role', label: 'Rollen', options: editor.audienceOptions.role },
|
|
{ key: 'department', label: 'Abteilungen', options: editor.audienceOptions.department.map((value) => ({ value, label: value })) },
|
|
{ key: 'location', label: 'Standorte', options: editor.audienceOptions.location.map((value) => ({ value, label: value })) },
|
|
].filter((group) => group.options.length));
|
|
</script>
|
|
|
|
<template>
|
|
<div v-if="type" class="grid gap-5">
|
|
<header class="flex items-start gap-3">
|
|
<span class="grid size-9 shrink-0 place-items-center rounded-md bg-brand-soft text-brand-text"><component :is="blockIcon(type.icon)" class="size-4.5" /></span>
|
|
<div class="min-w-0">
|
|
<h2 class="font-semibold">{{ type.label }}</h2>
|
|
<p v-if="type.description" class="text-xs text-muted-foreground">{{ type.description }}</p>
|
|
</div>
|
|
</header>
|
|
|
|
<p v-if="type.fields.some((field) => field.type === 'html')" class="rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground">
|
|
Den Text bearbeiten Sie direkt im Block. Markieren Sie Text für Fettdruck, Links und Listen.
|
|
</p>
|
|
|
|
<FieldInput
|
|
v-for="field in fields"
|
|
:id="`field-${block.id}-${field.name}`"
|
|
:key="`${block.id}-${field.name}`"
|
|
v-model="block.data[field.name]"
|
|
:field="field"
|
|
/>
|
|
|
|
<section v-if="type.container && type.container.max > 1 && type.key !== 'columns'" class="grid gap-2">
|
|
<h3 class="text-[13px] font-medium">{{ type.container.label }}s</h3>
|
|
<div v-for="(item, index) in block.items" :key="item.id" class="flex items-center gap-1">
|
|
<Input v-if="type.container.titled" v-model="item.title" class="h-8" :aria-label="`Titel ${index + 1}`" maxlength="120" />
|
|
<span v-else class="flex-1 text-[13px]">{{ type.container.label }} {{ index + 1 }}</span>
|
|
<button type="button" class="grid size-7 shrink-0 place-items-center rounded hover:bg-accent" title="Nach oben" @click="moveItem(index, -1)"><ArrowUp class="size-3.5" /></button>
|
|
<button type="button" class="grid size-7 shrink-0 place-items-center rounded hover:bg-accent" title="Nach unten" @click="moveItem(index, 1)"><ArrowDown class="size-3.5" /></button>
|
|
<button
|
|
type="button"
|
|
class="grid size-7 shrink-0 place-items-center rounded text-destructive hover:bg-destructive/10 disabled:opacity-30"
|
|
title="Entfernen"
|
|
:disabled="block.items.length <= type.container.min"
|
|
@click="removeItem(index)"
|
|
>
|
|
<Trash2 class="size-3.5" />
|
|
</button>
|
|
</div>
|
|
<button
|
|
v-if="block.items.length < type.container.max"
|
|
type="button"
|
|
class="flex h-8 items-center justify-center gap-1.5 rounded-md border border-dashed text-[13px] font-medium text-muted-foreground hover:border-brand-300 hover:text-foreground"
|
|
@click="addItem"
|
|
>
|
|
<Plus class="size-3.5" /> {{ type.container.label }} hinzufügen
|
|
</button>
|
|
</section>
|
|
|
|
<details v-if="ruleGroups.length" class="rounded-md border" :open="restricted">
|
|
<summary class="flex cursor-pointer items-center gap-2 px-3 py-2 text-[13px] font-medium">
|
|
<EyeOff class="size-4 text-muted-foreground" />
|
|
Sichtbarkeit
|
|
<span v-if="restricted" class="ml-auto rounded bg-amber-100 px-1.5 py-0.5 text-[11px] text-amber-800 dark:bg-amber-900/50 dark:text-amber-200">eingeschränkt</span>
|
|
</summary>
|
|
<div class="grid gap-3 border-t px-3 py-3">
|
|
<p class="text-xs text-muted-foreground">Leer = für alle, die die Seite sehen. Sonst nur für Personen, die mindestens eine Angabe erfüllen.</p>
|
|
<fieldset v-for="group in ruleGroups" :key="group.key" class="grid gap-1">
|
|
<legend class="mb-1 text-xs font-semibold text-muted-foreground">{{ group.label }}</legend>
|
|
<div class="grid max-h-36 gap-0.5 overflow-y-auto">
|
|
<label v-for="option in group.options" :key="option.value" class="flex items-center gap-2 rounded px-1 py-0.5 text-[13px] hover:bg-accent">
|
|
<input
|
|
type="checkbox"
|
|
class="size-4 accent-[var(--brand)]"
|
|
:checked="(visibility[group.key] ?? []).includes(option.value)"
|
|
@change="toggleRule(group.key, option.value)"
|
|
/>
|
|
{{ option.label }}
|
|
</label>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
</template>
|