diff --git a/app/Console/Commands/Grap.php b/app/Console/Commands/Grap.php index db1dc631..d13f5465 100644 --- a/app/Console/Commands/Grap.php +++ b/app/Console/Commands/Grap.php @@ -69,7 +69,7 @@ class Grap extends Command SetStorage::set(1); // MoveToArchive::move(1); - // with m just resend + // with --m just resend mail if (!self::$options['m']) { Grapper::load(1); MakeExcel::create(); @@ -87,26 +87,21 @@ class Grap extends Command case 3: // RANGE SetStorage::set(3); - Grapper::load(3); - MakeExcel::create(); break; case 4: // ROSE - SetStorage::set(4); - Rose::run(); - MakeExcel::create(); break; case 5: SetStorage::set(5); - MakeExcel::create(); + break; case 6: PlayerPerSeason::run(); diff --git a/app/Livewire/BoardDispatcher.php b/app/Livewire/BoardDispatcher.php index b232b803..461c49c3 100644 --- a/app/Livewire/BoardDispatcher.php +++ b/app/Livewire/BoardDispatcher.php @@ -2,224 +2,337 @@ namespace App\Livewire; +use App\Models\SofaScoreRosa; +use Filament\Actions\Action; +use Filament\Actions\Concerns\InteractsWithActions; +use Filament\Actions\Contracts\HasActions; +use Filament\Schemas\Concerns\InteractsWithSchemas; +use Filament\Schemas\Concerns\RestrictsFileUploadsToSchemaComponents; +use Filament\Schemas\Contracts\HasSchemas; +use Filament\Tables\Columns\ViewColumn; +use Filament\Tables\Concerns\InteractsWithTable; +use Filament\Tables\Contracts\HasTable; +use Filament\Tables\Enums\FiltersLayout; +use Filament\Tables\Filters\SelectFilter; +use Filament\Tables\Table; use Illuminate\Support\Facades\Log; +use Livewire\Attributes\On; use Livewire\Component; -class BoardDispatcher extends Component +class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTable { + + use InteractsWithActions; + use InteractsWithSchemas; + use InteractsWithTable; + use RestrictsFileUploadsToSchemaComponents; + + public array $sourceRecords = []; 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 array $activeBoxes = [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']; public bool $copyDisabled = true; public bool $calculationDisabled = true; public string $calculationColor = 'gray'; public string $copyColor = 'gray'; + public string $ss_team_name = ''; + + public array $boxes = []; + public array $beschriftung = []; public function mount(array $filters) { - $this->boardVersion = uniqid(); + $this->ss_team_name = SofaScoreRosa::where('ss_team_id', $filters['team_id'])->value('ss_team_name'); - $this->lists = PlayerCalculator::load($filters); - - $active = [2, 4, 6, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 30, 32, 34]; + $this->sourceRecords = PlayerCalculator::load($filters); for ($i = 1; $i <= 35; $i++) { - if (in_array($i, $active)) - $this->lists["dest-{$i}"] = []; + $this->boxes[$i] = []; + if (isset($this->activeBoxes[$i])) + $this->beschriftung[$i] = $this->activeBoxes[$i]; else - $this->lists["blind-{$i}"] = []; + $this->beschriftung[$i] = ''; } + + Log::debug('boxes', $this->boxes); } - public function setCalculationButton() + public function table(Table $table): Table { - $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 copyResult() - { - $copystring = ''; - foreach ($this->results as $row) { - unset($row['origin']); - unset($row['pcolor']); - unset($row['ecolor']); - unset($row['info']); - $copystring .= implode("\t", $row) . "\n"; - } - $this->js("navigator.clipboard.writeText(`$copystring`)"); - } - - - public function moveItem($itemId, $fromList, $toList, $newIndex) - { - $itemId = (string) $itemId; - $newIndex = (int) $newIndex; - - if (! $toList || $fromList === $toList || ! isset($this->lists[$fromList]) || ! isset($this->lists[$toList])) { - $this->boardVersion = uniqid(); - - return; - } - - // Limit-Guard: Wenn das Ziel bereits ein Element enthält, abbrechen - if (count($this->lists[$toList]) >= 1) { - $this->boardVersion = uniqid(); - - return; - } - - $foundItem = null; - - 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]); - break; - } - } - - if ($foundItem) { - 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; - - // Log::info($this->boardVersion); - // Log::info('itemId, currentListId', [$itemId, $currentListId]); - // Log::info('OLD LIST', $this->lists); - - if (! isset($this->lists[$currentListId])) { - $this->boardVersion = uniqid(); - - 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']])) { - // Nur zurücklegen, wenn die Quelle wirklich frei ist - array_unshift($this->lists[$foundItem['origin']], $foundItem); - // if (count($this->lists[$foundItem['origin']]) < 2) { - // Log::info('origin'); - // array_unshift($this->lists[$foundItem['origin']], $foundItem); - // } else { - // // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben - // array_unshift($this->lists[$currentListId], $foundItem); - // Log::info('box'); - // } - } - - $this->setCalculationButton(); - - $this->boardVersion = uniqid(); - } - - public function resetBoard() - { - // Alle 21 Zielbays durchlaufen - for ($i = 1; $i <= 21; $i++) { - $bayKey = "dest-{$i}"; - - if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) { - foreach ($this->lists[$bayKey] as $item) { - $targetOrigin = $item['origin']; - - // Element zurück in sein Original-Quell-Tab schieben - if (isset($this->lists[$targetOrigin])) { - array_unshift($this->lists[$targetOrigin], $item); - } + return $table + ->headerActions([ + Action::make('close')->icon('phosphor-x')->close(), + Action::make('reset')->icon('phosphor-arrows-clockwise'), + Action::make('calculate')->icon('phosphor-calculator')->color('gray'), + Action::make('download')->icon('phosphor-download')->color('gray'), + ]) + /** + * WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein + * leeres Modell (z.B. ein beliebiges Basis-Modell deines Projekts) NUR als Dummy-Builder. + * Alternativ kannst du ein anonymes Model nutzen. + */ + ->query(\App\Models\User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen + ->paginated(false) + // ->striped() + ->defaultSort('name') + ->columns([ + ViewColumn::make('drag_card') + ->columnSpanFull() + ->label('Roster of ' . $this->ss_team_name) + ->view('filament.tables.columns.drag-card'), + ]) + ->filters([ + SelectFilter::make('player_position') + ->columnSpanFull() + ->options([ + 'attack' => 'Attack', + 'midfield' => 'Midfield', + 'defence' => 'Defence', + 'goalkeeper' => 'Goalkeeper', + ]) + ->query(function ($query, array $data) { + return $query; + }), + ], layout: FiltersLayout::AboveContent) + ->deferFilters(false) + ->records(function () { + $collection = collect($this->sourceRecords); + $selectedPosition = $this->tableFilters['player_position']['value'] ?? null; + if (!empty($selectedPosition)) { + $collection = $collection->where('player_position', $selectedPosition); } + return $collection; + }); + } - // Die Zielbucht komplett leeren - $this->lists[$bayKey] = []; + #[On('element-dropped-in-box')] + public function handleElementDropped(mixed $elementData, mixed $boxNumber): void + { + $boxNumber = (int) $boxNumber; + $player = is_array($elementData) ? $elementData : json_decode($elementData, true); + + if (!$player || !isset($player['id'])) { + return; + } + + foreach ($this->sourceRecords as $k => $record) { + if ($record['id'] == (int) $player['id']) { + if ($this->boxes[$boxNumber]) { + $this->clearBox($boxNumber); + } + $this->boxes[$boxNumber] = $record; + $this->sourceRecords[$k]['active'] = 1; } } + } - // Falls Sie die boardVersion-Logik nutzen, erneuern wir sie hier für den DOM-Refresh: - if (property_exists($this, 'boardVersion')) { - $this->boardVersion = uniqid(); + public function clearBox(int $boxNumber): void + { + if (isset($this->boxes[$boxNumber])) { + $tmp = $this->boxes[$boxNumber]; + $player_id = 0; + foreach ($tmp as $key => $value) { + if ($key == 'id') + $player_id = $value; + } + foreach ($this->sourceRecords as $k => $record) { + if ($record['id'] == (int) $player_id) { + $this->boxes[$boxNumber] = []; + $this->sourceRecords[$k]['active'] = 0; + } + } } - - // 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() { return view('livewire.board-dispatcher'); } + + + // 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 copyResult() + // { + // $copystring = ''; + // foreach ($this->results as $row) { + // unset($row['origin']); + // unset($row['pcolor']); + // unset($row['ecolor']); + // unset($row['info']); + // $copystring .= implode("\t", $row) . "\n"; + // } + // $this->js("navigator.clipboard.writeText(`$copystring`)"); + // } + + + // public function moveItem($itemId, $fromList, $toList, $newIndex) + // { + // $itemId = (string) $itemId; + // $newIndex = (int) $newIndex; + + // if (! $toList || $fromList === $toList || ! isset($this->lists[$fromList]) || ! isset($this->lists[$toList])) { + // $this->boardVersion = uniqid(); + + // return; + // } + + // // Limit-Guard: Wenn das Ziel bereits ein Element enthält, abbrechen + // if (count($this->lists[$toList]) >= 1) { + // $this->boardVersion = uniqid(); + + // return; + // } + + // $foundItem = null; + + // 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]); + // break; + // } + // } + + // if ($foundItem) { + // 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; + + // // Log::info($this->boardVersion); + // // Log::info('itemId, currentListId', [$itemId, $currentListId]); + // // Log::info('OLD LIST', $this->lists); + + // if (! isset($this->lists[$currentListId])) { + // $this->boardVersion = uniqid(); + + // 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']])) { + // // Nur zurücklegen, wenn die Quelle wirklich frei ist + // array_unshift($this->lists[$foundItem['origin']], $foundItem); + // // if (count($this->lists[$foundItem['origin']]) < 2) { + // // Log::info('origin'); + // // array_unshift($this->lists[$foundItem['origin']], $foundItem); + // // } else { + // // // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben + // // array_unshift($this->lists[$currentListId], $foundItem); + // // Log::info('box'); + // // } + // } + + // $this->setCalculationButton(); + + // $this->boardVersion = uniqid(); + // } + + // public function resetBoard() + // { + // // Alle 21 Zielbays durchlaufen + // for ($i = 1; $i <= 21; $i++) { + // $bayKey = "dest-{$i}"; + + // if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) { + // foreach ($this->lists[$bayKey] as $item) { + // $targetOrigin = $item['origin']; + + // // Element zurück in sein Original-Quell-Tab schieben + // if (isset($this->lists[$targetOrigin])) { + // array_unshift($this->lists[$targetOrigin], $item); + // } + // } + + // // Die Zielbucht komplett leeren + // $this->lists[$bayKey] = []; + // } + // } + + // // Falls Sie die boardVersion-Logik nutzen, erneuern wir sie hier für den DOM-Refresh: + // if (property_exists($this, 'boardVersion')) { + // $this->boardVersion = uniqid(); + // } + + // // 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(); + // } } diff --git a/app/Livewire/PlayerCalculator.php b/app/Livewire/PlayerCalculator.php index 9a550177..a6d22aa6 100644 --- a/app/Livewire/PlayerCalculator.php +++ b/app/Livewire/PlayerCalculator.php @@ -88,62 +88,50 @@ class PlayerCalculator extends Component $colorlevel = round($matches->count() / 3); if (in_array($val['player_position'], $positions_map['MIDFIELD'])) { - $origin = 'source-midfield'; - $pcolor = 'info'; + $player_position = 'midfield'; + $player_color = 'info'; } elseif (in_array($val['player_position'], $positions_map['DEFENCE'])) { - $origin = 'source-defence'; - $pcolor = 'success'; + $player_position = 'defence'; + $player_color = 'success'; } elseif (in_array($val['player_position'], $positions_map['ATTACK'])) { - $origin = 'source-attack'; - $pcolor = 'warning'; + $player_position = 'attack'; + $player_color = 'warning'; } elseif (in_array($val['player_position'], $positions_map['GOALKEEPER'])) { - $origin = 'source-goalkeeper'; - $pcolor = 'gray'; + $player_position = 'goalkeeper'; + $player_color = 'gray'; } else { - $origin = 'NO SPECIFIC POSITION'; - $pcolor = ''; + $player_position = 'NO SPECIFIC POSITION'; + $player_color = 'danger'; } - $name = $val['player_name']; - $preferred_foot = $val['preferred_foot'] ?? '-'; $everage_minutes = 0; - $ecolor = ''; + $timed_color = ''; if ($events_played) { $everage_minutes = round($minues_played / $events_played); if ($colorlevel > 1 && $events_played < $colorlevel) { - $ecolor = 'danger'; + $timed_color = 'danger'; } elseif ($events_played < $colorlevel * 2) { - $ecolor = 'info'; + $timed_color = 'info'; } else { - $ecolor = 'success'; + $timed_color = 'success'; } } - $info = []; - if ($events_played == 1) { - $info[] = '1 Event'; - } else if ($events_played > 1) { - $info[] = $events_played . ' Events'; - } else { - $info[] = 'None'; - } - if ($preferred_foot) { - $info[] = $preferred_foot . ' Foot'; - } - if ($everage_minutes) { - $info[] = ' Ø ' . $everage_minutes . 'min'; - } - - $result[$origin][] = [ + $result[] = [ 'id' => $player_id, - 'name' => $name, - 'origin' => $origin, - 'pcolor' => $pcolor, - 'ecolor' => $ecolor, - 'info' => implode(', ', $info), + 'name' => $val['player_name'], + 'preferred_foot' => $val['preferred_foot'], + 'player_position' => $player_position, + 'player_color' => $player_color, + 'timed_color' => $timed_color, + 'events_played' => $events_played, + 'everage_minutes' => $everage_minutes, + 'active' => 0, ]; } + $sort = array_column($result, 'player_position'); + return $result; } } diff --git a/app/Livewire/backup.txt b/app/Livewire/backup.txt new file mode 100644 index 00000000..13e22cc3 --- /dev/null +++ b/app/Livewire/backup.txt @@ -0,0 +1,284 @@ +boardVersion = uniqid(); + + $this->filters = $filters; + + $active = [2, 4, 6, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 30, 32, 34]; + + for ($i = 1; $i <= 35; $i++) { + if (in_array($i, $active)) + $this->lists["dest-{$i}"] = []; + else + $this->lists["blind-{$i}"] = []; + } + } + + /* + 'id' => $player_id, + 'name' => $val['player_name'], + 'preferred_foot' => $val['preferred_foot'], + 'player_position' => $player_position, + 'player_color' => $player_color, + 'timed_color' => $timed_color, + 'events_played' => $events_played, + 'everage_minutes' => $everage_minutes, + */ + public function table(Table $table): Table + { + return $table + ->headerActions([ + Action::make('Close')->icon('phosphor-x')->close() + ]) + ->records(fn(): array => PlayerCalculator::load($this->filters)) + ->paginated(false) + ->striped() + ->columns([ + TextColumn::make('name') + ->sortable() + // ->searchable() + ->icon('icon-soccerplayer') + ->extraAttributes(fn($record) => [ + 'data-id' => $record['id'], + 'class' => 'sortable-zone', + 'style' => 'padding: 4px !important; cursor:pointer; user-select: none;', + 'wire:key' => "item-src-" . $record['id'] . "-v-" . $this->boardVersion + ]), + ]) + ->filters([ + // ... + ]) + ->recordActions([ + // ... + ]) + ->toolbarActions([ + // ... + ]); + } + + public function render() + { + return view('livewire.board-dispatcher'); + } + + + 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 copyResult() + { + $copystring = ''; + foreach ($this->results as $row) { + unset($row['origin']); + unset($row['pcolor']); + unset($row['ecolor']); + unset($row['info']); + $copystring .= implode("\t", $row) . "\n"; + } + $this->js("navigator.clipboard.writeText(`$copystring`)"); + } + + + public function moveItem($itemId, $fromList, $toList, $newIndex) + { + $itemId = (string) $itemId; + $newIndex = (int) $newIndex; + + if (! $toList || $fromList === $toList || ! isset($this->lists[$fromList]) || ! isset($this->lists[$toList])) { + $this->boardVersion = uniqid(); + + return; + } + + // Limit-Guard: Wenn das Ziel bereits ein Element enthält, abbrechen + if (count($this->lists[$toList]) >= 1) { + $this->boardVersion = uniqid(); + + return; + } + + $foundItem = null; + + 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]); + break; + } + } + + if ($foundItem) { + 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; + + // Log::info($this->boardVersion); + // Log::info('itemId, currentListId', [$itemId, $currentListId]); + // Log::info('OLD LIST', $this->lists); + + if (! isset($this->lists[$currentListId])) { + $this->boardVersion = uniqid(); + + 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']])) { + // Nur zurücklegen, wenn die Quelle wirklich frei ist + array_unshift($this->lists[$foundItem['origin']], $foundItem); + // if (count($this->lists[$foundItem['origin']]) < 2) { + // Log::info('origin'); + // array_unshift($this->lists[$foundItem['origin']], $foundItem); + // } else { + // // Ausfallsicherheit gegen Datenverlust: Zurück in die Bucht schieben + // array_unshift($this->lists[$currentListId], $foundItem); + // Log::info('box'); + // } + } + + $this->setCalculationButton(); + + $this->boardVersion = uniqid(); + } + + public function resetBoard() + { + // Alle 21 Zielbays durchlaufen + for ($i = 1; $i <= 21; $i++) { + $bayKey = "dest-{$i}"; + + if (isset($this->lists[$bayKey]) && ! empty($this->lists[$bayKey])) { + foreach ($this->lists[$bayKey] as $item) { + $targetOrigin = $item['origin']; + + // Element zurück in sein Original-Quell-Tab schieben + if (isset($this->lists[$targetOrigin])) { + array_unshift($this->lists[$targetOrigin], $item); + } + } + + // Die Zielbucht komplett leeren + $this->lists[$bayKey] = []; + } + } + + // Falls Sie die boardVersion-Logik nutzen, erneuern wir sie hier für den DOM-Refresh: + if (property_exists($this, 'boardVersion')) { + $this->boardVersion = uniqid(); + } + + // 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(); + } +} diff --git a/resources/views/filament/tables/columns/drag-card.blade.php b/resources/views/filament/tables/columns/drag-card.blade.php new file mode 100644 index 00000000..7cb9edf1 --- /dev/null +++ b/resources/views/filament/tables/columns/drag-card.blade.php @@ -0,0 +1,71 @@ +@php + $record = $getRecord(); + /* + 'id' => $player_id, + 'name' => $val['player_name'], + 'preferred_foot' => $val['preferred_foot'], + 'player_position' => $player_position, + 'player_color' => $player_color, + 'timed_color' => $timed_color, + 'events_played' => $events_played, + 'everage_minutes' => $everage_minutes, + */ +@endphp +@if ($record['active']) +
+
+ + {{ strtoupper($record['player_position']) }} + +
+
+ {{ $record['name'] }} +
+
+ {{ $record['preferred_foot'] }}, + Ev {{ $record['events_played'] }}, + Av {{ $record['everage_minutes'] }}min +
+
+ +
+
Goal: 0.13
+
Card: 0.41
+
Foul: 0.41
+
Goal: 0.13
+
Card: 0.41
+
Foul: 0.41
+
+@else +
+
+ + {{ strtoupper($record['player_position']) }} + +
+
+ {{ $record['name'] }} +
+
+ {{ $record['preferred_foot'] }}, + Ev {{ $record['events_played'] }}, + Av {{ $record['everage_minutes'] }}min +
+
+ +
+
Goal: 0.13
+
Card: 0.41
+
Foul: 0.41
+
Goal: 0.13
+
Card: 0.41
+
Foul: 0.41
+
+@endif diff --git a/resources/views/livewire/board-dispatcher.blade.php b/resources/views/livewire/board-dispatcher.blade.php index d0e88b9e..f5ccba18 100644 --- a/resources/views/livewire/board-dispatcher.blade.php +++ b/resources/views/livewire/board-dispatcher.blade.php @@ -1,172 +1,52 @@ -
- - -
-
- - @foreach ($lists as $listId => $items) - @if (str_starts_with($listId, 'source-')) - - {{ str_replace('source-', '', $listId) }} - - {{ count($items) }} - - - @endif - @endforeach - -
- -
- - - - - - - - - - - - -
+@php + use Illuminate\Support\Facades\Log; +@endphp +
+
+ {{ $this->table }}
- - -
- @foreach ($lists as $listId => $items) - @if (str_starts_with($listId, 'source-')) -
- - -
- @foreach ($items as $item) - -
{{ $item['name'] }} -
- - {{ $item['info'] }} - -
- @endforeach -
-
- @endif - @endforeach -
- - -
-
- @foreach ($lists as $listId => $items) - @if (str_starts_with($listId, 'dest-')) -
+
+
+ @foreach ($beschriftung as $boxNumber => $benennung) + @if ($benennung) +
+
- {{ $pos = array_shift($destLabels) }} + class="flex justify-between items-center border-b border-gray-100 dark:border-gray-800 p-1"> +
+ {{ $benennung }} +
+ + @if ($boxes[$boxNumber]) + + @endif
- -
- - @foreach ($items as $item) -
- - - {{ ucfirst(str_replace('source-', '', $item['origin'])) }} - -
- {{ $item['name'] }} -
-
- @endforeach -
+ + @if ($boxes[$boxNumber]) +
+ {{ $boxes[$boxNumber]['name'] }} +
+ @endif
- @elseif (str_starts_with($listId, 'blind-')) -
+ @else +
@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 - -@endscript diff --git a/resources/views/livewire/kanban-board.blade.php b/resources/views/livewire/kanban-board.blade.php new file mode 100644 index 00000000..b88bbf2e --- /dev/null +++ b/resources/views/livewire/kanban-board.blade.php @@ -0,0 +1,103 @@ + + +
+ + +
+
+

Elemente-Kopierer (v5)

+

Ziehe einen Eintrag aus der Tabelle. Das Ziel-Modal + öffnet sich synchron beim Ziehen.

+
+ + + Slots manuell öffnen (21 Boxen) + +
+ + +
+ {{ $this->table }} +
+ + + + +
+ + Ziel-Matrix (21 Slots) +
+
+ + + Lass das gezogene Element über der gewünschten Box los, um eine Kopie zuzuweisen. + + + +
+ @foreach ($boxes as $boxNumber => $items) +
+ +
+ + Box {{ $boxNumber }} + + + @if (count($items) > 0) + + @endif +
+ + +
+ @forelse($items as $item) +
+ + {{ $item['title'] }} + + ID: + {{ $item['id'] }} +
+ @empty +
+ Bereit +
+ @endforelse +
+
+ @endforeach +
+ + +
+ + Schließen + +
+
+
+ +
+