Skip to content

Commit 2d414d2

Browse files
committed
Tweaks to Base
1 parent a4f320b commit 2d414d2

File tree

10 files changed

+136
-91
lines changed

10 files changed

+136
-91
lines changed

src/Views/Filters/Traits/FilterConfiguration.php

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

55
trait FilterConfiguration
66
{
7-
public function notResetByClearButton(): self
8-
{
9-
$this->resetByClearButton = false;
10-
11-
return $this;
12-
}
137

14-
/**
15-
* Sets a Default Value via the Filter Component
16-
*
17-
* @param mixed $value
18-
*/
19-
public function setFilterDefaultValue($value): self
20-
{
21-
$this->filterDefaultValue = $value;
22-
23-
return $this;
24-
}
258

269
public function setGenericDisplayData(array $genericDisplayData = []): self
2710
{

src/Views/Filters/Traits/FilterHelpers.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ public function getKeys(): array
3232
return [];
3333
}
3434

35-
/**
36-
* Get the filter options.
37-
*/
38-
public function getDefaultValue(): mixed
39-
{
40-
return null;
41-
}
4235

4336
public function filter(callable $callback): Filter
4437
{
@@ -57,18 +50,6 @@ public function getFilterCallback(): callable
5750
return $this->filterCallback;
5851
}
5952

60-
public function isResetByClearButton(): bool
61-
{
62-
return $this->resetByClearButton === true;
63-
}
64-
65-
/**
66-
* Determines if the Filter has a Default Value via the Component
67-
*/
68-
public function hasFilterDefaultValue(): bool
69-
{
70-
return ! is_null($this->filterDefaultValue);
71-
}
7253

7354
public function generateWireKey(string $tableName, string $filterType, string $extraData = ''): string
7455
{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits;
4+
5+
trait HandlesClearButton
6+
{
7+
protected bool $resetByClearButton = true;
8+
9+
public function isResetByClearButton(): bool
10+
{
11+
return $this->resetByClearButton === true;
12+
}
13+
14+
public function notResetByClearButton(): self
15+
{
16+
$this->resetByClearButton = false;
17+
18+
return $this;
19+
}
20+
21+
22+
}

src/Views/Filters/Traits/HandlesDates.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits;
44

5+
use Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Pills\HandlesPillsLocale;
56
use Carbon\Carbon;
67

78
trait HandlesDates
89
{
9-
use HasPillsLocale;
10+
use HandlesPillsLocale;
1011

1112
protected string $inputDateFormat;
1213

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits;
4+
5+
trait HandlesDefaultValue
6+
{
7+
8+
protected mixed $filterDefaultValue = null;
9+
10+
/**
11+
* Sets a Default Value via the Filter Component
12+
*
13+
* @param mixed $value
14+
*/
15+
public function setFilterDefaultValue($value): self
16+
{
17+
$this->filterDefaultValue = $value;
18+
19+
return $this;
20+
}
21+
22+
/**
23+
* Get the filter options.
24+
*/
25+
public function getDefaultValue(): mixed
26+
{
27+
return null;
28+
}
29+
/**
30+
* Determines if the Filter has a Default Value via the Component
31+
*/
32+
public function hasFilterDefaultValue(): bool
33+
{
34+
return ! is_null($this->filterDefaultValue);
35+
}
36+
37+
}

src/Views/Filters/Traits/HasFilterPills.php

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits;
44

55
use Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Styling\HandlesFilterPillsAttributes;
6+
use Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Pills\{HandlesPillsAsHtml,HandlesPillsCustomBlade,HandlesPillsLocale};
67

78
trait HasFilterPills
89
{
9-
use HandlesFilterPillsAttributes;
10+
use HandlesPillsAsHtml,
11+
HandlesPillsCustomBlade,
12+
HandlesPillsLocale,
13+
HandlesFilterPillsAttributes;
1014

1115
protected ?string $filterPillTitle = null;
1216

1317
protected array $filterPillValues = [];
1418

15-
protected ?string $filterCustomPillBlade = null;
1619

17-
protected bool $pillsAsHtml = false;
1820

1921
public function setFilterPillTitle(string $title): self
2022
{
@@ -33,12 +35,6 @@ public function setFilterPillValues(array $values): self
3335
return $this;
3436
}
3537

36-
public function setFilterPillBlade(string $blade): self
37-
{
38-
$this->filterCustomPillBlade = $blade;
39-
40-
return $this;
41-
}
4238

4339
public function getCustomFilterPillTitle(): ?string
4440
{
@@ -71,41 +67,5 @@ public function getCustomFilterPillValue(string $value): ?string
7167
return $this->getCustomFilterPillValues()[$value] ?? null;
7268
}
7369

74-
/**
75-
* Determine if filter has a Custom Pill Blade
76-
*/
77-
public function hasCustomPillBlade(): bool
78-
{
79-
return $this->filterCustomPillBlade != null;
80-
}
81-
82-
/**
83-
* Get the path to the Custom Pill Blade
84-
*/
85-
public function getCustomPillBlade(): ?string
86-
{
87-
return $this->filterCustomPillBlade;
88-
}
89-
90-
public function getPillsAreHtml(): bool
91-
{
92-
return $this->pillsAsHtml ?? false;
93-
}
9470

95-
public function setPillsAsHtml(bool $status = true): self
96-
{
97-
$this->pillsAsHtml = $status;
98-
99-
return $this;
100-
}
101-
102-
public function setPillsAsHtmlEnabled(): self
103-
{
104-
return $this->setPillsAsHtml(true);
105-
}
106-
107-
public function setPillsAsHtmlDisabled(): self
108-
{
109-
return $this->setPillsAsHtml(false);
110-
}
11171
}

src/Views/Filters/Traits/IsFilter.php

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

99
trait IsFilter
1010
{
11-
use HasLocalisations,
11+
use HandlesDefaultValue,
12+
HasLocalisations,
1213
HasFilterPills,
1314
HasFilterLabel,
1415
FilterConfiguration,
@@ -18,17 +19,14 @@ trait IsFilter
1819
HasLabelAttributes,
1920
HasVisibility,
2021
HasView,
21-
HandlesFilterInputAttributes;
22+
HandlesFilterInputAttributes,
23+
HandlesClearButton;
2224

2325
protected string $name;
2426

2527
protected string $key;
2628

27-
protected bool $resetByClearButton = true;
28-
2929
protected mixed $filterCallback = null;
3030

31-
protected mixed $filterDefaultValue = null;
32-
3331
public array $genericDisplayData = [];
3432
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Pills;
4+
5+
trait HandlesPillsAsHtml
6+
{
7+
protected bool $pillsAsHtml = false;
8+
9+
public function getPillsAreHtml(): bool
10+
{
11+
return $this->pillsAsHtml ?? false;
12+
}
13+
14+
public function setPillsAsHtml(bool $status = true): self
15+
{
16+
$this->pillsAsHtml = $status;
17+
18+
return $this;
19+
}
20+
21+
public function setPillsAsHtmlEnabled(): self
22+
{
23+
return $this->setPillsAsHtml(true);
24+
}
25+
26+
public function setPillsAsHtmlDisabled(): self
27+
{
28+
return $this->setPillsAsHtml(false);
29+
}
30+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Pills;
4+
5+
trait HandlesPillsCustomBlade
6+
{
7+
protected ?string $filterCustomPillBlade = null;
8+
9+
public function setFilterPillBlade(string $blade): self
10+
{
11+
$this->filterCustomPillBlade = $blade;
12+
13+
return $this;
14+
}
15+
16+
17+
/**
18+
* Determine if filter has a Custom Pill Blade
19+
*/
20+
public function hasCustomPillBlade(): bool
21+
{
22+
return $this->filterCustomPillBlade != null;
23+
}
24+
25+
/**
26+
* Get the path to the Custom Pill Blade
27+
*/
28+
public function getCustomPillBlade(): ?string
29+
{
30+
return $this->filterCustomPillBlade;
31+
}
32+
}

src/Views/Filters/Traits/HasPillsLocale.php renamed to src/Views/Filters/Traits/Pills/HandlesPillsLocale.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits;
3+
namespace Rappasoft\LaravelLivewireTables\Views\Filters\Traits\Pills;
44

5-
trait HasPillsLocale
5+
trait HandlesPillsLocale
66
{
77
protected ?string $pillsLocale;
88

@@ -22,4 +22,5 @@ public function getPillsLocale(): string
2222
{
2323
return isset($this->pillsLocale) ? $this->pillsLocale : ($this->getConfig('locale') ?? config('app.locale', 'en'));
2424
}
25-
}
25+
26+
}

0 commit comments

Comments
 (0)