Files
nuhodds_fi4/resources/views/livewire/board-dispatcher.blade.php
T
2026-09-05 16:15:18 +02:00

157 lines
8.0 KiB
PHP

<div class="h-full p-1" x-data="{ activeTab: '{{ collect(array_keys($lists))->first(fn($key) => str_starts_with($key, 'source-')) }}' }" id="dispatcher-board-root">
<!-- 🌟 SPLIT HEADER -->
<div class="flex items-center justify-between border-b border-gray-200 dark:border-gray-600 py-2 mb-4">
<div class="flex-1 overflow-x-auto min-w-0">
<x-filament::tabs>
@foreach ($lists as $listId => $items)
@if (str_starts_with($listId, 'source-'))
<x-filament::tabs.item :alpine-active="'activeTab === \'' . $listId . '\''" x-on:click="activeTab = '{{ $listId }}'"
wire:key="tab-button-{{ $listId }}" class="cursor-pointer">
<div class="flex items-center space-x-1.5 leading-none">
<span class="uppercase">{{ str_replace('source-', '', $listId) }}</span>
<span
class="inline-flex items-center justify-center px-1 py-0.5 text-[10px] font-mono font-bold bg-primary-500/10 text-primary-600 dark:text-primary-400 rounded-md">
{{ count($items) }}
</span>
</div>
</x-filament::tabs.item>
@endif
@endforeach
</x-filament::tabs>
</div>
<!-- RECHTE SEITE DES HEADERS: AKTIONEN -->
<div class="flex items-right space-x-2 pl-4 shrink-0" wire:key="modal-actions-right-side">
<!-- Copy-Button -->
<x-filament::button icon="heroicon-o-clipboard-document-list" size="md" tooltip="Copy"
x-on:click="$wire.resetBoard()" class="cursor-pointer" />
<!-- Calculate-Button -->
<x-filament::button icon="heroicon-o-calculator" size="md" tooltip="Calculate"
x-on:click="$wire.resetBoard()" class="cursor-pointer" />
<!-- Reset-Button -->
<x-filament::button icon="heroicon-o-arrow-path" size="md" tooltip="Reset"
x-on:click="$wire.resetBoard()" class="cursor-pointer" />
<!-- Schließen-Button -->
<x-filament::button icon="heroicon-o-x-mark" size="md" x-on:click="close()" tooltip="Close"
class="cursor-pointer" />
</div>
</div>
<!-- 🌟 SEKTION 1: SOURCES -->
<div>
@foreach ($lists as $listId => $items)
@if (str_starts_with($listId, 'source-'))
<div x-show="activeTab === '{{ $listId }}'" class="transition-all"
wire:key="tab-panel-{{ $listId }}">
<!-- Reiner HTML-Container mit Sortable-Klassenerkennung -->
<div id="{{ $listId }}" class="sortable-zone grid grid-cols-5 gap-2 space-y-1 min-h-12">
@foreach ($items as $item)
<x-filament::badge color="{{ $item['pcolor'] }}" data-id="{{ $item['id'] }}"
icon="phosphor-dots-six-vertical" icon-position="after"
wire:key="item-src-{{ $item['id'] }}-v-{{ $boardVersion }}"
class="flex items-center justify-between shadow-sm cursor-grab active:cursor-grabbing">
<span class="text-sm font-medium text-gray-900 dark:text-gray-100">{{ $item['name'] }}
<div class="text-xs">{{ $item['info'] }}</div>
</span>
</x-filament::badge>
@endforeach
</div>
</div>
@endif
@endforeach
</div>
<!-- 🌟 SEKTION 2: DESTINATIONS (21 BAYS) -->
<div class="mt-7">
<div class="rounded-2xl grid grid-cols-7 grid-rows-5 p-5 gap-2 bg-cover bg-center bg-no-repeat aspect-7/5 max-w-4xl"
style="background-image: url({{ asset('images/soccerfield-middle.jpg') }});">
@foreach ($lists as $listId => $items)
@if (str_starts_with($listId, 'dest-'))
<div class="rounded-xl flex flex-col bg-white/30 backdrop-blur-none drop-shadow-xl"
wire:key="box-{{ $listId }}">
<div class="font-bold text-md mx-auto">
{{-- {{ $destLabels[str_replace('dest-', '', $listId)] }} --}}
{{ array_shift($destLabels) }}
</div>
<!-- Reiner HTML-Container mit Sortable-Klassenerkennung -->
<div id="{{ $listId }}" class="sortable-zone flex-1 rounded-b-lg p-1">
@foreach ($items as $item)
<x-filament::badge color="{{ $item['pcolor'] }}" data-id="{{ $item['id'] }}"
tooltip="{{ $item['info'] }}" icon="phosphor-dots-six-vertical"
icon-position="after"
wire:key="item-dst-{{ $item['id'] }}-v-{{ $boardVersion }}"
class="m-0 p-2 w-full h-full cursor-grab active:cursor-grabbing hover:border-danger-500 transition-all">
<div class=" font-medium text-gray-900 dark:text-gray-100 flex-1 text-wrap my-1">
{{ $item['name'] }}
</div>
<div class=" flex flex-row gap-1 items-center justify-between">
<x-filament::icon-button icon="phosphor-x-circle" size="sm" color="gray"
wire:click="returnToOrigin('{{ $item['id'] }}', '{{ $listId }}')" />
{{ ucfirst(str_replace('source-', '', $item['origin'])) }}
</div>
</x-filament::badge>
@endforeach
</div>
</div>
@elseif (str_starts_with($listId, 'blind-'))
<div class=""></div>
@endif
@endforeach
</div>
</div>
</div>
<!-- 🌟 ZENTRALE AUTOMATISCHE INITIALISIERUNG NACH JEDEM RENDERING -->
@script
<script>
function setupSortableZones() {
document.querySelectorAll('.sortable-zone').forEach(el => {
// Falls für dieses Element bereits eine Instanz existiert, zerstören wir sie sauber vor dem Neuaufbau
if (el._sortableInstance) {
el._sortableInstance.destroy();
}
el._sortableInstance = new Sortable(el, {
group: {
name: 'master-board',
// Striktes Limit: Maximal 1 Kind-Element pro Box zulassen
put: function(to, from) {
if (from.el !== to.el) {
return to.el.children.length < 1;
}
return true;
}
},
animation: 150,
onEnd: function(evt) {
if (evt.from.id !== evt.to.id) {
// Triggert den Server-Call absolut fehlerfrei
$wire.call('moveItem', evt.item.getAttribute('data-id'), evt.from.id, evt.to
.id, evt.newIndex);
}
}
});
});
}
// Initialer Aufruf beim Laden
setupSortableZones();
// 💡 DER ENTSCHEIDENDE FIX: Jedes Mal, wenn Livewire das DOM nach einer Array-Änderung (Löschen/Verschieben) aktualisiert,
// binden wir SortableJS sofort wieder frisch an alle 25 Container an!
Livewire.hook('morph.updated', () => {
setupSortableZones();
});
</script>
@endscript