wip
This commit is contained in:
1 parent
0d6181b393
commit
52a275324e
5 files changed
+79
-77
No files matched your search
@@ -25,6 +25,7 @@ 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 Illuminate\Support\HtmlString;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
@@ -39,6 +40,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
public array $sourceRecords = [];
|
||||
|
||||
public array $filters = [];
|
||||
public int $player_on_field_counter = 0;
|
||||
|
||||
// slider
|
||||
public float $x_value = 3;
|
||||
@@ -52,8 +54,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
|
||||
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 bool $rangeXDisabled = true;
|
||||
@@ -190,11 +190,8 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
$this->beschriftung[$i] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateXvalue()
|
||||
{
|
||||
$this->calculationChecker();
|
||||
$this->clearResultTable();
|
||||
}
|
||||
|
||||
public function getHeadingTable(): HtmlString
|
||||
@@ -232,10 +229,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
{
|
||||
return $table
|
||||
->headerActions([
|
||||
// FilamentView::registerRenderHook(
|
||||
// PanelsRenderHook::GLOBAL_SEARCH_AFTER,
|
||||
// fn (): View => view('filament.modals.position-abbreviation'),
|
||||
// );
|
||||
Action::make('close')
|
||||
->size(Size::Small)
|
||||
->tooltip('Close application')
|
||||
@@ -258,7 +251,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
->size(Size::Small)
|
||||
->tooltip('Remove all players from field')
|
||||
->icon('phosphor-arrows-clockwise')
|
||||
->action(fn() => $this->clearAll()),
|
||||
->action(fn() => $this->clearResultTable()),
|
||||
// Action::make('calculate')
|
||||
// ->hiddenLabel()
|
||||
// ->tooltip('Calculate expected values')
|
||||
@@ -271,7 +264,6 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
->hiddenLabel()
|
||||
->size(Size::Small)
|
||||
->icon('phosphor-copy')
|
||||
->disabled($this->copyDisabled)
|
||||
->action(fn() => $this->copyResult()),
|
||||
])
|
||||
/**
|
||||
@@ -331,6 +323,15 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
return;
|
||||
}
|
||||
|
||||
// when drag from field to field remove from prviouse field to prevent doubles
|
||||
foreach ($this->boxes as $k => $record) {
|
||||
if (count($record) && $record['id'] == (int) $player['id']) {
|
||||
$this->clearBox($k);
|
||||
$this->player_on_field_counter--;
|
||||
}
|
||||
}
|
||||
|
||||
// when drag from source remove from proviuse field
|
||||
foreach ($this->sourceRecords as $k => $record) {
|
||||
if ($record['id'] == (int) $player['id']) {
|
||||
if ($this->boxes[$boxNumber]) {
|
||||
@@ -339,36 +340,17 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
$this->boxes[$boxNumber] = $record;
|
||||
$this->sourceRecords[$k]['active'] = 1;
|
||||
$this->sourceRecords[$k]['position'] = $this->activeBoxes[$boxNumber];
|
||||
|
||||
$this->player_on_field_counter++;
|
||||
}
|
||||
}
|
||||
$this->calculationChecker();
|
||||
}
|
||||
|
||||
public function calculationChecker()
|
||||
{
|
||||
$count = 0;
|
||||
foreach ($this->sourceRecords as $record) {
|
||||
if (count($record)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if ($count >= 9) {
|
||||
$this->copyDisabled = false;
|
||||
$this->rangeXDisabled = false;
|
||||
|
||||
$this->calculateAspg();
|
||||
} else {
|
||||
$this->copyDisabled = true;
|
||||
$this->rangeXDisabled = true;
|
||||
|
||||
$this->clearAll();
|
||||
}
|
||||
$this->calculateAspg();
|
||||
}
|
||||
|
||||
public function updateLineup(?string $state)
|
||||
{
|
||||
$this->clearAll();
|
||||
$this->calculationChecker();
|
||||
$this->clearResultTable();
|
||||
|
||||
if (isset($this->lineupsMap[$state])) {
|
||||
$this->lineup = $this->lineupsMap[$state];
|
||||
@@ -393,14 +375,23 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
$this->boxes[$boxNumber] = [];
|
||||
$this->sourceRecords[$k]['position'] = '';
|
||||
$this->sourceRecords[$k]['active'] = 0;
|
||||
|
||||
$this->player_on_field_counter--;
|
||||
}
|
||||
}
|
||||
|
||||
$this->calculationChecker();
|
||||
foreach ($this->sourceRecords as $k => $record) {
|
||||
$this->sourceRecords[$k]['gls'] = '';
|
||||
$this->sourceRecords[$k]['fls'] = '';
|
||||
$this->sourceRecords[$k]['ofs'] = '';
|
||||
$this->sourceRecords[$k]['snt'] = '';
|
||||
$this->sourceRecords[$k]['tsh'] = '';
|
||||
$this->sourceRecords[$k]['crd'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function clearAll(): void
|
||||
public function clearResultTable(): void
|
||||
{
|
||||
for ($i = 1; $i <= 35; $i++) {
|
||||
$this->boxes[$i] = [];
|
||||
@@ -408,19 +399,21 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
foreach ($this->sourceRecords as $k => $record) {
|
||||
$this->sourceRecords[$k]['position'] = '';
|
||||
$this->sourceRecords[$k]['active'] = 0;
|
||||
$this->sourceRecords[$k]['gls'] = 0;
|
||||
$this->sourceRecords[$k]['fls'] = 0;
|
||||
$this->sourceRecords[$k]['ofs'] = 0;
|
||||
$this->sourceRecords[$k]['snt'] = 0;
|
||||
$this->sourceRecords[$k]['tsh'] = 0;
|
||||
$this->sourceRecords[$k]['crd'] = 0;
|
||||
$this->sourceRecords[$k]['gls'] = '';
|
||||
$this->sourceRecords[$k]['fls'] = '';
|
||||
$this->sourceRecords[$k]['ofs'] = '';
|
||||
$this->sourceRecords[$k]['snt'] = '';
|
||||
$this->sourceRecords[$k]['tsh'] = '';
|
||||
$this->sourceRecords[$k]['crd'] = '';
|
||||
}
|
||||
|
||||
$this->calculationChecker();
|
||||
$this->player_on_field_counter = 0;
|
||||
}
|
||||
|
||||
public function copyResult()
|
||||
{
|
||||
if ($this->player_on_field_counter < 10)
|
||||
return;
|
||||
// "id" => 787607
|
||||
// "name" => "Keno"
|
||||
// "preferred_foot" => "Right"
|
||||
@@ -439,7 +432,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
// "tsh" => 0
|
||||
// "crd" => 0
|
||||
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd'];
|
||||
$copystring = implode("\t", $header) . "\n";;
|
||||
$copystring = implode("\t", $header) . "\n";
|
||||
foreach ($this->sourceRecords as $row) {
|
||||
unset($row['id']);
|
||||
unset($row['player_position']);
|
||||
@@ -453,6 +446,17 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
|
||||
public function calculateAspg(): void
|
||||
{
|
||||
if ($this->player_on_field_counter < 10) {
|
||||
foreach ($this->sourceRecords as $k => $record) {
|
||||
$this->sourceRecords[$k]['gls'] = '';
|
||||
$this->sourceRecords[$k]['fls'] = '';
|
||||
$this->sourceRecords[$k]['ofs'] = '';
|
||||
$this->sourceRecords[$k]['snt'] = '';
|
||||
$this->sourceRecords[$k]['tsh'] = '';
|
||||
$this->sourceRecords[$k]['crd'] = '';
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Calcolare Aspettativa Team per GOALS
|
||||
// (il valore che appare quando viene selezionato un Evento): nell' esempio,
|
||||
// se scegliamo come Team il Remo (Home) il valore di riferimento sarà 1.2
|
||||
|
||||
Reference in new issue
Block a user