Skip to content

Commit d993ba8

Browse files
feat: [LAR-34] Remove blank space , add slive over and delete create and edit page , delete package-lock.json in git ignore
1 parent 2891914 commit d993ba8

File tree

6 files changed

+28
-76
lines changed

6 files changed

+28
-76
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
npm-debug.log
55
yarn-error.log
66
yarn.lock
7-
package-lock.json
87
/vendor
98
composer.phar
109

app/Filament/Resources/TagResource.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
use Filament\Forms;
1010
use Filament\Forms\Components\Select;
1111
use Filament\Forms\Form;
12-
use Filament\Forms\Get;
13-
use Filament\Forms\Set;
1412
use Filament\Resources\Resource;
13+
use Filament\Support\Enums\MaxWidth;
1514
use Filament\Tables;
1615
use Filament\Tables\Table;
1716
use Illuminate\Support\Str;
@@ -29,19 +28,20 @@ public static function form(Form $form): Form
2928
Forms\Components\TextInput::make('name')
3029
->required()
3130
->live(onBlur: true)
32-
->afterStateUpdated(function (Get $get, Set $set, ?string $old, ?string $state): void {
33-
if (($get('slug') ?? '') !== Str::slug($old)) {
34-
return;
35-
}
31+
->afterStateUpdated(function (string $operation, $state, Forms\Set $set): void {
3632
$set('slug', Str::slug($state));
37-
}),
33+
})
34+
->columnSpanFull(),
3835
Forms\Components\TextInput::make('slug')
39-
->required(),
36+
->readOnly()
37+
->required()
38+
->helperText(__('Cette valeur est générée dynamiquement en fonction du Name.'))
39+
->columnSpanFull(),
4040
Select::make('concerns')
4141
->multiple()
4242
->options([
4343
'post' => 'Post',
44-
'tutorial' => 'Tutorial',
44+
'tutorial' => 'Tutoriel',
4545
'discussion' => 'Discussion',
4646
])
4747
->required()
@@ -68,7 +68,8 @@ public static function table(Table $table): Table
6868
\Filament\Tables\Actions\ActionGroup::make([
6969
Tables\Actions\DeleteAction::make(),
7070
Tables\Actions\EditAction::make()
71-
->color('warning'),
71+
->slideOver()
72+
->modalWidth(MaxWidth::Large),
7273
]),
7374
])
7475
->bulkActions([
@@ -82,8 +83,6 @@ public static function getPages(): array
8283
{
8384
return [
8485
'index' => Pages\ListTags::route('/'),
85-
'create' => Pages\CreateTag::route('/create'),
86-
'edit' => Pages\EditTag::route('/{record}/edit'),
8786
];
8887
}
8988
}

app/Filament/Resources/TagResource/Pages/CreateTag.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/Filament/Resources/TagResource/Pages/EditTag.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/Filament/Resources/TagResource/Pages/ListTags.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Filament\Resources\TagResource;
88
use Filament\Actions;
99
use Filament\Resources\Pages\ListRecords;
10+
use Filament\Support\Enums\MaxWidth;
1011

1112
final class ListTags extends ListRecords
1213
{
@@ -15,7 +16,9 @@ final class ListTags extends ListRecords
1516
protected function getHeaderActions(): array
1617
{
1718
return [
18-
Actions\CreateAction::make(),
19+
Actions\CreateAction::make()
20+
->slideOver()
21+
->modalWidth(MaxWidth::Large),
1922
];
2023
}
2124
}

tests/Feature/Filament/TagTest.php

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
declare(strict_types=1);
44

55
use App\Filament\Resources\TagResource;
6-
use App\Filament\Resources\TagResource\Pages\CreateTag;
76
use App\Filament\Resources\TagResource\Pages\ListTags;
87
use App\Models\Tag;
8+
use Filament\Actions\CreateAction;
99
use Filament\Actions\EditAction;
1010
use Illuminate\Database\Eloquent\Factories\Sequence;
1111
use Livewire\Livewire;
@@ -22,47 +22,34 @@
2222
});
2323

2424
describe(TagResource::class, function (): void {
25-
2625
it('page can display table with records', function (): void {
2726
Livewire::test(ListTags::class)
2827
->assertCanSeeTableRecords($this->tags);
2928
});
3029

31-
it('can automatically generate a slug from the title', function (): void {
32-
$name = fake()->name();
33-
34-
Livewire::test(CreateTag::class)
35-
->fillForm([
36-
'name' => $name,
37-
])
38-
->assertFormSet([
39-
'slug' => Str::slug($name),
40-
]);
41-
});
42-
4330
it('can validate input is value is null or empty', function (): void {
4431
$name = fake()->name();
4532

46-
Livewire::test(CreateTag::class)
47-
->fillForm([
33+
Livewire::test(ListTags::class)
34+
->callAction(CreateAction::class, data: [
4835
'name' => null,
4936
'concerns' => [],
5037
'description' => 'Description du tag '.$name,
5138
])
52-
->call('create')
53-
->assertHasFormErrors(['name' => 'required', 'concerns' => 'required']);
39+
->assertHasActionErrors(['name' => 'required', 'concerns' => 'required']);
5440
});
5541

56-
it('Admin user can create tag', function (): void {
42+
it('Admin can create tag', function (): void {
5743
$name = fake()->name();
5844

59-
Livewire::test(CreateTag::class)
60-
->fillForm([
45+
Livewire::test(ListTags::class)
46+
->callAction(CreateAction::class, data: [
6147
'name' => $name,
6248
'concerns' => ['post', 'tutorial'],
6349
'description' => 'Description du tag '.$name,
6450
])
65-
->call('create');
51+
->assertHasNoActionErrors()
52+
->assertStatus(200);
6653
});
6754

6855
it('Generate tag if tag already exist', function (): void {
@@ -74,20 +61,18 @@
7461
'concerns' => ['discussion'],
7562
]);
7663

77-
Livewire::test(CreateTag::class)
78-
->fillForm([
64+
Livewire::test(ListTags::class)
65+
->callAction(CreateAction::class, data: [
7966
'name' => $name,
8067
'concerns' => ['post', 'tutorial'],
8168
'description' => 'Description du tag '.$name,
82-
])
83-
->call('create');
69+
]);
8470

8571
expect(Tag::orderByDesc('id')->first()->slug)
8672
->toBe(Str::slug($name).'-1');
87-
8873
});
8974

90-
it('Admin user can edit tag', function (): void {
75+
it('Admin can edit tag', function (): void {
9176
$tag = Tag::factory()->create();
9277

9378
Livewire::test(ListTags::class)

0 commit comments

Comments
 (0)