Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
9 changes: 4 additions & 5 deletions app/Filament/Resources/ArticleResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static function table(Table $table): Table
->actions([
ActionGroup::make([
Action::make('approved')
->visible(fn ($record) => $record->submitted_at && (! $record->declined_at && ! $record->approved_at))
->label('Approuver')
->icon('heroicon-s-check')
->color('success')
Expand All @@ -74,10 +75,10 @@ public static function table(Table $table): Table
->modalIcon('heroicon-s-check')
->action(function ($record): void {
$record->approved_at = now();
$record->declined_at = null;
$record->save();
}),
Action::make('declined')
->visible(fn ($record) => $record->submitted_at && (! $record->declined_at && ! $record->approved_at))
->label('Décliner')
->icon('heroicon-s-x-mark')
->color('warning')
Expand All @@ -87,10 +88,8 @@ public static function table(Table $table): Table
->modalIcon('heroicon-s-x-mark')
->action(function ($record): void {
$record->declined_at = now();
$record->approved_at = null;
$record->save();
}),
// DeclinedAction::make('declined'),
Tables\Actions\DeleteAction::make('delete'),
]),

Expand All @@ -101,7 +100,7 @@ public static function table(Table $table): Table
->label('Approuver la sélection')
->icon('heroicon-s-check')
->color('success')
->action(fn (Collection $records) => $records->each->update(['approved_at' => now(), 'declined_at' => null]))
->action(fn (Collection $records) => $records->each->update(['approved_at' => now()]))
->deselectRecordsAfterCompletion()
->requiresConfirmation()
->modalIcon('heroicon-s-check')
Expand All @@ -112,7 +111,7 @@ public static function table(Table $table): Table
->label('Décliner la sélection')
->icon('heroicon-s-x-mark')
->color('warning')
->action(fn (Collection $records) => $records->each->update(['declined_at' => now(), 'approved_at' => null]))
->action(fn (Collection $records) => $records->each->update(['declined_at' => now()]))
->deselectRecordsAfterCompletion()
->requiresConfirmation()
->modalIcon('heroicon-s-x-mark')
Expand Down
21 changes: 0 additions & 21 deletions tests/Feature/Filament/ArticleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,4 @@
->and($article->approved_at)
->toBe(null);
});

it('admin user can bulk approved articles', function (): void {
$articles = Article::factory()->count(5)->create(['submitted_at' => now()]);

Livewire::test(ArticleResource\Pages\ListArticles::class)
->callTableBulkAction('approved', $articles);

expect(Article::whereNotNull('approved_at')->count())
->toBe(5);
});

it('admin user can bulk declined articles', function (): void {
$articles = Article::factory()->count(5)->create(['submitted_at' => now()]);

Livewire::test(ArticleResource\Pages\ListArticles::class)
->callTableBulkAction('declined', $articles);

expect(Article::whereNotNull('declined_at')->count())
->toBe(5);
});

})->group('articles');
Loading