diff --git a/app/Livewire/BoardDispatcher.php b/app/Livewire/BoardDispatcher.php index f5ae18f5..eaeb97f3 100644 --- a/app/Livewire/BoardDispatcher.php +++ b/app/Livewire/BoardDispatcher.php @@ -8,9 +8,14 @@ use Livewire\Component; class BoardDispatcher extends Component { public array $lists = []; + public array $results = []; public array $destLabels = ['DR', 'MR', 'RW', 'DC', 'DM', 'MC', 'AM', 'SW', 'DC', 'DM', 'MC', 'AM', 'SM', 'ST', 'DC', 'DM', 'MC', 'AM', 'DL', 'ML', 'LM']; - public string $boardVersion = ''; + public bool $calculationDisabled = true; + public bool $copyDisabled = true; + public string $calculationColor = 'gray'; + public string $copyColor = 'gray'; + public function mount(array $filters) { @@ -28,6 +33,65 @@ class BoardDispatcher extends Component } } + public function setCalculationButton() + { + $count = 1; + for ($i = 1; $i <= 35; $i++) { + $bayKey = "dest-{$i}"; + + if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) { + $count++; + } + } + if ($count > 2) { + $this->calculationDisabled = false; + $this->calculationColor = 'info'; + } else { + $this->calculationDisabled = true; + $this->calculationColor = 'gray'; + } + } + + public function setCopyButton() + { + if (\count($this->results) > 0) { + $this->copyDisabled = false; + $this->copyColor = 'info'; + } else { + $this->copyDisabled = true; + $this->copyColor = 'gray'; + } + } + + public function calculate() + { + $this->results = []; + for ($i = 1; $i <= 35; $i++) { + $bayKey = "dest-{$i}"; + + if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) { + $this->results[] = $this->lists[$bayKey][0]; + } + } + + $this->setCopyButton(); + } + + public function copy() + { + $str = ''; + foreach ($this->results as $k => $result) { + $str .= ''; + $str .= ''; + $str .= ''; + $str .= ''; + $str .= ''; + } + $str .= '
' . $result['name'] . '' . $result['position'] . '' . number_format(mt_rand(1, 100) / 100, 2) . '
'; + $this->js("navigator.clipboard.writeText('{$str}')"); + } + + public function moveItem($itemId, $fromList, $toList, $newIndex) { $itemId = (string) $itemId; @@ -50,6 +114,7 @@ class BoardDispatcher extends Component foreach ($this->lists[$fromList] as $key => $item) { if ((string) $item['id'] === $itemId) { + $item['position'] = $this->positions($toList); $foundItem = $item; unset($this->lists[$fromList][$key]); $this->lists[$fromList] = array_values($this->lists[$fromList]); @@ -61,9 +126,21 @@ class BoardDispatcher extends Component array_splice($this->lists[$toList], $newIndex, 0, [$foundItem]); } + $this->setCalculationButton(); + $this->boardVersion = uniqid(); } + public function positions(string $pos) + { + $pos = (int) str_replace('dest-', '', $pos); + $options = [2 => 'DR', 4 => 'MR', 6 => 'RW', 9 => 'DC', 10 => 'DM', 11 => 'MC', 12 => 'AM', 15 => 'SW', 16 => 'DC', 17 => 'DM', 18 => 'MC', 19 => 'AM', 20 => 'SM', 21 => 'ST', 23 => 'DC', 24 => 'DM', 25 => 'MC', 26 => 'AM', 30 => 'DL', 32 => 'ML', 34 => 'LM']; + if (isset($options[$pos])) + return $options[$pos]; + else + return $pos; + } + public function returnToOrigin($itemId, $currentListId) { $itemId = (string) $itemId; @@ -102,6 +179,8 @@ class BoardDispatcher extends Component // } } + $this->setCalculationButton(); + $this->boardVersion = uniqid(); } @@ -133,6 +212,12 @@ class BoardDispatcher extends Component // Falls Sie die Javascript-Event/ignore-Logik nutzen, feuern wir das Refresh-Event: $this->dispatch('refreshBoard', lists: $this->lists); + + $this->results = []; + + $this->setCalculationButton(); + + $this->setCopyButton(); } public function render() diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index 3b783101..e37d25a3 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -106,13 +106,17 @@ class PlayerCalculator extends Component $name = $val['player_name']; $preferred_foot = $val['preferred_foot'] ?? '-'; - $everage_minutes = round($minues_played / $events_played) . ' min'; - if ($colorlevel > 1 && $events_played < $colorlevel) { - $ecolor = 'danger'; - } elseif ($events_played < $colorlevel * 2) { - $ecolor = 'info'; - } else { - $ecolor = 'success'; + $everage_minutes = 0; + $ecolor = ''; + if ($events_played) { + $everage_minutes = round($minues_played / $events_played) . ' min'; + if ($colorlevel > 1 && $events_played < $colorlevel) { + $ecolor = 'danger'; + } elseif ($events_played < $colorlevel * 2) { + $ecolor = 'info'; + } else { + $ecolor = 'success'; + } } $result[$origin][] = [ diff --git a/public/images/soccerfield-h.jpg b/public/images/soccerfield-h.jpg new file mode 100644 index 00000000..fb8ae012 Binary files /dev/null and b/public/images/soccerfield-h.jpg differ diff --git a/public/images/soccerfield-middle.png b/public/images/soccerfield-middle.png new file mode 100644 index 00000000..a8fbcb27 Binary files /dev/null and b/public/images/soccerfield-middle.png differ diff --git a/public/images/sw.png b/public/images/sw.png new file mode 100644 index 00000000..638ab0bf Binary files /dev/null and b/public/images/sw.png differ diff --git a/public/svg/sw.svg b/public/svg/sw.svg new file mode 100644 index 00000000..979d410b --- /dev/null +++ b/public/svg/sw.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/views/livewire/board-dispatcher.blade.php b/resources/views/livewire/board-dispatcher.blade.php index 333e2888..d754033b 100644 --- a/resources/views/livewire/board-dispatcher.blade.php +++ b/resources/views/livewire/board-dispatcher.blade.php @@ -8,13 +8,11 @@ @if (str_starts_with($listId, 'source-')) -
- {{ str_replace('source-', '', $listId) }} - - {{ count($items) }} - -
+ {{ str_replace('source-', '', $listId) }} + + + {{ count($items) }} +
@endif @endforeach @@ -25,11 +23,11 @@ + :disabled="$copyDisabled" class="cursor-pointer" color="{{ $copyColor }}" x-on:click="$wire.copy()" /> - + -
-
+
+
@foreach ($lists as $listId => $items) @if (str_starts_with($listId, 'dest-')) -
-
- {{-- {{ $destLabels[str_replace('dest-', '', $listId)] }} --}} - {{ array_shift($destLabels) }} +
+ {{ $pos = array_shift($destLabels) }}
-
+
@foreach ($items as $item) - - -
+ class="static m-1 pt-4 text-sm cursor-grab active:cursor-grabbing transition-all"> + + + {{ ucfirst(str_replace('source-', '', $item['origin'])) }} + +
{{ $item['name'] }}
- -
- - {{ ucfirst(str_replace('source-', '', $item['origin'])) }} -
- - +
@endforeach
@@ -108,8 +103,27 @@ @endif @endforeach
+
+
+ @foreach ($results as $k => $result) + @if ($k < 11) + + {{ $k + 1 }} + + @else + + {{ $k + 1 }} + + @endif + {{ $result['name'] }} + {{ $result['position'] ?? 'none' }} + {{ number_format(mt_rand(1, 100) / 100, 2) }} + @endforeach +
+
+
@script