-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added ability to chain a `->when(bool $condition)` method to an instantiated head action, in order to enable it conditionally * Added a new built-in `RedirectHeadAction`, that will be used by the pre-configured `CreateHeadAction` * Added an optional `bool $openInNewWindow = false` to the `CreateHeadAction` * Added a new [JavaScript snippet](/README.md#set-up-a-few-lines-of-javascript) to handle head action link opening in tab: you'll have to add it if you want to benefit from this new ability
- Loading branch information
Showing
9 changed files
with
154 additions
and
22 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
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,41 @@ | ||
<?php | ||
|
||
namespace Okipa\LaravelTable\HeadActions; | ||
|
||
use Livewire\Component; | ||
use Okipa\LaravelTable\Abstracts\AbstractHeadAction; | ||
|
||
class RedirectHeadAction extends AbstractHeadAction | ||
{ | ||
public function __construct( | ||
public string $url, | ||
public string $label, | ||
public string $icon, | ||
public array $class = ['btn', 'btn-success'], | ||
public bool $openInNewWindow = false, | ||
) { | ||
// | ||
} | ||
|
||
protected function class(): array | ||
{ | ||
return $this->class; | ||
} | ||
|
||
protected function title(): string | ||
{ | ||
return __($this->label); | ||
} | ||
|
||
protected function icon(): string | ||
{ | ||
return $this->icon; | ||
} | ||
|
||
public function action(Component $livewire): void | ||
{ | ||
$this->openInNewWindow | ||
? $livewire->emit('laraveltable:link:open:newtab', $this->url) | ||
: redirect()->to($this->url); | ||
} | ||
} |
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