wip
This commit is contained in:
1 parent
217636b564
commit
3ec2c18fed
7 files changed
+153
-40
No files matched your search
@@ -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 = '<table>';
|
||||
foreach ($this->results as $k => $result) {
|
||||
$str .= '<tr>';
|
||||
$str .= '<td>' . $result['name'] . '</td>';
|
||||
$str .= '<td>' . $result['position'] . '</td>';
|
||||
$str .= '<td>' . number_format(mt_rand(1, 100) / 100, 2) . '</td>';
|
||||
$str .= '</tr>';
|
||||
}
|
||||
$str .= '</table>';
|
||||
$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()
|
||||
|
||||
@@ -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][] = [
|
||||
|
||||
Reference in new issue
Block a user