-
-
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.
- Loading branch information
Showing
23 changed files
with
253 additions
and
102 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
resources/views/components/tools/filters/livewire-component-filter.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 @@ | ||
<livewire:dynamic-component :key="$wirekey" :is=$livewireComponent wire:model="{{ $modelableValue }}" /> |
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,48 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\DataTransferObjects; | ||
|
||
use Rappasoft\LaravelLivewireTables\DataTableComponent; | ||
use Rappasoft\LaravelLivewireTables\Views\Filter; | ||
|
||
class FilterRenderData | ||
{ | ||
public DataTableComponent $component; | ||
|
||
public array $globalData = []; | ||
|
||
public function __construct(DataTableComponent $component) | ||
{ | ||
$this->component = $component; | ||
|
||
$this->setupGlobalData(); | ||
} | ||
|
||
protected function setupGlobalData() | ||
{ | ||
$this->globalData = [ | ||
'filterLayout' => $this->component->getFilterLayout(), | ||
'tableName' => $this->component->getTableName(), | ||
'isTailwind' => $this->component->isTailwind(), | ||
'isBootstrap' => $this->component->isBootstrap(), | ||
'isBootstrap4' => $this->component->isBootstrap4(), | ||
'isBootstrap5' => $this->component->isBootstrap5(), | ||
'filter' => null, | ||
'filter-key' => null, | ||
'filter-id' => null, | ||
]; | ||
} | ||
|
||
public function filterDataToArray(Filter $filter): array | ||
{ | ||
$tempArray = $this->globalData; | ||
$tempArray['filter'] = $filter; | ||
|
||
return $tempArray; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return $this->globalData; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -156,4 +156,6 @@ public function setSearchFieldAttributes(array $attributes = []): self | |
|
||
return $this; | ||
} | ||
|
||
|
||
} |
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
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,78 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Views\Filters; | ||
|
||
use Rappasoft\LaravelLivewireTables\Views\Filter; | ||
use Illuminate\Support\Str; | ||
|
||
class LivewireComponentFilter extends Filter | ||
{ | ||
public string $filterComponentPath = ''; | ||
public array $filterComponentOptions = []; | ||
|
||
public function validate(mixed $value): mixed | ||
{ | ||
return $value; | ||
} | ||
|
||
public function isEmpty($value): bool | ||
{ | ||
return $value === ''; | ||
} | ||
|
||
/** | ||
* Gets the Default Value for this Filter via the Component | ||
*/ | ||
public function getFilterDefaultValue(): ?string | ||
{ | ||
return $this->filterDefaultValue ?? null; | ||
} | ||
|
||
public function setFilterComponentPath(string $filterComponentPath): self | ||
{ | ||
$this->filterComponentPath = (Str::startsWith($filterComponentPath, 'livewire:')) ? substr($filterComponentPath, 9) : $filterComponentPath; | ||
|
||
return $this; | ||
} | ||
|
||
public function setFilterComponentOptions(array $filterComponentOptions): self | ||
{ | ||
$this->filterComponentOptions = $filterComponentOptions; | ||
|
||
return $this; | ||
} | ||
|
||
public function config(array $config = []): LivewireComponentFilter | ||
{ | ||
$this->config = $config; | ||
|
||
if ($this->filterComponentPath == '' && $this->hasConfig('filterComponentPath')) | ||
{ | ||
$this->setFilterComponentPath($this->getConfig('filterComponentPath')); | ||
} | ||
|
||
if ($this->filterComponentOptions == [] && $this->hasConfig('filterComponentOptions')) | ||
{ | ||
$this->setFilterComponentOptions($this->getConfig('filterComponentOptions')); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
|
||
|
||
|
||
|
||
public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory | ||
{ | ||
return view('livewire-tables::components.tools.filters.livewire-component-filter', [...$this->getFilterSpecificViewData(), ...[ | ||
'wirekey' => 'test12312' . '-filter-'. $this->getKey() . ($this->hasCustomPosition() ? '-'.$this->getCustomPosition() : ''), | ||
'livewireComponent' => $this->filterComponentPath, | ||
'modelableValue' => 'filterComponents.'.$this->getKey(), | ||
...$this->filterComponentOptions, | ||
]]); | ||
|
||
|
||
|
||
} | ||
} |
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.