-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add displayActionsInToolbar and actionsPosition * Add docs and tests for setActionsInToolbar * Fix styling --------- Co-authored-by: lrljoe <[email protected]>
- Loading branch information
Showing
11 changed files
with
376 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; | ||
|
||
trait ActionsConfiguration | ||
{ | ||
public function setActionWrapperAttributes(array $actionWrapperAttributes): self | ||
{ | ||
$this->actionWrapperAttributes = [...$this->actionWrapperAttributes, ...$actionWrapperAttributes]; | ||
|
||
return $this; | ||
} | ||
|
||
public function setActionsInToolbar(bool $status): self | ||
{ | ||
$this->displayActionsInToolbar = $status; | ||
|
||
return $this; | ||
} | ||
|
||
public function setActionsInToolbarEnabled(): self | ||
{ | ||
return $this->setActionsInToolbar(true); | ||
} | ||
|
||
public function setActionsInToolbarDisabled(): self | ||
{ | ||
return $this->setActionsInToolbar(false); | ||
} | ||
|
||
protected function setActionsPosition(string $position): self | ||
{ | ||
$this->actionsPosition = ($position == 'left' || $position == 'center' || $position == 'right') ? $position : 'right'; | ||
|
||
return $this; | ||
} | ||
|
||
public function setActionsLeft(): self | ||
{ | ||
return $this->setActionsPosition('left'); | ||
} | ||
|
||
public function setActionsCenter(): self | ||
{ | ||
return $this->setActionsPosition('center'); | ||
} | ||
|
||
public function setActionsRight(): self | ||
{ | ||
return $this->setActionsPosition('right'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Helpers; | ||
|
||
use Illuminate\Support\Collection; | ||
use Livewire\Attributes\Computed; | ||
use Rappasoft\LaravelLivewireTables\Views\Action; | ||
|
||
trait ActionsHelpers | ||
{ | ||
#[Computed] | ||
public function showActionsInToolbar(): bool | ||
{ | ||
return $this->displayActionsInToolbar ?? false; | ||
} | ||
|
||
#[Computed] | ||
public function getActionsPosition(): string | ||
{ | ||
return $this->actionsPosition ?? 'right'; | ||
} | ||
|
||
#[Computed] | ||
public function getActionWrapperAttributes(): array | ||
{ | ||
return [...['class' => '', 'default-styling' => true, 'default-colors' => true], ...$this->actionWrapperAttributes]; | ||
} | ||
|
||
#[Computed] | ||
public function hasActions(): bool | ||
{ | ||
return (new Collection($this->actions())) | ||
->filter(fn ($action) => $action instanceof Action)->count() > 0; | ||
} | ||
|
||
#[Computed] | ||
public function getActions(): Collection | ||
{ | ||
return (new Collection($this->actions())) | ||
->filter(fn ($action) => $action instanceof Action) | ||
->each(function (Action $action, int $key) { | ||
$action->setTheme($this->getTheme()); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.