-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathOverlookPlugin.php
More file actions
149 lines (111 loc) · 3.31 KB
/
Copy pathOverlookPlugin.php
File metadata and controls
149 lines (111 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
namespace Awcodes\Overlook;
use Closure;
use Filament\Contracts\Plugin;
use Filament\Forms\ComponentContainer;
use Filament\Forms\Concerns\HasColumns;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
class OverlookPlugin implements Plugin
{
use EvaluatesClosures;
use HasColumns;
protected array | Closure | null $excludes = null;
protected array | Closure | null $includes = null;
protected bool | Closure | null $shouldAbbreviateCount = null;
protected bool | Closure | null $shouldShowTooltips = null;
protected bool | Closure | null $shouldSortAlphabetical = null;
protected int | Closure | null $sort = null;
protected array | Closure | null $icons = null;
public static function make(): OverlookPlugin
{
return app(self::class);
}
public static function get(): static
{
return filament(app(static::class)->getId());
}
public function getId(): string
{
return 'awcodes/overlook';
}
public function register(Panel $panel): void {}
public function boot(Panel $panel): void {}
public function alphabetical(bool | Closure | null $condition = true): static
{
$this->shouldSortAlphabetical = $condition;
return $this;
}
public function abbreviateCount(bool | Closure | null $condition = true): static
{
$this->shouldAbbreviateCount = $condition;
return $this;
}
public function excludes(array | Closure $resources): static
{
$this->excludes = $resources;
return $this;
}
public function getColumnsConfig(): array
{
if ($this instanceof ComponentContainer && $this->getParentComponent()) {
return $this->getParentComponent()->getColumnsConfig();
}
return $this->columns ?? [
'default' => 2,
'sm' => 2,
'md' => 3,
'lg' => 4,
'xl' => 5,
'2xl' => null,
];
}
public function getExcludes(): array
{
return $this->evaluate($this->excludes) ?? [];
}
public function getIncludes(): array
{
return $this->evaluate($this->includes) ?? [];
}
public function getSort(): int
{
return $this->evaluate($this->sort) ?? -1;
}
public function includes(array | Closure $resources): static
{
$this->includes = $resources;
return $this;
}
public function shouldAbbreviateCount(): bool
{
return $this->evaluate($this->shouldAbbreviateCount) ?? true;
}
public function shouldShowTooltips(): bool
{
return $this->evaluate($this->shouldShowTooltips) ?? true;
}
public function shouldSortAlphabetical(): bool
{
return $this->evaluate($this->shouldSortAlphabetical) ?? false;
}
public function sort(int | Closure $sort): static
{
$this->sort = $sort;
return $this;
}
public function tooltips(bool | Closure | null $condition = true): static
{
$this->shouldShowTooltips = $condition;
return $this;
}
public function icons(array | Closure | null $icons): static
{
$this->icons = $icons;
return $this;
}
public function getIcons(): array
{
return $this->evaluate($this->icons) ?? [];
}
}