Skip to content

Commit bf02f7a

Browse files
committed
Additional Trait Splits
1 parent f868fbe commit bf02f7a

File tree

8 files changed

+41
-61
lines changed

8 files changed

+41
-61
lines changed

src/Views/Columns/ComponentColumn.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
use Rappasoft\LaravelLivewireTables\Views\Column;
1010
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ComponentColumnConfiguration;
1111
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\ComponentColumnHelpers;
12+
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\{HasComponentView,HasSlot};
1213

1314
class ComponentColumn extends Column
1415
{
15-
use ComponentColumnConfiguration,
16+
use HasComponentView,
17+
HasSlot,
18+
ComponentColumnConfiguration,
1619
ComponentColumnHelpers;
1720

18-
protected string $componentView;
19-
20-
protected mixed $slotCallback = null;
21-
2221
public function __construct(string $title, ?string $from = null)
2322
{
2423
parent::__construct($title, $from);

src/Views/Columns/Traits/Configuration/ColumnConfiguration.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ public function unclickable(): self
5050
return $this;
5151
}
5252

53-
public function setCustomSlug(string $customSlug): self
54-
{
55-
$this->customSlug = $customSlug;
56-
57-
return $this;
58-
}
59-
6053
public function setColumnLabelStatusDisabled(): self
6154
{
6255
$this->setColumnLabelStatus(false);

src/Views/Columns/Traits/Configuration/ComponentColumnConfiguration.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,4 @@
33
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration;
44

55
trait ComponentColumnConfiguration
6-
{
7-
public function component(string $component): self
8-
{
9-
$this->componentView = 'components.'.$component;
10-
11-
return $this;
12-
}
13-
14-
public function slot(callable $callback): self
15-
{
16-
$this->slotCallback = $callback;
17-
18-
return $this;
19-
}
20-
}
6+
{}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits;
4+
5+
trait HasCustomSlug
6+
{
7+
protected ?string $customSlug = null;
8+
9+
public function getCustomSlug(): string
10+
{
11+
return $this->customSlug;
12+
}
13+
14+
public function hasCustomSlug(): bool
15+
{
16+
return $this->customSlug !== null;
17+
}
18+
19+
public function setCustomSlug(string $customSlug): self
20+
{
21+
$this->customSlug = $customSlug;
22+
23+
return $this;
24+
}
25+
26+
27+
}

src/Views/Columns/Traits/Helpers/ColumnHelpers.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,6 @@ public function isClickable(): bool
183183
! $this instanceof LinkColumn;
184184
}
185185

186-
public function getCustomSlug(): string
187-
{
188-
return $this->customSlug;
189-
}
190-
191-
public function hasCustomSlug(): bool
192-
{
193-
return $this->customSlug !== null;
194-
}
195-
196186
public function getColumnLabelStatus(): bool
197187
{
198188
return $this->displayColumnLabel ?? true;

src/Views/Columns/Traits/Helpers/ComponentColumnHelpers.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,4 @@
33
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers;
44

55
trait ComponentColumnHelpers
6-
{
7-
public function getSlotCallback(): ?callable
8-
{
9-
return $this->slotCallback;
10-
}
11-
12-
public function hasSlotCallback(): bool
13-
{
14-
return $this->slotCallback !== null;
15-
}
16-
17-
public function getComponentView(): string
18-
{
19-
return $this->componentView;
20-
}
21-
22-
public function hasComponentView(): bool
23-
{
24-
return isset($this->componentView);
25-
}
26-
}
6+
{}

src/Views/Columns/Traits/IsColumn.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use Rappasoft\LaravelLivewireTables\Traits\Core\HasLocalisations;
66
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Configuration\ColumnConfiguration;
77
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\Helpers\{ColumnHelpers,RelationshipHelpers};
8-
use Rappasoft\LaravelLivewireTables\Views\Columns\Traits\{HasColumnView, HasFooter, HasSecondaryHeader, HasVisibility, IsCollapsible, IsSearchable, IsSelectable, IsSortable};
98
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasAttributes, HasLabelAttributes, HasTheme};
109

1110
trait IsColumn
1211
{
1312
use HasLocalisations,
1413
HasDataTableComponent,
14+
HasCustomSlug,
1515
ColumnConfiguration,
1616
ColumnHelpers,
1717
RelationshipHelpers,
@@ -55,8 +55,6 @@ trait IsColumn
5555

5656
protected bool $clickable = true;
5757

58-
protected ?string $customSlug = null;
59-
6058
protected bool $hasTableRowUrl = false;
6159

6260
protected bool $isReorderColumn = false;

tests/Unit/Views/Columns/ColumnTestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ public function test_can_set_the_column_component(): void
3636

3737
$this->assertSame($this->basicTable, self::$columnInstance->getComponent());
3838
}
39+
40+
public function test_can_check_if_is_reorder_column(): void
41+
{
42+
$this->assertFalse(self::$columnInstance->isReorderColumn());
43+
44+
}
45+
3946
}

0 commit comments

Comments
 (0)