12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
313270b55f
777 changed files with 67136 additions and 6241 deletions
78
resources/views/livewire/admin/presets/create.blade.php
Normal file
78
resources/views/livewire/admin/presets/create.blade.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
use App\Models\AdminPreset;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Neue Voreinstellung')] class extends Component
|
||||
{
|
||||
public string $key = '';
|
||||
|
||||
public string $area = 'press_releases';
|
||||
|
||||
public string $type = 'text';
|
||||
|
||||
public string $label = '';
|
||||
|
||||
public string $value = '';
|
||||
|
||||
public string $payload = '';
|
||||
|
||||
public bool $isActive = true;
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'key' => ['required', 'string', 'max:255', 'regex:/^[a-z0-9_.-]+$/', Rule::unique('admin_presets', 'key')],
|
||||
'area' => ['required', 'string', 'max:100'],
|
||||
'type' => ['required', Rule::in(['text', 'number', 'boolean', 'json'])],
|
||||
'label' => ['required', 'string', 'max:255'],
|
||||
'value' => ['nullable', 'string'],
|
||||
'payload' => ['nullable', 'json'],
|
||||
'isActive' => ['boolean'],
|
||||
]);
|
||||
|
||||
AdminPreset::query()->create([
|
||||
'key' => $validated['key'],
|
||||
'area' => $validated['area'],
|
||||
'type' => $validated['type'],
|
||||
'label' => $validated['label'],
|
||||
'value' => $validated['value'] ?: null,
|
||||
'payload' => filled($validated['payload']) ? json_decode($validated['payload'], true) : null,
|
||||
'is_active' => $validated['isActive'],
|
||||
]);
|
||||
|
||||
session()->flash('success', __('Voreinstellung wurde angelegt.'));
|
||||
|
||||
$this->redirect(route('admin.presets.index'), navigate: true);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<form wire:submit="save" class="space-y-6">
|
||||
<flux:card>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Neue Voreinstellung') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Texte, Zahlen oder JSON-Werte zentral fuer Admin-Funktionen pflegen.') }}</flux:subheading>
|
||||
</div>
|
||||
<flux:button variant="ghost" icon="arrow-left" href="{{ route('admin.presets.index') }}" wire:navigate>
|
||||
{{ __('Zurück') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
@include('livewire.admin.presets.partials.form-fields')
|
||||
|
||||
<flux:card>
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:button variant="ghost" href="{{ route('admin.presets.index') }}" wire:navigate>
|
||||
{{ __('Abbrechen') }}
|
||||
</flux:button>
|
||||
<flux:button type="submit" variant="primary">
|
||||
{{ __('Voreinstellung erstellen') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
</form>
|
||||
99
resources/views/livewire/admin/presets/edit.blade.php
Normal file
99
resources/views/livewire/admin/presets/edit.blade.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
|
||||
use App\Models\AdminPreset;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Voreinstellung bearbeiten')] class extends Component
|
||||
{
|
||||
#[Locked]
|
||||
public int $id;
|
||||
|
||||
public string $key = '';
|
||||
|
||||
public string $area = '';
|
||||
|
||||
public string $type = 'text';
|
||||
|
||||
public string $label = '';
|
||||
|
||||
public string $value = '';
|
||||
|
||||
public string $payload = '';
|
||||
|
||||
public bool $isActive = true;
|
||||
|
||||
public function mount(int $id): void
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
$preset = AdminPreset::query()->findOrFail($id);
|
||||
|
||||
$this->key = $preset->key;
|
||||
$this->area = $preset->area;
|
||||
$this->type = $preset->type;
|
||||
$this->label = $preset->label;
|
||||
$this->value = $preset->value ?? '';
|
||||
$this->payload = $preset->payload ? json_encode($preset->payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : '';
|
||||
$this->isActive = $preset->is_active;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$validated = $this->validate([
|
||||
'key' => ['required', 'string', 'max:255', 'regex:/^[a-z0-9_.-]+$/', Rule::unique('admin_presets', 'key')->ignore($this->id)],
|
||||
'area' => ['required', 'string', 'max:100'],
|
||||
'type' => ['required', Rule::in(['text', 'number', 'boolean', 'json'])],
|
||||
'label' => ['required', 'string', 'max:255'],
|
||||
'value' => ['nullable', 'string'],
|
||||
'payload' => ['nullable', 'json'],
|
||||
'isActive' => ['boolean'],
|
||||
]);
|
||||
|
||||
AdminPreset::query()
|
||||
->findOrFail($this->id)
|
||||
->update([
|
||||
'key' => $validated['key'],
|
||||
'area' => $validated['area'],
|
||||
'type' => $validated['type'],
|
||||
'label' => $validated['label'],
|
||||
'value' => $validated['value'] ?: null,
|
||||
'payload' => filled($validated['payload']) ? json_decode($validated['payload'], true) : null,
|
||||
'is_active' => $validated['isActive'],
|
||||
]);
|
||||
|
||||
session()->flash('success', __('Voreinstellung wurde gespeichert.'));
|
||||
|
||||
$this->redirect(route('admin.presets.index'), navigate: true);
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<form wire:submit="save" class="space-y-6">
|
||||
<flux:card>
|
||||
<div class="flex items-center justify-between gap-4">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Voreinstellung bearbeiten') }}</flux:heading>
|
||||
<flux:subheading>{{ __('ID') }}: {{ $id }}</flux:subheading>
|
||||
</div>
|
||||
<flux:button variant="ghost" icon="arrow-left" href="{{ route('admin.presets.index') }}" wire:navigate>
|
||||
{{ __('Zurück') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
@include('livewire.admin.presets.partials.form-fields')
|
||||
|
||||
<flux:card>
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:button variant="ghost" href="{{ route('admin.presets.index') }}" wire:navigate>
|
||||
{{ __('Abbrechen') }}
|
||||
</flux:button>
|
||||
<flux:button type="submit" variant="primary">
|
||||
{{ __('Änderungen speichern') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
</form>
|
||||
184
resources/views/livewire/admin/presets/index.blade.php
Normal file
184
resources/views/livewire/admin/presets/index.blade.php
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
use App\Models\AdminPreset;
|
||||
use App\Services\Admin\AdminPerformanceCache;
|
||||
use Livewire\Attributes\Layout;
|
||||
use Livewire\Attributes\Title;
|
||||
use Livewire\Volt\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
new #[Layout('components.layouts.app'), Title('Voreinstellungen')] class extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $search = '';
|
||||
|
||||
public string $areaFilter = 'all';
|
||||
|
||||
public string $typeFilter = 'all';
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedAreaFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedTypeFilter(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function with(): array
|
||||
{
|
||||
$presets = AdminPreset::query()
|
||||
->when(filled($this->search), function ($query): void {
|
||||
$term = $this->search;
|
||||
|
||||
$query->where(function ($query) use ($term): void {
|
||||
$query->where('key', 'like', '%'.$term.'%')
|
||||
->orWhere('label', 'like', '%'.$term.'%')
|
||||
->orWhere('value', 'like', '%'.$term.'%');
|
||||
});
|
||||
})
|
||||
->when($this->areaFilter !== 'all', fn ($query) => $query->where('area', $this->areaFilter))
|
||||
->when($this->typeFilter !== 'all', fn ($query) => $query->where('type', $this->typeFilter))
|
||||
->orderBy('area')
|
||||
->orderBy('key')
|
||||
->paginate(50);
|
||||
|
||||
return [
|
||||
'presets' => $presets,
|
||||
'areas' => $this->areas(),
|
||||
'types' => $this->types(),
|
||||
];
|
||||
}
|
||||
|
||||
private function areas()
|
||||
{
|
||||
return app(AdminPerformanceCache::class)->remember(AdminPerformanceCache::PresetAreas, AdminPerformanceCache::OptionsTtl, fn () => AdminPreset::query()
|
||||
->select('area')
|
||||
->distinct()
|
||||
->orderBy('area')
|
||||
->pluck('area'));
|
||||
}
|
||||
|
||||
private function types()
|
||||
{
|
||||
return app(AdminPerformanceCache::class)->remember(AdminPerformanceCache::PresetTypes, AdminPerformanceCache::OptionsTtl, fn () => AdminPreset::query()
|
||||
->select('type')
|
||||
->distinct()
|
||||
->orderBy('type')
|
||||
->pluck('type'));
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div class="space-y-6">
|
||||
@if(session('success'))
|
||||
<div class="rounded-md border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800 dark:border-green-800 dark:bg-green-900/20 dark:text-green-300">
|
||||
{{ session('success') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<flux:card>
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Voreinstellungen') }}</flux:heading>
|
||||
<flux:subheading>{{ __('Zentrale Admin-Presets fuer Texte, Zahlen und weitere Werte.') }}</flux:subheading>
|
||||
</div>
|
||||
|
||||
<flux:button icon="plus" variant="primary" href="{{ route('admin.presets.create') }}" wire:navigate>
|
||||
{{ __('Neue Voreinstellung') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
<flux:input
|
||||
wire:model.live.debounce.300ms="search"
|
||||
placeholder="{{ __('Key, Bezeichnung oder Wert suchen...') }}"
|
||||
icon="magnifying-glass"
|
||||
class="flex-1"
|
||||
/>
|
||||
|
||||
<flux:select wire:model.live="areaFilter" class="sm:w-48">
|
||||
<option value="all">{{ __('Alle Bereiche') }}</option>
|
||||
@foreach($areas as $area)
|
||||
<option value="{{ $area }}">{{ $area }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
|
||||
<flux:select wire:model.live="typeFilter" class="sm:w-40">
|
||||
<option value="all">{{ __('Alle Typen') }}</option>
|
||||
@foreach($types as $type)
|
||||
<option value="{{ $type }}">{{ $type }}</option>
|
||||
@endforeach
|
||||
</flux:select>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card class="overflow-hidden">
|
||||
<flux:table>
|
||||
<flux:table.columns>
|
||||
<flux:table.column>{{ __('Key') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Bereich') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Typ') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Wert') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Status') }}</flux:table.column>
|
||||
<flux:table.column>{{ __('Aktionen') }}</flux:table.column>
|
||||
</flux:table.columns>
|
||||
|
||||
<flux:table.rows>
|
||||
@forelse($presets as $preset)
|
||||
<flux:table.row wire:key="{{ $preset->id }}">
|
||||
<flux:table.cell>
|
||||
<div class="max-w-xs">
|
||||
<flux:text weight="semibold" class="truncate">{{ $preset->label }}</flux:text>
|
||||
<flux:text class="truncate text-xs text-zinc-500">{{ $preset->key }}</flux:text>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:badge color="blue" size="sm">{{ $preset->area }}</flux:badge>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:badge color="zinc" size="sm">{{ $preset->type }}</flux:badge>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:text class="line-clamp-2 max-w-sm text-sm text-zinc-600 dark:text-zinc-300">
|
||||
{{ \Illuminate\Support\Str::limit($preset->value ?? '-', 140) }}
|
||||
</flux:text>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:badge color="{{ $preset->is_active ? 'green' : 'zinc' }}" size="sm">
|
||||
{{ $preset->is_active ? __('Aktiv') : __('Inaktiv') }}
|
||||
</flux:badge>
|
||||
</flux:table.cell>
|
||||
|
||||
<flux:table.cell>
|
||||
<flux:button size="sm" variant="ghost" icon="pencil" href="{{ route('admin.presets.edit', $preset->id) }}" wire:navigate />
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@empty
|
||||
<flux:table.row>
|
||||
<flux:table.cell colspan="6">
|
||||
<div class="flex flex-col items-center justify-center py-10">
|
||||
<flux:icon.cog class="size-10 text-zinc-400" />
|
||||
<flux:text class="mt-3 text-zinc-500">{{ __('Keine Voreinstellungen gefunden.') }}</flux:text>
|
||||
</div>
|
||||
</flux:table.cell>
|
||||
</flux:table.row>
|
||||
@endforelse
|
||||
</flux:table.rows>
|
||||
</flux:table>
|
||||
</flux:card>
|
||||
|
||||
{{ $presets->links() }}
|
||||
</div>
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
<div class="grid gap-6 lg:grid-cols-[1fr,320px]">
|
||||
<div class="space-y-6">
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Basisdaten') }}</flux:heading>
|
||||
|
||||
<div class="space-y-4">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Key') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:input wire:model="key" placeholder="press_releases.deleted_published_text" />
|
||||
<flux:description>{{ __('Technischer Schlüssel. Erlaubt sind Kleinbuchstaben, Zahlen, Punkt, Unterstrich und Bindestrich.') }}</flux:description>
|
||||
<flux:error name="key" />
|
||||
</flux:field>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Bereich') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:input wire:model="area" placeholder="press_releases" />
|
||||
<flux:error name="area" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Typ') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:select wire:model="type">
|
||||
<option value="text">{{ __('Text') }}</option>
|
||||
<option value="number">{{ __('Zahl') }}</option>
|
||||
<option value="boolean">{{ __('Boolean') }}</option>
|
||||
<option value="json">{{ __('JSON') }}</option>
|
||||
</flux:select>
|
||||
<flux:error name="type" />
|
||||
</flux:field>
|
||||
</div>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Bezeichnung') }} <span class="text-red-500">*</span></flux:label>
|
||||
<flux:input wire:model="label" placeholder="{{ __('Ersatztext für gelöschte veröffentlichte Pressemitteilungen') }}" />
|
||||
<flux:error name="label" />
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:card>
|
||||
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Werte') }}</flux:heading>
|
||||
|
||||
<div class="space-y-4">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Wert') }}</flux:label>
|
||||
<flux:textarea wire:model="value" rows="10" />
|
||||
<flux:description>{{ __('Hauptwert des Presets. Für Texte ist dies der eigentliche Inhalt.') }}</flux:description>
|
||||
<flux:error name="value" />
|
||||
</flux:field>
|
||||
|
||||
<flux:field>
|
||||
<flux:label>{{ __('Payload JSON') }}</flux:label>
|
||||
<flux:textarea wire:model="payload" rows="8" placeholder='{"example": true}' />
|
||||
<flux:description>{{ __('Optionaler strukturierter Zusatzwert. Leer lassen, wenn nicht benötigt.') }}</flux:description>
|
||||
<flux:error name="payload" />
|
||||
</flux:field>
|
||||
</div>
|
||||
</flux:card>
|
||||
</div>
|
||||
|
||||
<div class="space-y-6">
|
||||
<flux:card>
|
||||
<flux:heading size="lg" class="mb-4">{{ __('Status') }}</flux:heading>
|
||||
|
||||
<flux:checkbox wire:model="isActive" label="{{ __('Aktiv') }}" />
|
||||
|
||||
<flux:text class="mt-3 text-sm text-zinc-500">
|
||||
{{ __('Nur aktive Presets werden von der Anwendung automatisch verwendet.') }}
|
||||
</flux:text>
|
||||
</flux:card>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Add table
Add a link
Reference in a new issue