Seiten: Bausteine und Vorlagen (0.22.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m0s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m50s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m33s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m11s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m24s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m0s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m0s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m50s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m33s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m11s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m46s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m24s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8817727283
commit
2166a7e11a
129 changed files with 1381 additions and 267 deletions
|
|
@ -4,6 +4,8 @@ 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';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
const props = defineProps({
|
||||
parentId: { type: Number, default: null },
|
||||
|
|
@ -12,9 +14,21 @@ const props = defineProps({
|
|||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['before-create']);
|
||||
const form = useForm({ title: '', parent_id: null });
|
||||
const form = useForm({ title: '', parent_id: null, template_id: null });
|
||||
const templates = ref([]);
|
||||
|
||||
watch(open, (value) => value && (form.reset(), form.clearErrors()));
|
||||
watch(open, async (value) => {
|
||||
if (!value) return;
|
||||
|
||||
form.reset();
|
||||
form.clearErrors();
|
||||
|
||||
try {
|
||||
templates.value = (await http.get('/redaktion/bausteine?kind=template')).snippets;
|
||||
} catch {
|
||||
templates.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
async function create() {
|
||||
emit('before-create');
|
||||
|
|
@ -37,6 +51,10 @@ async function create() {
|
|||
<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>
|
||||
<label v-if="templates.length" class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Vorlage</span>
|
||||
<NativeSelect v-model="form.template_id" :options="[{ value: null, label: 'Leere Seite' }, ...templates.map((t) => ({ value: t.id, label: t.description ? `${t.name} – ${t.description}` : t.name }))]" />
|
||||
</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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { LoaderCircle } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/**
|
||||
* Block als Baustein bzw. Seite als Vorlage speichern.
|
||||
*/
|
||||
const props = defineProps({
|
||||
kind: { type: String, default: 'block' },
|
||||
content: { type: Object, default: null },
|
||||
suggestion: { type: String, default: '' },
|
||||
});
|
||||
|
||||
const open = defineModel('open', { type: Boolean, default: false });
|
||||
const emit = defineEmits(['saved']);
|
||||
|
||||
const name = ref('');
|
||||
const description = ref('');
|
||||
const saving = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
watch(open, (value) => {
|
||||
if (!value) return;
|
||||
|
||||
name.value = props.suggestion;
|
||||
description.value = '';
|
||||
error.value = '';
|
||||
});
|
||||
|
||||
async function save() {
|
||||
saving.value = true;
|
||||
error.value = '';
|
||||
|
||||
try {
|
||||
const data = await http.post('/redaktion/bausteine', { kind: props.kind, name: name.value, description: description.value || null, content: props.content });
|
||||
emit('saved', data.snippet);
|
||||
open.value = false;
|
||||
} catch (e) {
|
||||
error.value = e.data?.errors?.name?.[0] ?? e.message;
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogContent class="sm:max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ kind === 'block' ? 'Als Baustein speichern' : 'Als Vorlage speichern' }}</DialogTitle>
|
||||
<DialogDescription v-if="kind === 'block'">Der Block wird zum Baustein und lässt sich auf anderen Seiten einsetzen. Änderungen am Baustein wirken dann überall.</DialogDescription>
|
||||
<DialogDescription v-else>Der Inhalt dieser Seite steht beim Anlegen neuer Seiten als Vorlage zur Wahl.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form class="grid gap-3" @submit.prevent="save">
|
||||
<label class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Name</span>
|
||||
<Input v-model="name" maxlength="120" autofocus :aria-invalid="!!error" />
|
||||
</label>
|
||||
<label class="grid gap-1.5">
|
||||
<span class="text-[13px] font-medium">Beschreibung (optional)</span>
|
||||
<Input v-model="description" maxlength="300" />
|
||||
</label>
|
||||
<p v-if="error" class="text-[13px] text-destructive">{{ error }}</p>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="outline" @click="open = false">Abbrechen</Button>
|
||||
<Button type="submit" :disabled="saving || !name.trim()"><LoaderCircle v-if="saving" class="animate-spin" /> Speichern</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue