Skip to content

Commit 462ff32

Browse files
committed
Further Column Trait Tidy Up
1 parent 2abb122 commit 462ff32

File tree

7 files changed

+100
-75
lines changed

7 files changed

+100
-75
lines changed

src/Views/Column.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class Column
99
{
1010
use IsColumn;
1111

12-
protected bool $displayColumnLabel = true;
13-
1412
protected string $view = '';
1513

1614
public function __construct(string $title, ?string $from = null)

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,6 @@ public function setTable(string $table): self
1818
return $this;
1919
}
2020

21-
public function unclickable(): self
22-
{
23-
$this->clickable = false;
24-
25-
return $this;
26-
}
27-
28-
public function setColumnLabelStatusDisabled(): self
29-
{
30-
$this->setColumnLabelStatus(false);
31-
32-
return $this;
33-
}
34-
35-
public function setColumnLabelStatusEnabled(): self
36-
{
37-
$this->setColumnLabelStatus(true);
38-
39-
return $this;
40-
}
41-
42-
public function setColumnLabelStatus(bool $status): void
43-
{
44-
$this->displayColumnLabel = $status;
45-
}
46-
47-
public function setHasTableRowUrl(bool $hasTableRowUrl): self
48-
{
49-
$this->hasTableRowUrl = $hasTableRowUrl;
50-
51-
return $this;
52-
}
53-
54-
public function setIsReorderColumn(bool $isReorderColumn): self
55-
{
56-
$this->isReorderColumn = $isReorderColumn;
57-
58-
return $this;
59-
}
6021

6122
public function setIndexes(int $rowIndex, int $columnIndex): self
6223
{
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits;
4+
5+
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
6+
7+
trait HasClickable
8+
{
9+
protected bool $clickable = true;
10+
11+
protected bool $hasTableRowUrl = false;
12+
13+
public function isClickable(): bool
14+
{
15+
return $this->clickable &&
16+
$this->getHasTableRowUrl() &&
17+
! $this instanceof LinkColumn;
18+
}
19+
20+
public function getHasTableRowUrl(): bool
21+
{
22+
return $this->hasTableRowUrl;
23+
}
24+
25+
public function unclickable(): self
26+
{
27+
$this->clickable = false;
28+
29+
return $this;
30+
}
31+
32+
public function setHasTableRowUrl(bool $hasTableRowUrl): self
33+
{
34+
$this->hasTableRowUrl = $hasTableRowUrl;
35+
36+
return $this;
37+
}
38+
39+
40+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits;
4+
5+
trait HasColumnLabelStatus
6+
{
7+
protected bool $displayColumnLabel = true;
8+
9+
public function getColumnLabelStatus(): bool
10+
{
11+
return $this->displayColumnLabel ?? true;
12+
}
13+
14+
public function setColumnLabelStatus(bool $status): self
15+
{
16+
$this->displayColumnLabel = $status;
17+
18+
return $this;
19+
}
20+
21+
public function setColumnLabelStatusEnabled(): self
22+
{
23+
return $this->setColumnLabelStatus(true);
24+
}
25+
26+
public function setColumnLabelStatusDisabled(): self
27+
{
28+
return $this->setColumnLabelStatus(false);
29+
}
30+
31+
}

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Support\HtmlString;
77
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
88
use Rappasoft\LaravelLivewireTables\Views\Column;
9-
use Rappasoft\LaravelLivewireTables\Views\Columns\LinkColumn;
109

1110
trait ColumnHelpers
1211
{
@@ -122,11 +121,6 @@ public function getValue(Model $row): mixed
122121
return $row->{$this->getRelationString().'.'.$this->getField()};
123122
}
124123

125-
public function isReorderColumn(): bool
126-
{
127-
return $this->isReorderColumn;
128-
}
129-
130124
public function isHtml(): bool
131125
{
132126
return $this->html === true;
@@ -145,28 +139,6 @@ public function view(string $view): self
145139
return $this;
146140
}
147141

148-
public function isClickable(): bool
149-
{
150-
return $this->clickable &&
151-
$this->getHasTableRowUrl() &&
152-
! $this instanceof LinkColumn;
153-
}
154-
155-
public function getColumnLabelStatus(): bool
156-
{
157-
return $this->displayColumnLabel ?? true;
158-
}
159-
160-
public function getHasTableRowUrl(): bool
161-
{
162-
return $this->hasTableRowUrl;
163-
}
164-
165-
public function getIsReorderColumn(): bool
166-
{
167-
return $this->isReorderColumn;
168-
}
169-
170142
public function getColumnIndex(): int
171143
{
172144
return $this->columnIndex;

src/Views/Columns/Traits/IsColumn.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ trait IsColumn
1111
{
1212
use HasLocalisations,
1313
HasDataTableComponent,
14+
IsReorderColumn,
15+
HasColumnLabelStatus,
1416
HasRelations,
1517
HasLabelFormat,
18+
HasClickable,
1619
HasSlug,
1720
ColumnConfiguration,
1821
ColumnHelpers,
@@ -45,12 +48,6 @@ trait IsColumn
4548

4649
protected bool $html = false;
4750

48-
protected bool $clickable = true;
49-
50-
protected bool $hasTableRowUrl = false;
51-
52-
protected bool $isReorderColumn = false;
53-
5451
protected ?int $columnIndex;
5552

5653
protected ?int $rowIndex;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Columns\Traits;
4+
5+
trait IsReorderColumn
6+
{
7+
protected bool $isReorderColumn = false;
8+
9+
public function isReorderColumn(): bool
10+
{
11+
return $this->isReorderColumn;
12+
}
13+
14+
public function getIsReorderColumn(): bool
15+
{
16+
return $this->isReorderColumn;
17+
}
18+
19+
public function setIsReorderColumn(bool $isReorderColumn): self
20+
{
21+
$this->isReorderColumn = $isReorderColumn;
22+
23+
return $this;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)