From 5e7f5c2a4ca2ee9c13e5f5c065aff93b9660a403 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Sat, 1 Jun 2024 19:26:23 -0400 Subject: [PATCH] Allow adding new allocations to existing servers --- .../RelationManagers/AllocationsRelationManager.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php index 58d13594b..ef200f841 100644 --- a/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Resources/ServerResource/RelationManagers/AllocationsRelationManager.php @@ -27,13 +27,15 @@ class AllocationsRelationManager extends RelationManager { return $table ->recordTitleAttribute('ip') + ->recordTitle(fn (Allocation $allocation) => "$allocation->ip:$allocation->port") ->checkIfRecordIsSelectableUsing(fn (Allocation $record) => $record->id !== $this->getOwnerRecord()->allocation_id) // ->actions // ->groups + ->inverseRelationship('server') ->columns([ - Tables\Columns\TextInputColumn::make('ip_alias')->label('Alias'), Tables\Columns\TextColumn::make('ip')->label('IP'), Tables\Columns\TextColumn::make('port')->label('Port'), + Tables\Columns\TextInputColumn::make('ip_alias')->label('Alias'), Tables\Columns\IconColumn::make('primary') ->icon(fn ($state) => match ($state) { false => 'tabler-star', @@ -57,7 +59,11 @@ class AllocationsRelationManager extends RelationManager ]) ->headerActions([ //TODO Tables\Actions\CreateAction::make()->label('Create Allocation'), - //TODO Tables\Actions\AssociateAction::make()->label('Add Allocation'), + Tables\Actions\AssociateAction::make() + ->multiple() + ->preloadRecordSelect() + ->recordSelectOptionsQuery(fn ($query) => $query->whereBelongsTo($this->getOwnerRecord()->node)) + ->label('Add Allocation'), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([