forked from rappasoft/laravel-livewire-tables
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added context menu and some customizations
Fix styling Fixed livewire dom sniffing issue in menu Fix styling Improve code after update from master Fix styling add hidden method to actions Fix styling Update CheckboxFilter.php add support of render html in link column
- Loading branch information
Showing
29 changed files
with
636 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
return [ | ||
'classes' => [ | ||
'bootstrap-5' => [ | ||
'loader-top' => 'bg-success p-0 py-0 rounded-0 text-center text-white', | ||
], | ||
], | ||
]; |
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,21 @@ | ||
@aware(['component']) | ||
|
||
<div> | ||
@foreach($component->actions as $action) | ||
@continue($action->isHidden()) | ||
<a {{ | ||
$attributes->merge($action->attributes) | ||
->class(['btn btn-sm btn-success' => ! $action->hasClass()]) | ||
}} | ||
@if($action->hasWireElement()) | ||
wire:{{ $action->getWireElementType() }}="{{ $action->getWireElementComponentName() }} , @js($action->getWireElementParams())" | ||
@endif | ||
> | ||
{{ $action->label }} | ||
|
||
@if($action->hasIcon()) | ||
<i class="ms-1 {{ $action->icon }}"></i> | ||
@endif | ||
</a> | ||
@endforeach | ||
</div> |
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
21 changes: 21 additions & 0 deletions
21
resources/views/components/tools/filters/checkbox.blade.php
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,21 @@ | ||
<div> | ||
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap /> | ||
|
||
<div @class([ | ||
"rounded-md shadow-sm" => $isTailwind, | ||
"mb-3 mb-md-0 input-group" => $isBootstrap, | ||
])> | ||
<div class="form-check"> | ||
<input | ||
wire:model.live="filterComponents.{{ $filter->getKey() }}" | ||
wire:key="{{ $filter->generateWireKey($tableName, 'text') }}" | ||
id="{{ $tableName }}-filter-{{ $filter->getKey() }}@if($filter->hasCustomPosition())-{{ $filter->getCustomPosition() }}@endif" | ||
type="checkbox" | ||
class="form-check-input" | ||
@checked($filter->getValue() == $filter->getFilterDefaultValue()) | ||
value="{{ $filter->getValue() }}" | ||
> | ||
<label class="form-check-label" for="{{ $filter->generateWireKey($tableName, 'text') }}">{{ $filter->getLabel() }}</label> | ||
</div> | ||
</div> | ||
</div> |
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,21 @@ | ||
<div> | ||
<x-livewire-tables::tools.filter-label :$filter :$filterLayout :$tableName :$isTailwind :$isBootstrap4 :$isBootstrap5 :$isBootstrap /> | ||
<div @class([ | ||
"rounded-md shadow-sm" => $isTailwind, | ||
"mb-3 mb-md-0 input-group" => $isBootstrap, | ||
])> | ||
<input | ||
wire:model.live="filterComponents.{{ $filter->getKey() }}" | ||
wire:key="{{ $filter->generateWireKey($tableName, 'date') }}" | ||
id="{{ $tableName }}-filter-{{ $filter->getKey() }}@if($filter->hasCustomPosition())-{{ $filter->getCustomPosition() }}@endif" | ||
type="month" | ||
@if($filter->hasConfig('min')) min="{{ $filter->getConfig('min') }}" @endif | ||
@if($filter->hasConfig('max')) max="{{ $filter->getConfig('max') }}" @endif | ||
@if($filter->hasConfig('placeholder')) placeholder="{{ $filter->getConfig('placeholder') }}" @endif | ||
@class([ | ||
"block w-full border-gray-300 rounded-md shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:text-white dark:border-gray-600" => $isTailwind, | ||
"form-control" => $isBootstrap, | ||
]) | ||
/> | ||
</div> | ||
</div> |
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,36 @@ | ||
@if($column->hasDivider() && $column->dividerPosition() == 'before') | ||
<div class="dropdown-divider"></div> | ||
@endif | ||
|
||
@if($form) | ||
<form class="d-inline" action="{{ $path }}" method="post"> | ||
@csrf | ||
@method($method) | ||
<button {!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}> | ||
@if($icon) | ||
<i class="{{ $icon }}"></i> | ||
@endif | ||
{{ __($title) }} | ||
</button> | ||
</form> | ||
@else | ||
<a | ||
href="{{ $path }}" | ||
@if($column->hasWireElement()) | ||
wire:{{ $column->getWireElementType() }}="{{ $column->getWireElementComponentName() }} , @js($column->getWireElementParams())" | ||
@endif | ||
|
||
{!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}> | ||
@if($icon) | ||
<i class="{{ $icon }}"></i> | ||
@endif | ||
{{ __($title) }} | ||
</a> | ||
@endif | ||
|
||
@if($column->hasDivider() && $column->dividerPosition() == 'after') | ||
<div class="dropdown-divider"></div> | ||
@endif | ||
|
||
|
||
|
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,17 @@ | ||
<div x-data="{ showDropdown: false }" x-init="showDropdown = $refs.dropdownMenu.children.length > 0"> | ||
<div class="dropdown"{!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}> | ||
{!! $title !!} | ||
<a x-show="showDropdown" href="#" class="dropdown-toggle arrow-none card-drop" data-bs-toggle="dropdown" aria-expanded="false"> | ||
<i class="far fa-ellipsis-h"></i> | ||
</a> | ||
<div class="dropdown-menu dropdown-menu-end py-0 z-10" x-ref="dropdownMenu" style="z-index: 10!important;"> | ||
@foreach($actions as $action) | ||
@continue((bool)$action->getContents($row) === false) | ||
<div> | ||
{!! $action->getContents($row) !!} | ||
</div> | ||
@endforeach | ||
</div> | ||
</div> | ||
|
||
</div> |
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,3 @@ | ||
<div class="overlay d-none" wire:loading.class.remove="d-none" | ||
x-init="$el.parentElement.style.position = 'relative'"> | ||
</div> |
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,11 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; | ||
|
||
trait CustomColumnConfiguration | ||
{ | ||
public function from(callable $callback): self | ||
{ | ||
return $this->label($callback); | ||
} | ||
} |
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,79 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
trait HasWireElement | ||
{ | ||
protected ?string $wireElementType = null; | ||
|
||
protected ?string $wireElementComponentName = null; | ||
|
||
protected array $wireElementParams = []; | ||
|
||
protected mixed $wireElementCallback = null; | ||
|
||
public function wireModal($component, $params = []): self | ||
{ | ||
$this->wireElementType = 'modal'; | ||
$this->wireElementComponentName = $component; | ||
$this->wireElementParams = $params; | ||
|
||
return $this; | ||
} | ||
|
||
public function wireSlideOver($component, $params = []): self | ||
{ | ||
$this->wireElementType = 'slide-over'; | ||
$this->wireElementComponentName = $component; | ||
$this->wireElementParams = $params; | ||
|
||
return $this; | ||
} | ||
|
||
public function wireElement(callable $callback): self | ||
{ | ||
$this->wireElementCallback = $callback; | ||
|
||
return $this; | ||
} | ||
|
||
public function getWireElementCallback(): ?callable | ||
{ | ||
return $this->wireElementCallback; | ||
} | ||
|
||
public function hasWireElementCallback(): bool | ||
{ | ||
return $this->wireElementCallback !== null; | ||
} | ||
|
||
public function setWireElement(Model $row): void | ||
{ | ||
$wireElement = $this->hasWireElementCallback() ? app()->call($this->getWireElementCallback(), ['row' => $row]) : []; | ||
$this->wireElementType = $wireElement['type'] ?? null; | ||
$this->wireElementComponentName = $wireElement['component'] ?? null; | ||
$this->wireElementParams = $wireElement['params'] ?? []; | ||
} | ||
|
||
public function hasWireElement(): bool | ||
{ | ||
return $this->wireElementComponentName !== null; | ||
} | ||
|
||
public function getWireElementComponentName(): ?string | ||
{ | ||
return $this->wireElementComponentName; | ||
} | ||
|
||
public function getWireElementType(): ?string | ||
{ | ||
return $this->wireElementType; | ||
} | ||
|
||
public function getWireElementParams(): array | ||
{ | ||
return $this->wireElementParams; | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Views\Columns; | ||
|
||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Contracts\View\Factory; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\HtmlString; | ||
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException; | ||
use Rappasoft\LaravelLivewireTables\Views\Column; | ||
use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\MenuColumnConfiguration; | ||
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasTitleCallback; | ||
use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\MenuColumnHelpers; | ||
|
||
class MenuColumn extends Column | ||
{ | ||
use MenuColumnConfiguration, | ||
MenuColumnHelpers; | ||
use HasTitleCallback; | ||
|
||
protected array $actions = []; | ||
|
||
protected string $view = 'livewire-tables::includes.columns.menu'; | ||
|
||
public function __construct(string $title, ?string $from = null) | ||
{ | ||
parent::__construct($title, $from); | ||
|
||
$this->label(fn () => null); | ||
} | ||
|
||
public function getContents(Model $row): null|string|HtmlString|DataTableConfigurationException|Application|Factory|View | ||
{ | ||
return view($this->getView()) | ||
->withColumn($this) | ||
->withTitle($this->hasTitleCallback() ? app()->call($this->getTitleCallback(), ['row' => $row]) : '') | ||
->withRow($row) | ||
->withActions($this->getActions()) | ||
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []); | ||
} | ||
} |
Oops, something went wrong.