diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index 68a45e3a..1a031909 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -23,14 +23,9 @@ use Filament\Actions\ActionGroup; use Filament\Actions\BulkActionGroup; use Filament\Actions\DeleteAction; use Filament\Actions\DeleteBulkAction; -use Filament\Actions\EditAction; -use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; -use Filament\Infolists\Components\TextEntry; -use Filament\Schemas\Components\Grid; -use Filament\Schemas\Components\Section; use Filament\Schemas\Components\Utilities\Get; use Filament\Support\Enums\FontWeight; use Filament\Support\Enums\VerticalAlignment; @@ -40,6 +35,7 @@ use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\Indicator; use Filament\Tables\Table; +use Illuminate\Contracts\View\View; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; @@ -66,7 +62,7 @@ class EventsTable ->poll('10s') ->striped() ->deferLoading() - ->defaultPaginationPageOption(5) + ->defaultPaginationPageOption(50) ->paginated([5, 10, 15]) ->columns([ IconColumn::make('sport.icon') @@ -515,30 +511,16 @@ class EventsTable ->emptyStateDescription('Modify the filter') ->recordActions([ Action::make('note') + // ->before(fn () => $this->pollingInterval = null) + // ->after(fn () => $this->pollingInterval = '1s') ->iconButton()->icon('phosphor-note')->color('gray') ->tooltip('Add a note') - ->schema([ - Grid::make(2) - ->schema([ - Section::make('Details') - ->schema([ - TextInput::make('name'), - Select::make('position') - ->options([ - 'developer' => 'Developer', - 'designer' => 'Designer', - ]), - Checkbox::make('is_admin'), - ]), - Section::make('Auditing') - ->schema([ - TextEntry::make('created_at') - ->dateTime(), - TextEntry::make('updated_at') - ->dateTime(), - ]), - ]), - ]), + ->modalSubmitAction(false) + ->modalCancelAction(fn (Action $action) => $action->label('Close')) + ->modalContent(fn ($record): View => view( + 'filament.tables.columns.make-note', + ['record' => $record], + )), Action::make('notify')->iconButton()->icon('phosphor-bell')->color('gray')->tooltip('Add a notifications'), Action::make('star') ->iconButton() diff --git a/app/Livewire/EditUserNote.php b/app/Livewire/EditUserNote.php new file mode 100644 index 00000000..c111e099 --- /dev/null +++ b/app/Livewire/EditUserNote.php @@ -0,0 +1,77 @@ +record = $record; + } + + public function form(Schema $schema): Schema + { + return $schema + ->components([ + Textarea::make('message')->required()->rows(2)->label('Add a new note'), + ]) + ->statePath('data'); + } + + public function create(): void + { + dd($this->form->getState()); + } + + public function table(Table $table): Table + { + return $table + // ->headerActions([ + // Action::make() + // ->label('New note') + // ->icon('phosphor-plus') + // ->action(function () { + // UserNote::insert(['event_id' => $this->record->id, 'bookmaker_id' => auth()->user()->bookmaker_id, 'user_id' => auth()->user()->id]); + // }), + // ]) + ->query(UserNote::query()->where('event_id', $this->record->id)->where('bookmaker_id', auth()->user()->bookmaker_id)->where('user_id', auth()->user()->id)) + ->columns([ + TextColumn::make('message')->label('Notes'), + ]) + ->filters([ + // ... + ]) + ->recordActions([ + // ... + ]) + ->toolbarActions([ + ]); + } + + public function render(): View + { + return view('livewire.edit-user-note'); + } +} diff --git a/app/Models/Message.php b/app/Models/UserNote.php similarity index 93% rename from app/Models/Message.php rename to app/Models/UserNote.php index 9c844496..745606c2 100644 --- a/app/Models/Message.php +++ b/app/Models/UserNote.php @@ -4,7 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; -class Message extends Model +class UserNote extends Model { protected $fillable = [ 'event_id', diff --git a/database/migrations/2026_01_30_101858_create_messages_table.php b/database/migrations/2026_01_30_101858_create_user_note_table.php similarity index 87% rename from database/migrations/2026_01_30_101858_create_messages_table.php rename to database/migrations/2026_01_30_101858_create_user_note_table.php index 394e6c34..e0bbde7e 100644 --- a/database/migrations/2026_01_30_101858_create_messages_table.php +++ b/database/migrations/2026_01_30_101858_create_user_note_table.php @@ -11,7 +11,7 @@ return new class extends Migration */ public function up(): void { - Schema::create('messages', function (Blueprint $table) { + Schema::create('user_notes', function (Blueprint $table) { $table->id(); $table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events'); $table->integer('bookmaker_id')->default(0); @@ -27,6 +27,6 @@ return new class extends Migration */ public function down(): void { - Schema::dropIfExists('messages'); + Schema::dropIfExists('user_notes'); } }; diff --git a/resources/css/filament/admin/theme.css b/resources/css/filament/admin/theme.css index f2c51939..de0b8419 100644 --- a/resources/css/filament/admin/theme.css +++ b/resources/css/filament/admin/theme.css @@ -17,10 +17,6 @@ button[wire\:click="resetTableFiltersForm"] { /* background-color: #0f172b; */ } -.fi-ta-content-ctn { - min-height: 350px; -} - /* .fi-ta-header-toolbar { @apply flex-row-reverse; } */ diff --git a/resources/views/filament/tables/columns/make-note.blade.php b/resources/views/filament/tables/columns/make-note.blade.php new file mode 100644 index 00000000..a5becaec --- /dev/null +++ b/resources/views/filament/tables/columns/make-note.blade.php @@ -0,0 +1,3 @@ +