mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Sort
This commit is contained in:
@@ -8,8 +8,6 @@ use Laravel\SerializableClosure\Serializers\Native;
|
||||
|
||||
class MenuItem extends Component
|
||||
{
|
||||
protected string | Closure | null $postAction = null;
|
||||
|
||||
/**
|
||||
* @var string | array{50: string, 100: string, 200: string, 300: string, 400: string, 500: string, 600: string, 700: string, 800: string, 900: string, 950: string} | Closure | null
|
||||
*/
|
||||
@@ -19,6 +17,8 @@ class MenuItem extends Component
|
||||
|
||||
protected string | Closure | null $label = null;
|
||||
|
||||
protected string | Closure | null $postAction = null;
|
||||
|
||||
protected int | Closure | null $sort = null;
|
||||
|
||||
protected string | Closure | Native | null $url = null;
|
||||
@@ -65,6 +65,13 @@ class MenuItem extends Component
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function postAction(string | Closure | null $action): static
|
||||
{
|
||||
$this->postAction = $action;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function sort(int | Closure | null $sort): static
|
||||
{
|
||||
$this->sort = $sort;
|
||||
@@ -80,13 +87,6 @@ class MenuItem extends Component
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function postAction(string | Closure | null $action): static
|
||||
{
|
||||
$this->postAction = $action;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function openUrlInNewTab(bool | Closure $condition = true): static
|
||||
{
|
||||
$this->shouldOpenUrlInNewTab = $condition;
|
||||
@@ -140,6 +140,11 @@ class MenuItem extends Component
|
||||
return $this->evaluate($this->label);
|
||||
}
|
||||
|
||||
public function getPostAction(): ?string
|
||||
{
|
||||
return $this->evaluate($this->postAction);
|
||||
}
|
||||
|
||||
public function getSort(): int
|
||||
{
|
||||
return $this->evaluate($this->sort) ?? -1;
|
||||
@@ -150,11 +155,6 @@ class MenuItem extends Component
|
||||
return $this->evaluate($this->url);
|
||||
}
|
||||
|
||||
public function getPostAction(): ?string
|
||||
{
|
||||
return $this->evaluate($this->postAction);
|
||||
}
|
||||
|
||||
public function shouldOpenUrlInNewTab(): bool
|
||||
{
|
||||
return (bool) $this->evaluate($this->shouldOpenUrlInNewTab);
|
||||
|
||||
Reference in New Issue
Block a user