-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from eurofurence/feature/frontdesk
Front desk UI for on-site staff
- Loading branch information
Showing
23 changed files
with
1,411 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/Filament/Resources/ApplicationResource/RelationManagers/CommentRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\ApplicationResource\RelationManagers; | ||
|
||
use App\Filament\Resources\CommentResource; | ||
use App\Filament\Resources\CommentResource\Pages\CreateComment; | ||
use App\Models\Comment; | ||
use Filament\Forms; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
class CommentRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'comments'; | ||
protected static ?string $title = "Comments"; | ||
protected static ?string $label = "Comment"; | ||
protected static ?string $recordTitleAttribute = 'text'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
// | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('author.name'), | ||
Tables\Columns\IconColumn::make('admin_only') | ||
->boolean(), | ||
Tables\Columns\TextColumn::make('text'), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->sortable(), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\Action::make('New comment') | ||
->form([ | ||
Forms\Components\TextInput::make('application_id') | ||
->default(function (RelationManager $livewire) { | ||
return $livewire->ownerRecord->id; | ||
}) | ||
->required(), | ||
Forms\Components\TextInput::make('user_id') | ||
->label("User ID (Author)") | ||
->default(\Auth::user()->id) | ||
->required(), | ||
Forms\Components\Toggle::make('admin_only'), | ||
Forms\Components\Textarea::make('text') | ||
->required() | ||
->maxLength(4096), | ||
|
||
]) | ||
->action(function (array $data): void { | ||
Comment::create([ | ||
'text' => $data['text'], | ||
'admin_only' => $data['admin_only'], | ||
'application_id' => $data['application_id'], | ||
'user_id' => $data['user_id'], | ||
]); | ||
}) | ||
->icon('heroicon-o-pencil'), | ||
|
||
]) | ||
->actions([ | ||
Tables\Actions\Action::make('Show') | ||
->url(fn(Comment $record): string => CommentResource::getUrl('edit', ['record' => $record])), | ||
|
||
]) | ||
->bulkActions([ | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\CommentResource\Pages; | ||
use App\Filament\Resources\CommentResource\RelationManagers; | ||
use App\Models\Comment; | ||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class CommentResource extends Resource | ||
{ | ||
protected static ?string $model = Comment::class; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-pencil'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->columns(3) | ||
->schema([ | ||
Forms\Components\Group::make()->columnSpan(2)->columns()->schema([ | ||
Forms\Components\Group::make()->columns(1)->schema([ | ||
Forms\Components\Select::make('user_id')->searchable()->relationship('author', 'name') | ||
->required(), | ||
Forms\Components\Select::make('application_id')->searchable()->relationship('application', 'id') | ||
->required(), | ||
Forms\Components\Toggle::make('admin_only'), | ||
]), | ||
Forms\Components\Textarea::make('text') | ||
->required() | ||
->maxLength(4096), | ||
]), | ||
Forms\Components\Fieldset::make('Dates')->columnSpan(1)->columns()->schema([ | ||
Forms\Components\Placeholder::make('created_at')->content(fn (?Comment $record): string => $record?->created_at?->diffForHumans() ?? '-'), | ||
Forms\Components\Placeholder::make('updated_at')->content(fn (?Comment $record): string => $record?->updated_at?->diffForHumans() ?? '-'), | ||
]), | ||
|
||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('uuid')->hidden()->url(fn($record) => CommentResource::getUrl('edit', ['record' => $record->uuid])), | ||
Tables\Columns\TextColumn::make('application_id') | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('author.name') | ||
->searchable(), | ||
Tables\Columns\IconColumn::make('admin_only') | ||
->boolean(), | ||
Tables\Columns\TextColumn::make('text'), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->sortable(), | ||
]) | ||
->filters([ | ||
Tables\Filters\Filter::make('admin_only') | ||
->query(fn(Builder $query): Builder => $query->where('admin_only', '=', '1')) | ||
->label('Is Admin only'), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
RelationManagers\ApplicationRelationManager::class, | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListComments::route('/'), | ||
'create' => Pages\CreateComment::route('/create'), | ||
'edit' => Pages\EditComment::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
app/Filament/Resources/CommentResource/Pages/CreateComment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CommentResource\Pages; | ||
|
||
use App\Filament\Resources\CommentResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateComment extends CreateRecord | ||
{ | ||
protected static string $resource = CommentResource::class; | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CommentResource/Pages/EditComment.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CommentResource\Pages; | ||
|
||
use App\Filament\Resources\CommentResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditComment extends EditRecord | ||
{ | ||
protected static string $resource = CommentResource::class; | ||
|
||
protected function getActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Filament/Resources/CommentResource/Pages/ListComments.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CommentResource\Pages; | ||
|
||
use App\Filament\Resources\CommentResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListComments extends ListRecords | ||
{ | ||
protected static string $resource = CommentResource::class; | ||
|
||
protected function getActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
app/Filament/Resources/CommentResource/RelationManagers/ApplicationRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace App\Filament\Resources\CommentResource\RelationManagers; | ||
|
||
use App\Enums\ApplicationStatus; | ||
use App\Filament\Resources\ApplicationResource; | ||
use App\Models\Application; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
|
||
class ApplicationRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'application'; | ||
|
||
protected static ?string $title = "Application"; | ||
protected static ?string $label = "application"; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form; | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('user.name'), | ||
Tables\Columns\TextColumn::make('type'), | ||
Tables\Columns\BadgeColumn::make('status')->enum(ApplicationStatus::cases())->formatStateUsing(function (Application $record) { | ||
return $record->status->name; | ||
})->colors([ | ||
'secondary', | ||
'success' => ApplicationStatus::TableAccepted->value, | ||
'danger' => ApplicationStatus::Canceled->value | ||
]), | ||
Tables\Columns\TextColumn::make('assignedTable.name'), | ||
Tables\Columns\TextColumn::make('table_number'), | ||
|
||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
]) | ||
->actions([ | ||
Tables\Actions\Action::make('Show') | ||
->url(fn(Application $record): string => ApplicationResource::getUrl('edit', ['record' => $record])), | ||
|
||
]) | ||
->bulkActions([ | ||
]); | ||
} | ||
} |
Oops, something went wrong.