Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front desk UI for on-site staff #33

Merged
merged 31 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
fb1333a
initial draft for front desk system
Fenrikur Aug 9, 2023
1bd72b9
Added comment resource for admin area
julsteele Aug 10, 2023
f4a21de
Formatting
julsteele Aug 10, 2023
b5544b1
Added dates, formatted comment view
julsteele Aug 10, 2023
c858e98
render application data in frontdesk
Fenrikur Aug 10, 2023
2a86f01
allow searching for table number, attendee nickname and display name
Fenrikur Aug 10, 2023
1b1de50
avoid unnecessary queries by middleware
Fenrikur Aug 10, 2023
1bc90ac
fix UI and data access and prepare check-in/-out
Fenrikur Aug 10, 2023
d7e35ed
fix application status based button color
Fenrikur Aug 10, 2023
9aac677
implement comment storing in frontdesk
Fenrikur Aug 10, 2023
0ac28d8
add error handling for frontdesk comments
Fenrikur Aug 10, 2023
36631ae
fix undefined in frontdesk comment error handling
Fenrikur Aug 10, 2023
cc8957f
Fixed redirect, added ts to comments in admin
julsteele Aug 13, 2023
2a02bfd
Create comment from application page
julsteele Aug 13, 2023
247e733
Added label
julsteele Aug 13, 2023
1be8f24
improve code for comment storing
Fenrikur Aug 13, 2023
99ad0e4
improve tab order in frontdesk
Fenrikur Aug 13, 2023
f04e287
fix column type for comment text
Fenrikur Aug 13, 2023
db27e49
implement check-in and check-out via frontdesk
Fenrikur Aug 13, 2023
aa255b1
remove admin-only option for check-in/out comments
Fenrikur Aug 13, 2023
1dfe362
add checked-out state to admin ui
Fenrikur Aug 13, 2023
bbce5c5
Merge tag v0.1.7 into feature/frontdesk
Fenrikur Aug 13, 2023
8606c13
move ApplicationRelationManager for comments
Fenrikur Aug 13, 2023
71825b6
Merge commit '1ac3d89629ec9f40cc471a715f1b48ad4c014058' into feature/…
Fenrikur Aug 14, 2023
a673ba5
fix users.groups using unsupported json type in mariadb
Fenrikur Aug 14, 2023
d275f51
Merge branch 'bugfix/users-groups-type' into feature/frontdesk
Fenrikur Aug 14, 2023
240b97f
add attendance to additional info
Fenrikur Aug 15, 2023
eddae6f
disable autocomplete in frontdesk
Fenrikur Aug 26, 2023
bdb2a01
add more content to Additional Information on frontdesk
Fenrikur Aug 27, 2023
c5b1e4f
restrict frontdesk view via Application policy
Fenrikur Aug 27, 2023
626fc8c
improve not found message in frontend
Fenrikur Sep 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/Enums/ApplicationStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ enum ApplicationStatus: string
case TableOffered = 'table_offered';
case TableAccepted = 'table_accepted';
case CheckedIn = 'checked_in';
case CheckedOut = 'checked_out';

static function for(\App\Models\Application $application): ApplicationStatus
{
if (!is_null($application->canceled_at)) {
return ApplicationStatus::Canceled;
} elseif (!is_null($application->checked_out_at)) {
return ApplicationStatus::CheckedOut;
} elseif (!is_null($application->checked_in_at)) {
return ApplicationStatus::CheckedIn;
} elseif (!is_null($application->waiting_at)) {
Expand All @@ -38,27 +41,36 @@ function orWhere(\Illuminate\Database\Eloquent\Builder $query)
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '!=', null)
),
ApplicationStatus::CheckedOut => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '!=', null)
),
ApplicationStatus::CheckedIn => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '!=', null)
),
ApplicationStatus::Waiting => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '=', null)
->where('waiting_at', '!=', null)
),
ApplicationStatus::TableAccepted => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '=', null)
->where('waiting_at', '=', null)
->where('offer_accepted_at', '!=', null)
),
ApplicationStatus::TableOffered => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '=', null)
->where('waiting_at', '=', null)
->where('offer_accepted_at', '=', null)
Expand All @@ -67,6 +79,7 @@ function orWhere(\Illuminate\Database\Eloquent\Builder $query)
ApplicationStatus::TableAssigned => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '=', null)
->where('waiting_at', '=', null)
->where('offer_accepted_at', '=', null)
Expand All @@ -81,6 +94,7 @@ function orWhere(\Illuminate\Database\Eloquent\Builder $query)
ApplicationStatus::Open => $query->orWhere(
fn (\Illuminate\Database\Eloquent\Builder $query) =>
$query->where('canceled_at', '=', null)
->where('checked_out_at', '=', null)
->where('checked_in_at', '=', null)
->where('waiting_at', '=', null)
->where('offer_accepted_at', '=', null)
Expand Down
7 changes: 4 additions & 3 deletions app/Filament/Resources/ApplicationResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static function form(Form $form): Form
"table_assigned" => "Table assigned (Open)",
"table_offered" => "Table offered",
"table_accepted" => "Table accepted",
"checked_in" => "Checked in (on-site)"
"checked_in" => "Checked in (on-site)",
"checked_out" => "Checked out (on-site)",
])->disablePlaceholderSelection()->required()->reactive(),
Forms\Components\TextInput::make('table_number')
->maxLength(255),
Expand Down Expand Up @@ -96,6 +97,7 @@ public static function form(Form $form): Form
Forms\Components\Placeholder::make('offer_accepted_at')->content(fn (?Application $record): string => $record?->offer_accepted_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('waiting_at')->content(fn (?Application $record): string => $record?->waiting_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('checked_in_at')->content(fn (?Application $record): string => $record?->checked_in_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('checked_out_at')->content(fn (?Application $record): string => $record?->checked_out_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('canceled_at')->content(fn (?Application $record): string => $record?->canceled_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('updated_at')->content(fn (?Application $record): string => $record?->updated_at?->diffForHumans() ?? '-'),
Forms\Components\Placeholder::make('created_at')->content(fn (?Application $record): string => $record?->created_at?->diffForHumans() ?? '-'),
Expand Down Expand Up @@ -348,15 +350,14 @@ public static function table(Table $table): Table
]);
}



public static function getRelations(): array
{
return [
RelationManagers\ChildrenRelationManager::class,
RelationManagers\ParentRelationManager::class,
RelationManagers\UserRelationManager::class,
RelationManagers\ProfileRelationManager::class,
RelationManagers\CommentRelationManager::class,
];
}

Expand Down
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([
]);
}
}
92 changes: 92 additions & 0 deletions app/Filament/Resources/CommentResource.php
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 app/Filament/Resources/CommentResource/Pages/CreateComment.php
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 app/Filament/Resources/CommentResource/Pages/EditComment.php
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 app/Filament/Resources/CommentResource/Pages/ListComments.php
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(),
];
}
}
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([
]);
}
}
Loading