Skip to content

Commit 3fbc557

Browse files
committed
Refactor codebase for improved readability and consistency by adjusting spacing, removing unnecessary lines, and updating method signatures to enhance clarity.
1 parent c233f6a commit 3fbc557

24 files changed

+200
-153
lines changed

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"pest_3.8.2","defects":{"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_update_item_status":8,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_render_kanban_board_component":8},"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.175,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.015,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_update_item_status":0.03,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_render_kanban_board_component":0.017}}
1+
{"version":"pest_3.8.2","defects":{"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_update_item_status":8,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_render_kanban_board_component":8},"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.316,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.015,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_update_item_status":0.03,"Relaticle\\Flowforge\\Tests\\Feature\\KanbanBoardTest::it_can_render_kanban_board_component":0.017}}

resources/views/livewire/column.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class="ff-column__content"
5353
x-intersect.full="
5454
if (!isLoadingColumn('{{ $columnId }}')) {
5555
beginLoading('{{ $columnId }}');
56-
$wire.loadMoreItems('{{ $columnId }}', {{ $config->cardsIncrement ?? 'null' }});
56+
$wire.loadMoreItems('{{ $columnId }}', {{ $this->cardsIncrement ?? 'null' }});
5757
}
5858
"
5959
class="ff-column__loader"

src/Adapters/DefaultKanbanAdapter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function __construct(
4343
) {
4444
$this->modelClass = get_class($query->getModel());
4545
$this->connectionName = $query->getModel()->getConnectionName();
46-
46+
4747
// Store a closure that can recreate the query
48-
$this->queryCallback = fn() => $query->clone();
48+
$this->queryCallback = fn () => $query->clone();
4949
}
5050

5151
/**
@@ -85,15 +85,15 @@ public static function fromLivewire($value): static
8585
{
8686
$modelClass = $value['modelClass'];
8787
$connectionName = $value['connectionName'];
88-
88+
8989
// Recreate the query from the model class and connection
90-
$model = new $modelClass();
90+
$model = new $modelClass;
9191
if ($connectionName) {
9292
$model->setConnection($connectionName);
9393
}
94-
94+
9595
$query = $model->newQuery();
96-
96+
9797
return new static($query, $value['config']);
9898
}
9999
}

src/Board.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Relaticle\Flowforge;
66

7-
use Exception;
87
use Filament\Support\Components\ViewComponent;
98
use Relaticle\Flowforge\Concerns\HasActions;
109
use Relaticle\Flowforge\Concerns\HasColumns;
@@ -44,9 +43,6 @@ public static function make(): static
4443
return $static;
4544
}
4645

47-
/**
48-
* @param array $filters
49-
*/
5046
public function filters(array $filters): static
5147
{
5248
$this->filters = $filters;

src/BoardPage.php

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
use Filament\Pages\Page;
1414
use Illuminate\Database\Eloquent\Builder;
1515
use Relaticle\Flowforge\Adapters\DefaultKanbanAdapter;
16-
use Relaticle\Flowforge\Config\KanbanConfig;
17-
use Relaticle\Flowforge\Contracts\KanbanAdapterInterface;
18-
use Relaticle\Flowforge\Contracts\HasBoard;
1916
use Relaticle\Flowforge\Concerns\HasRecords;
2017
use Relaticle\Flowforge\Concerns\InteractsWithBoard;
18+
use Relaticle\Flowforge\Config\KanbanConfig;
19+
use Relaticle\Flowforge\Contracts\HasBoard;
20+
use Relaticle\Flowforge\Contracts\KanbanAdapterInterface;
2121

22-
abstract class BoardPage extends Page implements HasActions, HasForms, HasBoard
22+
abstract class BoardPage extends Page implements HasActions, HasBoard, HasForms
2323
{
24-
use InteractsWithActions;
25-
use InteractsWithForms;
2624
use HasRecords;
25+
use InteractsWithActions;
2726
use InteractsWithBoard {
2827
InteractsWithBoard::moveRecord insteadof HasRecords;
2928
}
29+
use InteractsWithForms;
3030

3131
protected string $view = 'flowforge::filament.pages.board-page';
3232

@@ -41,12 +41,15 @@ abstract class BoardPage extends Page implements HasActions, HasForms, HasBoard
4141

4242
public function bootedInteractsWithActions(): void
4343
{
44-
$this->bootedInteractsWithBoard();
45-
}
44+
// Recreate board fresh (Filament pattern)
45+
$this->board = $this->board(Board::make());
4646

47-
public function bootedInteractsWithBoard(): void
48-
{
49-
$this->board = $this->makeBoard();
47+
// Set the query on the board if not already set
48+
if (! $this->board->getQuery()) {
49+
$this->board->query($this->getEloquentQuery());
50+
}
51+
52+
// Recreate adapter fresh (Filament pattern)
5053
$this->adapter = $this->createAdapter();
5154
$this->cacheBoardActions();
5255
}
@@ -94,7 +97,7 @@ public function getCachedBoardActions(): array
9497
/**
9598
* Check if an action is a record-based action that shouldn't be used as column action.
9699
*/
97-
public function isRecordBasedAction(Action|ActionGroup $action): bool
100+
public function isRecordBasedAction(Action | ActionGroup $action): bool
98101
{
99102
// ActionGroups themselves are not record-based, only individual actions within them can be
100103
if ($action instanceof ActionGroup) {
@@ -149,14 +152,14 @@ public function getColumnActionsForColumn(string $columnId): array
149152
}
150153

151154
// Only include the group if it has valid actions
152-
if (!empty($validGroupActions)) {
155+
if (! empty($validGroupActions)) {
153156
$processedActions[] = $actionClone;
154157
}
155158
} else {
156159
// Handle individual actions
157160
$this->configureColumnAction($actionClone, $columnId);
158161

159-
if (!$actionClone->isHidden()) {
162+
if (! $actionClone->isHidden()) {
160163
$processedActions[] = $actionClone;
161164
}
162165
}
@@ -195,7 +198,7 @@ public function getCardActionsForRecord(array $recordData): array
195198
$recordModel = $this->getAdapter()->getModelById($recordData['id']);
196199

197200
// If we can't find the record, return empty actions
198-
if (!$recordModel || !($recordModel instanceof \Illuminate\Database\Eloquent\Model)) {
201+
if (! $recordModel || ! ($recordModel instanceof \Illuminate\Database\Eloquent\Model)) {
199202
return [];
200203
}
201204

@@ -227,7 +230,7 @@ public function getCardActionsForRecord(array $recordData): array
227230
}
228231

229232
// Safely check if action is hidden
230-
if (!$actionClone->isHidden()) {
233+
if (! $actionClone->isHidden()) {
231234
$processedActions[] = $actionClone;
232235
}
233236
} catch (\Exception $e) {
@@ -246,6 +249,7 @@ public function getCardActionsForRecord(array $recordData): array
246249
protected function makeBoard(): Board
247250
{
248251
$board = Board::make();
252+
249253
return $this->board($board);
250254
}
251255

@@ -268,7 +272,16 @@ protected function getTableQuery(): Builder
268272

269273
protected function createKanbanConfig(): KanbanConfig
270274
{
271-
$board = $this->getBoard();
275+
// Ensure board is initialized before creating config
276+
if (! isset($this->board)) {
277+
$this->board = $this->board(Board::make());
278+
// Set the query on the board if not already set
279+
if (! $this->board->getQuery()) {
280+
$this->board->query($this->getEloquentQuery());
281+
}
282+
}
283+
284+
$board = $this->board;
272285

273286
// Set columns configuration
274287
$columns = [];
@@ -313,7 +326,7 @@ protected function createKanbanConfig(): KanbanConfig
313326

314327
public function getBoard(): Board
315328
{
316-
return $this->board ??= $this->makeBoard();
329+
return $this->board ??= $this->board(Board::make());
317330
}
318331

319332
public function getAdapter(): KanbanAdapterInterface
@@ -326,11 +339,10 @@ public function getPageClass(): string
326339
return static::class;
327340
}
328341

329-
330342
protected function getViewData(): array
331343
{
332344
return [
333-
'adapter' => $this->adapter,
345+
'adapter' => $this->getAdapter(),
334346
'pageClass' => static::class,
335347
];
336348
}

src/Column.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
use Closure;
88
use Exception;
99
use Filament\Support\Components\ViewComponent;
10-
use Illuminate\Contracts\Support\Htmlable;
1110
use Filament\Support\Concerns\HasColor;
1211
use Filament\Support\Concerns\HasIcon;
1312
use Filament\Support\Concerns\HasIconColor;
1413
use Filament\Support\Concerns\HasIconPosition;
15-
use Relaticle\Flowforge\Concerns\HasLimit;
14+
use Illuminate\Contracts\Support\Htmlable;
15+
use Relaticle\Flowforge\Concerns\BelongsToBoard;
1616
use Relaticle\Flowforge\Concerns\CanBeSortable;
1717
use Relaticle\Flowforge\Concerns\CanBeVisible;
18-
use Relaticle\Flowforge\Concerns\BelongsToBoard;
18+
use Relaticle\Flowforge\Concerns\HasLimit;
1919

2020
class Column extends ViewComponent
2121
{
22+
use BelongsToBoard;
23+
use CanBeSortable;
24+
use CanBeVisible;
2225
use HasColor;
2326
use HasIcon;
2427
use HasIconColor;
2528
use HasIconPosition;
2629
use HasLimit;
27-
use CanBeSortable;
28-
use CanBeVisible;
29-
use BelongsToBoard;
3030

3131
/**
3232
* @var view-string
@@ -37,7 +37,7 @@ class Column extends ViewComponent
3737

3838
protected string $evaluationIdentifier = 'column';
3939

40-
protected string|Htmlable|Closure|null $label = null;
40+
protected string | Htmlable | Closure | null $label = null;
4141

4242
protected bool $shouldTranslateLabel = false;
4343

@@ -76,7 +76,7 @@ protected function setUp(): void
7676
// Override in subclasses if needed
7777
}
7878

79-
public function label(string|Htmlable|Closure|null $label): static
79+
public function label(string | Htmlable | Closure | null $label): static
8080
{
8181
$this->label = $label;
8282

@@ -90,7 +90,7 @@ public function translateLabel(bool $shouldTranslateLabel = true): static
9090
return $this;
9191
}
9292

93-
public function getLabel(): string|Htmlable|null
93+
public function getLabel(): string | Htmlable | null
9494
{
9595
$label = $this->evaluate($this->label) ?? $this->generateDefaultLabel();
9696

src/Concerns/BelongsToBoard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ protected function resolveDefaultClosureDependencyForEvaluationByName(string $pa
3232
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
3333
};
3434
}
35-
}
35+
}

src/Concerns/CanBeSortable.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
trait CanBeSortable
1010
{
11-
protected bool|Closure $isSortable = false;
11+
protected bool | Closure $isSortable = false;
1212

13-
public function sortable(bool|Closure $condition = true): static
13+
public function sortable(bool | Closure $condition = true): static
1414
{
1515
$this->isSortable = $condition;
1616

@@ -32,4 +32,4 @@ protected function resolveDefaultClosureDependencyForEvaluationByName(string $pa
3232
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
3333
};
3434
}
35-
}
35+
}

src/Concerns/CanBeVisible.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
trait CanBeVisible
1010
{
11-
protected bool|Closure $isVisible = true;
11+
protected bool | Closure $isVisible = true;
1212

13-
protected bool|Closure $isHidden = false;
13+
protected bool | Closure $isHidden = false;
1414

15-
public function visible(bool|Closure $condition = true): static
15+
public function visible(bool | Closure $condition = true): static
1616
{
1717
$this->isVisible = $condition;
1818

1919
return $this;
2020
}
2121

22-
public function hidden(bool|Closure $condition = true): static
22+
public function hidden(bool | Closure $condition = true): static
2323
{
2424
$this->isHidden = $condition;
2525

@@ -51,4 +51,4 @@ protected function resolveDefaultClosureDependencyForEvaluationByName(string $pa
5151
default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
5252
};
5353
}
54-
}
54+
}

src/Concerns/CardFormattingTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function formatCardForDisplay(Model $model): array
3939
foreach ($cardProperties as $property) {
4040
$name = $property->getName();
4141
$value = $property->getFormattedState($model);
42-
42+
4343
if ($value !== null && $value !== '') {
4444
$card['attributes'][$name] = [
4545
'label' => $property->getLabel(),

0 commit comments

Comments
 (0)