12-05-2026 admin, Panel Displays
This commit is contained in:
parent
0762e3beac
commit
6a65354f4c
43 changed files with 3273 additions and 410 deletions
|
|
@ -101,11 +101,13 @@ class DisplayVersionEditor extends Component
|
|||
/** @var array<string> */
|
||||
public array $availableVideos = [];
|
||||
|
||||
public int $previewFrameRefreshCounter = 0;
|
||||
|
||||
public function mount(DisplayVersion $displayVersion): void
|
||||
{
|
||||
$this->version = $displayVersion;
|
||||
$this->versionName = $displayVersion->name;
|
||||
$this->settings = $displayVersion->settings ?? [];
|
||||
$this->settings = $this->settingsWithDefaults();
|
||||
|
||||
if ($this->version->type === DisplayVersionType::VideoDisplay) {
|
||||
$this->loadAvailableVideos();
|
||||
|
|
@ -127,10 +129,11 @@ class DisplayVersionEditor extends Component
|
|||
|
||||
public function toggleTheme(): void
|
||||
{
|
||||
$settings = $this->version->settings ?? [];
|
||||
$settings = $this->settingsWithDefaults();
|
||||
$settings['theme'] = ($settings['theme'] ?? 'dark') === 'dark' ? 'light' : 'dark';
|
||||
$this->version->update(['settings' => $settings]);
|
||||
$this->settings = $settings;
|
||||
$this->refreshModulePreview();
|
||||
}
|
||||
|
||||
public function saveName(): void
|
||||
|
|
@ -140,6 +143,7 @@ class DisplayVersionEditor extends Component
|
|||
]);
|
||||
|
||||
$this->version->update(['name' => $this->versionName]);
|
||||
$this->refreshModulePreview();
|
||||
session()->flash('success', 'Name aktualisiert!');
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +153,7 @@ class DisplayVersionEditor extends Component
|
|||
|
||||
public function openSettingsModal(): void
|
||||
{
|
||||
$this->settings = $this->version->settings ?? [];
|
||||
$this->settings = $this->settingsWithDefaults();
|
||||
$this->showSettingsModal = true;
|
||||
}
|
||||
|
||||
|
|
@ -157,6 +161,7 @@ class DisplayVersionEditor extends Component
|
|||
{
|
||||
$this->version->update(['settings' => $this->settings]);
|
||||
$this->showSettingsModal = false;
|
||||
$this->refreshModulePreview();
|
||||
session()->flash('success', 'Einstellungen gespeichert!');
|
||||
}
|
||||
|
||||
|
|
@ -197,7 +202,7 @@ class DisplayVersionEditor extends Component
|
|||
->where('item_type', $this->itemType)
|
||||
->max('sort_order') ?? -1;
|
||||
|
||||
DisplayVersionItem::create([
|
||||
$item = DisplayVersionItem::create([
|
||||
'display_version_id' => $this->version->id,
|
||||
'item_type' => $this->itemType,
|
||||
'content' => $content,
|
||||
|
|
@ -207,12 +212,17 @@ class DisplayVersionEditor extends Component
|
|||
session()->flash('success', 'Inhalt hinzugefügt!');
|
||||
}
|
||||
|
||||
$this->closeItemModal();
|
||||
$this->itemId = $item->id;
|
||||
$this->itemType = $item->item_type;
|
||||
$this->loadItemContent($item->fresh());
|
||||
$this->showItemModal = true;
|
||||
$this->refreshModulePreview();
|
||||
}
|
||||
|
||||
public function deleteItem(int $id): void
|
||||
{
|
||||
DisplayVersionItem::findOrFail($id)->delete();
|
||||
$this->refreshModulePreview();
|
||||
session()->flash('success', 'Inhalt gelöscht!');
|
||||
}
|
||||
|
||||
|
|
@ -220,6 +230,7 @@ class DisplayVersionEditor extends Component
|
|||
{
|
||||
$item = DisplayVersionItem::findOrFail($id);
|
||||
$item->update(['is_active' => ! $item->is_active]);
|
||||
$this->refreshModulePreview();
|
||||
}
|
||||
|
||||
public function moveItem(int $id, string $direction): void
|
||||
|
|
@ -235,9 +246,24 @@ class DisplayVersionEditor extends Component
|
|||
if ($swapItem) {
|
||||
$item->update(['sort_order' => $swapItem->sort_order]);
|
||||
$swapItem->update(['sort_order' => $currentOrder]);
|
||||
$this->refreshModulePreview();
|
||||
}
|
||||
}
|
||||
|
||||
public function modulePreviewUrl(): string
|
||||
{
|
||||
return url('/preview/module/'.$this->version->id).'?refresh='.$this->previewFrameRefreshCounter;
|
||||
}
|
||||
|
||||
public function itemPreviewUrl(): string
|
||||
{
|
||||
if (! $this->itemId) {
|
||||
return $this->modulePreviewUrl();
|
||||
}
|
||||
|
||||
return url('/preview/module/'.$this->version->id.'/item/'.$this->itemId).'?refresh='.$this->previewFrameRefreshCounter;
|
||||
}
|
||||
|
||||
#[On('display-media-selected')]
|
||||
public function onDisplayMediaSelected(string $field, ?int $mediaId, ?string $url): void
|
||||
{
|
||||
|
|
@ -249,6 +275,8 @@ class DisplayVersionEditor extends Component
|
|||
'videoFilename' => $this->videoFilename = $url,
|
||||
'mediaUrl' => $this->mediaUrl = $url,
|
||||
'slideImageUrl' => $this->slideImageUrl = $url,
|
||||
'settings.header_logo_url' => $this->settings['header_logo_url'] = $url,
|
||||
'settings.logo_url' => $this->settings['logo_url'] = $url,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
|
@ -442,6 +470,58 @@ class DisplayVersionEditor extends Component
|
|||
$this->slideIsActive = true;
|
||||
}
|
||||
|
||||
private function refreshModulePreview(): void
|
||||
{
|
||||
$this->previewFrameRefreshCounter++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function settingsWithDefaults(): array
|
||||
{
|
||||
return array_replace_recursive($this->defaultSettings(), $this->version->settings ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function defaultSettings(): array
|
||||
{
|
||||
return match ($this->version->type) {
|
||||
DisplayVersionType::VideoDisplay => [
|
||||
'qr_label' => 'Website',
|
||||
],
|
||||
DisplayVersionType::B2in => [
|
||||
'theme' => 'dark',
|
||||
'header_logo_url' => '../assets/b2in-logo-positive.svg',
|
||||
'header_claim' => 'Connecting Design & Property',
|
||||
'footer_url' => 'B2in.eu',
|
||||
'footer_name' => '',
|
||||
'footer_prefix' => 'by',
|
||||
'qr_url' => '',
|
||||
'transition' => [
|
||||
'type' => 'crossfade',
|
||||
'duration_ms' => 800,
|
||||
],
|
||||
'default_image_duration' => 10,
|
||||
],
|
||||
DisplayVersionType::Offers => [
|
||||
'loop' => true,
|
||||
'logo_url' => '../logo-cabinet-300.png',
|
||||
'brand_text' => 'Bielefeld',
|
||||
'footer_claim' => '',
|
||||
'footer_url' => '',
|
||||
'qr_default_title' => 'Kontakt',
|
||||
'qr_subtitle' => 'QR scannen',
|
||||
'transition' => [
|
||||
'type' => 'fade',
|
||||
'duration' => 600,
|
||||
],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$items = $this->version->items()->get()->groupBy('item_type');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue