wip
This commit is contained in:
1 parent
ac536fd10b
commit
a05637d33d
4 files changed
+202
-73
No files matched your search
@@ -7,15 +7,16 @@ use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Concerns\RestrictsFileUploadsToSchemaComponents;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
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\Forms\Components\Select;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -43,8 +44,114 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
|
||||
public string $ss_team_name = '';
|
||||
|
||||
public array $lineups = [3331 => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21]];
|
||||
public array $lineup = [2, 9, 23, 30, 10, 24, 12, 19, 26, 21];
|
||||
public array $lineupsMap = [
|
||||
'3313' => [9, 16, 23, 11, 18, 25, 19, 6, 34, 21],
|
||||
'3331' => [9, 16, 23, 17, 11, 25, 12, 19, 26, 21],
|
||||
'3331-' => [9, 16, 23, 10, 18, 24, 12, 19, 26, 21],
|
||||
'3331+' => [9, 16, 23, 11, 18, 25, 12, 19, 26, 21],
|
||||
'3412-' => [9, 16, 23, 4, 10, 24, 32, 19, 20, 21],
|
||||
'3412+' => [9, 16, 23, 4, 11, 25, 32, 19, 20, 21],
|
||||
'3421-' => [9, 16, 23, 4, 10, 24, 32, 12, 26, 21],
|
||||
'3421+' => [9, 16, 23, 4, 11, 25, 32, 12, 26, 21],
|
||||
'343-' => [9, 16, 23, 4, 10, 24, 32, 6, 34, 21],
|
||||
'343+' => [9, 16, 23, 4, 11, 25, 32, 6, 34, 21],
|
||||
'3511' => [9, 16, 23, 4, 11, 17, 25, 32, 19, 21],
|
||||
'3511-' => [9, 16, 23, 4, 10, 18, 24, 32, 19, 21],
|
||||
'3511+' => [9, 16, 23, 4, 11, 18, 25, 32, 19, 21],
|
||||
'352' => [9, 16, 23, 4, 11, 17, 25, 32, 20, 21],
|
||||
'352-' => [9, 16, 23, 4, 10, 18, 24, 32, 20, 21],
|
||||
'352+' => [9, 16, 23, 4, 11, 18, 25, 32, 20, 21],
|
||||
'4132' => [2, 9, 23, 30, 17, 12, 19, 26, 20, 21],
|
||||
'4213-' => [2, 9, 23, 30, 10, 24, 19, 6, 34, 21],
|
||||
'4213+' => [2, 9, 23, 30, 11, 25, 19, 6, 34, 21],
|
||||
'4222' => [2, 9, 23, 30, 10, 24, 12, 26, 20, 21],
|
||||
'4231' => [2, 9, 23, 30, 10, 24, 12, 19, 26, 21],
|
||||
'424' => [2, 9, 23, 30, 10, 24, 6, 34, 20, 21],
|
||||
'4312' => [2, 9, 23, 30, 17, 11, 25, 19, 20, 21],
|
||||
'4312-' => [2, 9, 23, 30, 10, 18, 24, 19, 20, 21],
|
||||
'4312+' => [2, 9, 23, 30, 11, 18, 25, 19, 20, 21],
|
||||
'4321' => [2, 9, 23, 30, 17, 11, 25, 12, 26, 21],
|
||||
'4321-' => [2, 9, 23, 30, 10, 18, 24, 12, 26, 21],
|
||||
'4321+' => [2, 9, 23, 30, 11, 18, 25, 12, 26, 21],
|
||||
'433' => [2, 9, 23, 30, 17, 11, 25, 6, 34, 21],
|
||||
'433-' => [2, 9, 23, 30, 10, 18, 24, 6, 34, 21],
|
||||
'433+' => [2, 9, 23, 30, 11, 18, 25, 6, 34, 21],
|
||||
'4411-' => [2, 9, 23, 30, 4, 10, 24, 32, 19, 21],
|
||||
'4411+' => [2, 9, 23, 30, 4, 11, 25, 32, 19, 21],
|
||||
'442' => [2, 9, 23, 30, 4, 17, 18, 32, 20, 21],
|
||||
'442-' => [2, 9, 23, 30, 4, 10, 24, 32, 20, 21],
|
||||
'442+' => [2, 9, 23, 30, 4, 11, 25, 32, 20, 21],
|
||||
'451' => [2, 9, 23, 30, 4, 17, 11, 25, 32, 21],
|
||||
'451-' => [2, 9, 23, 30, 4, 10, 18, 24, 32, 21],
|
||||
'451+' => [2, 9, 23, 30, 4, 11, 18, 25, 32, 21],
|
||||
'523-' => [2, 9, 16, 23, 30, 10, 24, 6, 34, 21],
|
||||
'523+' => [2, 9, 16, 23, 30, 11, 25, 6, 34, 21],
|
||||
'5311' => [2, 9, 16, 23, 30, 17, 11, 25, 19, 21],
|
||||
'5311-' => [2, 9, 16, 23, 30, 10, 18, 24, 19, 21],
|
||||
'5311+' => [2, 9, 16, 23, 30, 11, 18, 25, 19, 21],
|
||||
'532' => [2, 9, 16, 23, 30, 17, 11, 25, 20, 21],
|
||||
'532-' => [2, 9, 16, 23, 30, 10, 18, 24, 20, 21],
|
||||
'532+' => [2, 9, 16, 23, 30, 11, 18, 25, 20, 21],
|
||||
'541-' => [2, 9, 16, 23, 30, 4, 10, 24, 32, 21],
|
||||
'541+' => [2, 9, 16, 23, 30, 4, 11, 25, 32, 21],
|
||||
];
|
||||
|
||||
public array $lineup = [];
|
||||
|
||||
public array $lineup_options = [
|
||||
'3313' => '3313',
|
||||
'3331' => '3331',
|
||||
'3331-' => '3331-',
|
||||
'3331+' => '3331+',
|
||||
'3412-' => '3412-',
|
||||
'3412+' => '3412+',
|
||||
'3421-' => '3421-',
|
||||
'3421+' => '3421+',
|
||||
'343-' => '343-',
|
||||
'343+' => '343+',
|
||||
'3511' => '3511',
|
||||
'3511-' => '3511-',
|
||||
'3511+' => '3511+',
|
||||
'352' => '352',
|
||||
'352-' => '352-',
|
||||
'352+' => '352+',
|
||||
'4132' => '4132',
|
||||
'4213-' => '4213-',
|
||||
'4213+' => '4213+',
|
||||
'4222' => '4222',
|
||||
'4231' => '4231',
|
||||
'424' => '424',
|
||||
'4312' => '4312',
|
||||
'4312-' => '4312-',
|
||||
'4312+' => '4312+',
|
||||
'4321' => '4321',
|
||||
'4321-' => '4321-',
|
||||
'4321+' => '4321+',
|
||||
'433' => '433',
|
||||
'433-' => '433-',
|
||||
'433+' => '433+',
|
||||
'4411-' => '4411-',
|
||||
'4411+' => '4411+',
|
||||
'442' => '442',
|
||||
'442-' => '442-',
|
||||
'442+' => '442+',
|
||||
'451' => '451',
|
||||
'451-' => '451-',
|
||||
'451+' => '451+',
|
||||
'523-' => '523-',
|
||||
'523+' => '523+',
|
||||
'5311' => '5311',
|
||||
'5311-' => '5311-',
|
||||
'5311+' => '5311+',
|
||||
'532' => '532',
|
||||
'532-' => '532-',
|
||||
'532+' => '532+',
|
||||
'541-' => '541-',
|
||||
'541+' => '541+',
|
||||
];
|
||||
|
||||
public string $lineup_selected = '3313';
|
||||
|
||||
public array $boxes = [];
|
||||
|
||||
public array $beschriftung = [];
|
||||
@@ -55,6 +162,8 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
|
||||
$this->sourceRecords = PlayerCalculator::load($filters);
|
||||
|
||||
$this->lineup = $this->lineupsMap[$this->lineup_selected];
|
||||
|
||||
for ($i = 1; $i <= 35; $i++) {
|
||||
$this->boxes[$i] = [];
|
||||
if (isset($this->activeBoxes[$i])) {
|
||||
@@ -69,7 +178,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
|
||||
public function getHeadingTable(): HtmlString
|
||||
{
|
||||
return new HtmlString('<div class="text-xl w-full">' . $this->ss_team_name . '</div>
|
||||
return new HtmlString('<div class="text-xl w-full">'.$this->ss_team_name.'</div>
|
||||
<div class="text-[11px] p-0 flex flex-row gap-4 font-bold font-mono" style="position: relative; left: -2px; bottom: -13px;">
|
||||
<div>Gls</div>
|
||||
<div>Fls</div>
|
||||
@@ -83,6 +192,25 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
</div>');
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(4)
|
||||
->components([
|
||||
Select::make('lineup_selected')
|
||||
->live()
|
||||
->hiddenLabel()
|
||||
->columnSpan(1)
|
||||
->prefix('Lineup')
|
||||
->prefixIcon('icon-soccerplayer')
|
||||
->searchable()
|
||||
->options($this->lineup_options)
|
||||
->afterStateUpdated(function ($state, $livewire) {
|
||||
$livewire->updateLineup($state);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -92,15 +220,15 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
->close(),
|
||||
Action::make('reset')
|
||||
->icon('phosphor-arrows-clockwise')
|
||||
->action(fn() => $this->clearAll()),
|
||||
->action(fn () => $this->clearAll()),
|
||||
Action::make('calculate')
|
||||
->icon('phosphor-calculator')
|
||||
->disabled($this->calculationDisabled)
|
||||
->action(fn() => $this->calculateAspg()),
|
||||
->action(fn () => $this->calculateAspg()),
|
||||
Action::make('copy')
|
||||
->icon('phosphor-copy')
|
||||
->disabled($this->copyDisabled)
|
||||
->action(fn() => $this->copyResult()),
|
||||
->action(fn () => $this->copyResult()),
|
||||
])
|
||||
/**
|
||||
* WICHTIG: Da Filament v5 zwingend eine Query braucht, nutzen wir ein
|
||||
@@ -108,14 +236,17 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
* Alternativ kannst du ein anonymes Model nutzen.
|
||||
*/
|
||||
->query(User::query()->whereRaw('1 = 0')) // Verhindert DB-Abfragen
|
||||
->paginated(false)
|
||||
->striped()
|
||||
->defaultSort('name')
|
||||
->columns([
|
||||
ViewColumn::make('drag_card')
|
||||
->columnSpanFull()
|
||||
->label(fn() => $this->getHeadingTable())
|
||||
->view('filament.tables.columns.drag-card'),
|
||||
->label(fn () => $this->getHeadingTable())
|
||||
->view('filament.tables.columns.drag-card')
|
||||
->extraAttributes([
|
||||
// Limits height, forces scrollbar, and switches layout to block to respect max-height
|
||||
'class' => 'max-h-[150px] overflow-y-auto block p-2 bg-gray-50 dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-700',
|
||||
]),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('player_position')
|
||||
@@ -126,7 +257,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
'midfield' => '<span class="text-blue-500">Midfield</span>',
|
||||
'defence' => '<span class="text-green-500">Defence</span>',
|
||||
'goalkeeper' => '<span class="text-gray-500">Goalkeeper</span>',
|
||||
])->modifyFormFieldUsing(fn(Select $component) => $component->allowHtml())
|
||||
])->modifyFormFieldUsing(fn (Select $component) => $component->allowHtml())
|
||||
->query(function ($query) {
|
||||
return $query;
|
||||
}),
|
||||
@@ -168,6 +299,13 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
}
|
||||
}
|
||||
|
||||
public function updateLineup(string $state)
|
||||
{
|
||||
$this->clearAll();
|
||||
|
||||
$this->lineup = $this->lineupsMap[$state];
|
||||
}
|
||||
|
||||
public function clearBox(int $boxNumber): void
|
||||
{
|
||||
if (isset($this->boxes[$boxNumber])) {
|
||||
@@ -217,7 +355,7 @@ class BoardDispatcher extends Component implements HasActions, HasSchemas, HasTa
|
||||
unset($row['pcolor']);
|
||||
unset($row['ecolor']);
|
||||
unset($row['info']);
|
||||
$copystring .= implode("\t", $row) . "\n";
|
||||
$copystring .= implode("\t", $row)."\n";
|
||||
}
|
||||
$this->js("navigator.clipboard.writeText(`$copystring`)");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user