Skip to content

Commit 4f43c33

Browse files
committed
UP
1 parent 7ae2e48 commit 4f43c33

File tree

6 files changed

+110
-96
lines changed

6 files changed

+110
-96
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"require": {
2323
"php": "^8.1",
2424
"filament/filament": "^3.0",
25+
"spatie/eloquent-sortable": "^4.4",
2526
"spatie/laravel-package-tools": "^1.15.0"
2627
},
2728
"require-dev": {
@@ -74,4 +75,4 @@
7475
},
7576
"minimum-stability": "dev",
7677
"prefer-stable": true
77-
}
78+
}

src/Concerns/CrudOperationsTrait.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
trait CrudOperationsTrait
1313
{
1414
/**
15-
* Create a new card with the given attributes.
15+
* Create a new record with the given attributes.
1616
*
17-
* @param array<string, mixed> $attributes The card attributes
17+
* @param array<string, mixed> $attributes The record attributes
1818
*/
1919
public function createRecord(array $attributes): ?Model
2020
{
@@ -42,10 +42,10 @@ public function createRecord(array $attributes): ?Model
4242
}
4343

4444
/**
45-
* Update an existing card with the given attributes.
45+
* Update an existing record with the given attributes.
4646
*
47-
* @param Model $record The card to update
48-
* @param array<string, mixed> $attributes The card attributes to update
47+
* @param Model $record The record to update
48+
* @param array<string, mixed> $attributes The record attributes to update
4949
*/
5050
public function updateRecord(Model $record, array $attributes): bool
5151
{
@@ -55,30 +55,30 @@ public function updateRecord(Model $record, array $attributes): bool
5555
}
5656

5757
/**
58-
* Delete an existing card.
58+
* Delete an existing record.
5959
*
60-
* @param Model $card The card to delete
60+
* @param Model $record The record to delete
6161
*/
62-
public function deleteRecord(Model $card): bool
62+
public function deleteRecord(Model $record): bool
6363
{
64-
return $card->delete();
64+
return $record->delete();
6565
}
6666

6767
/**
68-
* Update the order of cards in a column.
68+
* Update the order of records in a column.
6969
*
7070
* @param string|int $columnId The column ID
71-
* @param array<int, mixed> $cardIds The card IDs in their new order
71+
* @param array<int, mixed> $recordIds The record IDs in their new order
7272
* @return bool Whether the operation was successful
7373
*/
74-
public function updateRecordsOrderAndColumn(string | int $columnId, array $cardIds): bool
74+
public function updateRecordsOrderAndColumn(string | int $columnId, array $recordIds): bool
7575
{
7676
$orderField = $this->config->getOrderField();
7777
$columnField = $this->config->getColumnField();
7878
$success = true;
7979

80-
foreach ($cardIds as $index => $cardId) {
81-
$model = $this->getModelById($cardId);
80+
foreach ($recordIds as $index => $recordId) {
81+
$model = $this->getModelById($recordId);
8282

8383
if ($model === null) {
8484
$success = false;

src/Config/KanbanConfig.php

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@
2929
final readonly class KanbanConfig implements Wireable
3030
{
3131
public function __construct(
32-
private string $columnField = 'status',
33-
private array $columnValues = [],
34-
private ?array $columnColors = null,
35-
private string $titleField = 'title',
36-
private ?string $descriptionField = null,
37-
private array $cardAttributes = [],
38-
private ?string $orderField = null,
39-
private ?string $cardLabel = null,
40-
private ?string $pluralCardLabel = null,
41-
) {}
32+
private string $columnField = 'status',
33+
private array $columnValues = [],
34+
private array|bool|null $columnColors = null,
35+
private string $titleField = 'title',
36+
private ?string $descriptionField = null,
37+
private array $cardAttributes = [],
38+
private ?string $orderField = null,
39+
private ?string $cardLabel = null,
40+
private ?string $pluralCardLabel = null,
41+
)
42+
{
43+
}
4244

4345
/**
4446
* Get the field that stores the column value.
@@ -63,9 +65,9 @@ public function getColumnValues(): array
6365
/**
6466
* Get the colors for each column.
6567
*
66-
* @return array<string, string>|null Map of column values to color codes, or null if not set
68+
* @return array|bool|null Map of column values to color codes, or null if not set
6769
*/
68-
public function getColumnColors(): ?array
70+
public function getColumnColors(): array|bool|null
6971
{
7072
return $this->columnColors;
7173
}
@@ -133,8 +135,8 @@ public function getPluralCardLabel(): ?string
133135
/**
134136
* Get the default form schema for creating cards.
135137
*
136-
* @param string $titleField The field name used for card titles
137-
* @param string|null $descriptionField Optional field name for card descriptions
138+
* @param string $titleField The field name used for card titles
139+
* @param string|null $descriptionField Optional field name for card descriptions
138140
* @return array<\Filament\Forms\Components\Component> The default form schema
139141
*/
140142
public static function getDefaultCreateFormSchema(string $titleField, ?string $descriptionField): array
@@ -155,18 +157,19 @@ public static function getDefaultCreateFormSchema(string $titleField, ?string $d
155157
/**
156158
* Get the default form schema for editing cards.
157159
*
158-
* @param string $titleField The field name used for card titles
159-
* @param string|null $descriptionField Optional field name for card descriptions
160-
* @param string $columnField The field name that determines which column a card belongs to
161-
* @param array<string, string> $columnValues Available column values with their labels
160+
* @param string $titleField The field name used for card titles
161+
* @param string|null $descriptionField Optional field name for card descriptions
162+
* @param string $columnField The field name that determines which column a card belongs to
163+
* @param array<string, string> $columnValues Available column values with their labels
162164
* @return array<\Filament\Forms\Components\Component> The default form schema
163165
*/
164166
public static function getDefaultEditFormSchema(
165-
string $titleField,
167+
string $titleField,
166168
?string $descriptionField,
167-
string $columnField,
168-
array $columnValues
169-
): array {
169+
string $columnField,
170+
array $columnValues
171+
): array
172+
{
170173
$schema = [
171174
TextInput::make($titleField)
172175
->required()
@@ -192,21 +195,21 @@ public static function getDefaultEditFormSchema(
192195
* For example, `withColumnField('status')` will create a new configuration
193196
* with the columnField property set to 'status'.
194197
*
195-
* @param string $method The method name
196-
* @param array $arguments The method arguments
198+
* @param string $method The method name
199+
* @param array $arguments The method arguments
197200
* @return self A new instance with the updated property
198201
*
199202
* @throws \BadMethodCallException If the method is not a valid with* method or targets a non-existent property
200203
*/
201204
public function __call(string $method, array $arguments): self
202205
{
203-
if (! Str::startsWith($method, 'with')) {
206+
if (!Str::startsWith($method, 'with')) {
204207
throw new \BadMethodCallException("Method {$method} not found");
205208
}
206209

207210
$property = lcfirst(Str::after($method, 'with'));
208211

209-
if (! property_exists($this, $property)) {
212+
if (!property_exists($this, $property)) {
210213
throw new \BadMethodCallException("Property {$property} not found");
211214
}
212215

@@ -216,7 +219,7 @@ public function __call(string $method, array $arguments): self
216219
/**
217220
* Create a new configuration with the specified properties updated.
218221
*
219-
* @param array<string, mixed> $properties The properties to update
222+
* @param array<string, mixed> $properties The properties to update
220223
* @return self A new instance with the updated properties
221224
*/
222225
public function with(array $properties): self

src/Contracts/KanbanAdapterInterface.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,47 @@ public function getItemsForColumn(string | int $columnId, int $limit = 10): Coll
5050
public function getColumnItemsCount(string | int $columnId): int;
5151

5252
/**
53-
* Get the form for creating cards.
53+
* Get the form for creating records.
5454
*
5555
* @param Form $form The form instance
5656
* @param mixed $currentColumn The current column
5757
*/
5858
public function getCreateForm(Form $form, mixed $currentColumn): Form;
5959

6060
/**
61-
* Get the form for editing cards.
61+
* Get the form for editing records.
6262
*
6363
* @param Form $form The form instance
6464
*/
6565
public function getEditForm(Form $form): Form;
6666

6767
/**
68-
* Create a new card with the given attributes.
68+
* Create a new record with the given attributes.
6969
*
70-
* @param array<string, mixed> $attributes The card attributes
70+
* @param array<string, mixed> $attributes The record attributes
7171
*/
7272
public function createRecord(array $attributes): ?Model;
7373

7474
/**
75-
* Update an existing card with the given attributes.
75+
* Update an existing record with the given attributes.
7676
*
77-
* @param Model $card The card to update
78-
* @param array<string, mixed> $attributes The card attributes to update
77+
* @param Model $record The record to update
78+
* @param array<string, mixed> $attributes The record attributes to update
7979
*/
80-
public function updateRecord(Model $card, array $attributes): bool;
80+
public function updateRecord(Model $record, array $attributes): bool;
8181

8282
/**
83-
* Delete an existing card.
83+
* Delete an existing record.
8484
*
85-
* @param Model $card The card to delete
85+
* @param Model $record The record to delete
8686
*/
87-
public function deleteRecord(Model $card): bool;
87+
public function deleteRecord(Model $record): bool;
8888

8989
/**
90-
* Update the order of cards in a column.
90+
* Update the order of records in a column.
9191
*
9292
* @param string|int $columnId The column ID
93-
* @param array<int, mixed> $cardIds The card IDs in their new order
93+
* @param array<int, mixed> $recordIds The record IDs in their new order
9494
*/
95-
public function updateRecordsOrderAndColumn(string | int $columnId, array $cardIds): bool;
95+
public function updateRecordsOrderAndColumn(string | int $columnId, array $recordIds): bool;
9696
}

src/Filament/Pages/KanbanBoardPage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public function cardAttributes(array $attributes): static
9696
*
9797
* @param array<string, string> $colors
9898
*/
99-
public function columnColors(array $colors): static
99+
public function columnColors(?array $colors = null): static
100100
{
101-
$this->config = $this->config->withColumnColors($colors);
101+
$this->config = $this->config->withColumnColors($colors === null ? true : $colors);
102102

103103
return $this;
104104
}

0 commit comments

Comments
 (0)