This commit is contained in:
salam committed 2026-09-05 07:36:26 +02:00
1 parent 2e829b984f
commit c2e0e0b89b
18 files changed
+343 -246

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
<?php
namespace App\Livewire;
use Livewire\Component;
class BoardDispatcher extends Component
{
public array $lists = [];
public function mount()
{
$this->lists['source-attack'] = [
['id' => '1', 'name' => 'Source Item A', 'origin' => 'source-attack'],
['id' => '2', 'name' => 'Source Item B', 'origin' => 'source-attack'],
];
$this->lists['source-midfield'] = [
['id' => '3', 'name' => 'Source Item C', 'origin' => 'source-midfield'],
];
$this->lists['source-defence'] = [
['id' => '4', 'name' => 'Source Item D', 'origin' => 'source-defence'],
['id' => '5', 'name' => 'Source Item E', 'origin' => 'source-defence'],
];
$this->lists['source-goalkeeper'] = [
['id' => '6', 'name' => 'Source Item F', 'origin' => 'source-goalkeeper'],
];
for ($i = 1; $i <= 21; $i++) {
$this->lists["dest-{$i}"] = [];
}
}
public function moveItem($itemId, $fromList, $toList, $newIndex)
{
$itemId = (string) $itemId;
$newIndex = (int) $newIndex;
// Abbrechen falls kein Ziel vorhanden ist oder die Position unverändert blieb
if (! $toList || $fromList === $toList) {
return;
}
$foundItem = null;
// 1. Element aus der alten Liste entfernen
if (isset($this->lists[$fromList])) {
foreach ($this->lists[$fromList] as $key => $item) {
if ((string) $item['id'] === $itemId) {
$foundItem = $item;
unset($this->lists[$fromList][$key]);
$this->lists[$fromList] = array_values($this->lists[$fromList]); // Array-Keys korrigieren
break;
}
}
}
// 2. Element in die neue Zielliste am exakten Index einfügen
if ($foundItem && isset($this->lists[$toList])) {
array_splice($this->lists[$toList], $newIndex, 0, [$foundItem]);
}
}
public function returnToOrigin($itemId, $currentListId)
{
$itemId = (string) $itemId;
if (! isset($this->lists[$currentListId])) {
return;
}
$foundItem = null;
foreach ($this->lists[$currentListId] as $key => $item) {
if ((string) $item['id'] === $itemId) {
$foundItem = $item;
unset($this->lists[$currentListId][$key]);
$this->lists[$currentListId] = array_values($this->lists[$currentListId]);
break;
}
}
if ($foundItem && isset($this->lists[$foundItem['origin']])) {
array_unshift($this->lists[$foundItem['origin']], $foundItem);
}
}
public function render()
{
return view('livewire.board-dispatcher');
}
}
+6 -4
View File
@@ -106,7 +106,7 @@ class PlayerCalculator extends Component
$name = $val['player_name'];
$preferred_foot = $val['preferred_foot'] ?? '-';
$everage_minutes = round($minues_played / $events_played) . ' min';
$everage_minutes = round($minues_played / $events_played).' min';
if ($colorlevel > 1 && $events_played < $colorlevel) {
$color = 'danger';
} elseif ($events_played < $colorlevel * 2) {
@@ -119,12 +119,14 @@ class PlayerCalculator extends Component
'player_id' => $player_id,
'player_name' => $name,
'position' => $position,
'position_color' => $position_color,
'color' => $color,
'info' => 'Ev ' . $events_played . ', ' . $preferred_foot . ', ' . $everage_minutes,
'type_color' => $position_color,
'event_color' => $color,
'info' => 'Ev '.$events_played.', '.$preferred_foot.', '.$everage_minutes,
];
}
// dd($result);
return $result;
}
}