Skip to content

Commit 1aa9cc2

Browse files
committed
wip
1 parent e14566f commit 1aa9cc2

71 files changed

Lines changed: 1403 additions & 897 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Concerns/Forms/HasColor.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/Concerns/Forms/HasComponentActions.php

Lines changed: 0 additions & 40 deletions
This file was deleted.

app/Concerns/Forms/HasFooter.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/Concerns/Forms/HasHeader.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/Concerns/Forms/HasIcon.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/Concerns/Forms/HasSize.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

app/Concerns/Forms/HasTitle.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

app/Concerns/HasBooleanLabels.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Concerns;
6+
7+
use Closure;
8+
9+
trait HasBooleanLabels
10+
{
11+
protected string | Closure | null $trueLabel = null;
12+
13+
protected string | Closure | null $falseLabel = null;
14+
15+
public function trueLabel(string | Closure | null $label): static
16+
{
17+
$this->trueLabel = $label;
18+
19+
return $this;
20+
}
21+
22+
public function falseLabel(string | Closure | null $label): static
23+
{
24+
$this->falseLabel = $label;
25+
26+
return $this;
27+
}
28+
29+
public function getTrueLabel(): string
30+
{
31+
return $this->evaluate($this->trueLabel) ?? __('filament-forms::components.select.boolean.true');
32+
}
33+
34+
public function getFalseLabel(): string
35+
{
36+
return $this->evaluate($this->falseLabel) ?? __('filament-forms::components.select.boolean.false');
37+
}
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Filament\Infolists\Components;
6+
7+
use App\Concerns\HasBooleanLabels;
8+
use Filament\Infolists\Components\Entry;
9+
10+
class BooleanEntry extends Entry
11+
{
12+
use HasBooleanLabels;
13+
14+
protected string $view = 'filament.infolists.components.boolean-entry';
15+
16+
public function getState(): string
17+
{
18+
$state = parent::getState();
19+
20+
return \boolval($state)
21+
? $this->getTrueLabel()
22+
: $this->getFalseLabel();
23+
}
24+
}

app/Forms/Components/DocumentPreview.php renamed to app/Filament/Infolists/Components/DocumentPreview.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Forms\Components;
5+
namespace App\Filament\Infolists\Components;
66

77
use App\Models\Media;
88
use Closure;
9-
use Filament\Schemas\Components\Component;
9+
use Filament\Infolists\Components\Entry;
1010

11-
class DocumentPreview extends Component
11+
class DocumentPreview extends Entry
1212
{
13-
protected string $view = 'forms.components.document-preview';
13+
protected string $view = 'filament.infolists.components.document-preview';
1414

1515
protected string | Closure $collection = 'default';
1616

17-
public static function make(): static
18-
{
19-
$static = app(static::class);
20-
$static->configure();
21-
22-
return $static;
23-
}
24-
2517
public function collection(string | Closure $collection = 'default'): static
2618
{
2719
$this->collection = $collection;
@@ -34,7 +26,12 @@ public function getCollection(): string
3426
return $this->evaluate($this->collection);
3527
}
3628

37-
public function getFile(): ?Media
29+
public static function getDefaultName(): ?string
30+
{
31+
return 'preview';
32+
}
33+
34+
public function getState(): ?Media
3835
{
3936
return $this->getRecord()
4037
->getFirstMedia($this->getCollection());

0 commit comments

Comments
 (0)