|
2 | 2 |
|
3 | 3 | namespace Relaticle\Flowforge; |
4 | 4 |
|
5 | | -use Filament\Support\Components\ViewComponent; |
6 | | -use Relaticle\Flowforge\Concerns\HasRecordAction; |
7 | | -use Relaticle\Flowforge\Concerns\HasRecordActions; |
| 5 | +use Closure; |
| 6 | +use Filament\Actions\Action; |
| 7 | +use Filament\Actions\ActionGroup; |
8 | 8 |
|
9 | | -class Board extends ViewComponent |
| 9 | +class Board |
10 | 10 | { |
11 | | - use HasRecordAction; |
12 | | - use HasRecordActions; |
13 | 11 |
|
| 12 | + protected ?string $recordTitleAttribute = null; |
| 13 | + |
| 14 | + protected ?string $columnIdentifierAttribute = null; |
| 15 | + |
| 16 | + protected ?array $defaultSort = null; |
| 17 | + |
| 18 | + /** |
| 19 | + * @var Column[] |
| 20 | + */ |
| 21 | + protected array $columns = []; |
| 22 | + |
| 23 | + /** |
| 24 | + * @var Action[]|ActionGroup[] |
| 25 | + */ |
| 26 | + protected array $columnActions = []; |
| 27 | + |
| 28 | + protected array $recordProperties = []; |
| 29 | + |
| 30 | + /** |
| 31 | + * @var Action[]|ActionGroup[] |
| 32 | + */ |
| 33 | + protected array $recordActions = []; |
| 34 | + |
| 35 | + public function recordTitleAttribute(string $attribute): static |
| 36 | + { |
| 37 | + $this->recordTitleAttribute = $attribute; |
| 38 | + |
| 39 | + return $this; |
| 40 | + } |
| 41 | + |
| 42 | + public function columnIdentifierAttribute(string $attribute): static |
| 43 | + { |
| 44 | + $this->columnIdentifierAttribute = $attribute; |
| 45 | + |
| 46 | + return $this; |
| 47 | + } |
| 48 | + |
| 49 | + public function defaultSort(string $column, string $direction = 'asc'): static |
| 50 | + { |
| 51 | + $this->defaultSort = [ |
| 52 | + 'column' => $column, |
| 53 | + 'direction' => $direction, |
| 54 | + ]; |
| 55 | + |
| 56 | + return $this; |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @param Column[] $columns |
| 61 | + */ |
| 62 | + public function columns(array $columns): static |
| 63 | + { |
| 64 | + $this->columns = $columns; |
| 65 | + |
| 66 | + return $this; |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @param Action[]|ActionGroup[] $actions |
| 71 | + */ |
| 72 | + public function columnActions(array $actions): static |
| 73 | + { |
| 74 | + $this->columnActions = $actions; |
| 75 | + |
| 76 | + return $this; |
| 77 | + } |
| 78 | + |
| 79 | + public function getRecordTitleAttribute(): ?string |
| 80 | + { |
| 81 | + return $this->recordTitleAttribute; |
| 82 | + } |
| 83 | + |
| 84 | + public function getColumnIdentifierAttribute(): ?string |
| 85 | + { |
| 86 | + return $this->columnIdentifierAttribute; |
| 87 | + } |
| 88 | + |
| 89 | + public function getDefaultSort(): ?array |
| 90 | + { |
| 91 | + return $this->defaultSort; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * @return Column[] |
| 96 | + */ |
| 97 | + public function getColumns(): array |
| 98 | + { |
| 99 | + return $this->columns; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * @param Property[] $properties |
| 104 | + */ |
| 105 | + public function recordProperties(array $properties): static |
| 106 | + { |
| 107 | + $this->recordProperties = $properties; |
| 108 | + |
| 109 | + return $this; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @return Property[] |
| 114 | + */ |
| 115 | + public function getRecordProperties(): array |
| 116 | + { |
| 117 | + return $this->recordProperties; |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * @param Action[]|ActionGroup[] $actions |
| 122 | + */ |
| 123 | + public function recordActions(array $actions): static |
| 124 | + { |
| 125 | + $this->recordActions = $actions; |
| 126 | + |
| 127 | + return $this; |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * @return Action[]|ActionGroup[] |
| 132 | + */ |
| 133 | + public function getColumnActions(): array |
| 134 | + { |
| 135 | + return $this->columnActions; |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * @return Action[]|ActionGroup[] |
| 140 | + */ |
| 141 | + public function getRecordActions(): array |
| 142 | + { |
| 143 | + return $this->recordActions; |
| 144 | + } |
14 | 145 | } |
0 commit comments