Skip to content

Commit

Permalink
Show components on component group resource
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Mar 5, 2024
1 parent 981e0a4 commit c5c747c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Filament/Resources/ComponentGroupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Cachet\Enums\ComponentGroupVisibilityEnum;
use Cachet\Enums\ResourceVisibilityEnum;
use Cachet\Filament\Resources\ComponentGroupResource\Pages;
use Cachet\Filament\Resources\ComponentResource\RelationManagers\ComponentsRelationManager;
use Cachet\Models\ComponentGroup;
use Filament\Forms;
use Filament\Forms\Form;
Expand Down Expand Up @@ -79,7 +80,7 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
ComponentsRelationManager::class,
];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Cachet\Filament\Resources\ComponentResource\RelationManagers;

use Cachet\Enums\ComponentStatusEnum;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;

class ComponentsRelationManager extends RelationManager
{
protected static string $relationship = 'components';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\ToggleButtons::make('status')
->inline()
->columnSpanFull()
->options(ComponentStatusEnum::class)
->required(),
Forms\Components\MarkdownEditor::make('description')
->maxLength(255)
->columnSpanFull(),
Forms\Components\TextInput::make('link')
->url()
->hint(__('An optional link to the component.')),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('status')
->badge()
->sortable(),
Tables\Columns\IconColumn::make('enabled')
->boolean()
->toggleable(isToggledHiddenByDefault: false),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}

0 comments on commit c5c747c

Please sign in to comment.