-
-
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 a new built-in `RedirectRowAction`, that is now used to render the pre-configured `ShowRowAction` * Added an optional second argument `bool $openInNewWindow = false` to the `ShowRowAction` * Added a new pre-configured `AddHeadAction`, that is using the built-in `RedirectHeadAction` * Added a new `Add` translation for it that you'll have to add to [your own translations](/README.md#translations) * Added a new `config('laravel-table.icon.add')` config for it with the `<i class="fa-solid fa-circle-plus fa-fw"></i>` default value that you'll also have to add to [your published configuration file](/README.md#configuration)
- Loading branch information
Showing
9 changed files
with
150 additions
and
26 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 AddHeadAction extends AbstractHeadAction | ||
{ | ||
protected RedirectHeadAction $redirectHeadAction; | ||
|
||
public function __construct(public string $createUrl, bool $openInNewWindow = false) | ||
{ | ||
$this->redirectHeadAction = new RedirectHeadAction( | ||
url: $createUrl, | ||
label: __('Add'), | ||
icon: config('laravel-table.icon.add'), | ||
openInNewWindow: $openInNewWindow | ||
); | ||
} | ||
|
||
protected function class(): array | ||
{ | ||
return $this->redirectHeadAction->class(); | ||
} | ||
|
||
protected function title(): string | ||
{ | ||
return $this->redirectHeadAction->title(); | ||
} | ||
|
||
protected function icon(): string | ||
{ | ||
return $this->redirectHeadAction->icon(); | ||
} | ||
|
||
public function action(Component $livewire): void | ||
{ | ||
$this->redirectHeadAction->action($livewire); | ||
} | ||
} |
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,60 @@ | ||
<?php | ||
|
||
namespace Okipa\LaravelTable\RowActions; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Str; | ||
use Livewire\Component; | ||
use Okipa\LaravelTable\Abstracts\AbstractRowAction; | ||
|
||
class RedirectRowAction extends AbstractRowAction | ||
{ | ||
public function __construct( | ||
public string $url, | ||
public string $title, | ||
public string $icon, | ||
public array $class = ['link-info'], | ||
public string|null $defaultConfirmationQuestion = null, | ||
public string|null $defaultFeedbackMessage = null, | ||
public bool $openInNewWindow = false, | ||
) { | ||
// | ||
} | ||
|
||
protected function identifier(): string | ||
{ | ||
return 'row_action_' . Str::snake($this->title); | ||
} | ||
|
||
protected function class(Model $model): array | ||
{ | ||
return $this->class; | ||
} | ||
|
||
protected function icon(Model $model): string | ||
{ | ||
return $this->icon; | ||
} | ||
|
||
protected function title(Model $model): string | ||
{ | ||
return $this->title; | ||
} | ||
|
||
protected function defaultConfirmationQuestion(Model $model): string|null | ||
{ | ||
return $this->defaultConfirmationQuestion; | ||
} | ||
|
||
protected function defaultFeedbackMessage(Model $model): string|null | ||
{ | ||
return $this->defaultFeedbackMessage; | ||
} | ||
|
||
public function action(Model $model, 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