Skip to content

Commit

Permalink
Merge branch 'develop' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Jan 4, 2024
2 parents 2c0d9c9 + b114094 commit 9b05c64
Show file tree
Hide file tree
Showing 73 changed files with 1,370 additions and 1,106 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-livewire-tables` will be documented in this file

## [v3.2.0] - 2023-01-04
### Tweaks
- Migration to new Core Traits, and de-duplication of code by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1623

## [v3.1.9] - 2023-12-29
### Bug Fixes
- Fix CHANGELOG.md missing release
Expand Down Expand Up @@ -1133,4 +1137,4 @@ Ground Up Rebuild
[0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4
[0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3
[0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1
[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1
22 changes: 22 additions & 0 deletions config/livewire-tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,27 @@
'suffix' => '', // A suffix to append to the values when displayed
],
],
/**
* Configuration options for SelectFilter
*/
'selectFilter' => [
'defaultOptions' => [],
'defaultConfig' => [],
],
/**
* Configuration options for MultiSelectFilter
*/
'multiSelectFilter' => [
'defaultOptions' => [],
'defaultConfig' => [],
],

/**
* Configuration options for MultiSelectFilter
*/
'multiSelectDropdownFilter' => [
'defaultOptions' => [],
'defaultConfig' => [],
],

];
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ parameters:
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '#Access to an undefined property Rappasoft\\LaravelLivewireTables\\Views\\Column\:\:\$view#'
- "#Unsafe usage of new static#"
- '#on array\<string, non-empty-array\<int\<0, max\>, mixed\>\> in empty\(\) does not exist.#'
- '#on array<string, non-empty-array<int<0, max>, mixed>> in isset\(\) does not exist#'
Expand Down
2 changes: 2 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"preset": "laravel",
"rules": {
"single_import_per_statement": false,
"no_unused_imports": false,
"ordered_traits": false
}
}
2 changes: 1 addition & 1 deletion resources/views/components/table/tr/bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@php
$colspan = $component->getColspanCount();
$selectAll = $component->selectAllIsEnabled();
$simplePagination = $component->paginationMethod === 'simple';
$simplePagination = $component->isPaginationMethod('simple');
@endphp

@if ($component->isTailwind())
Expand Down
8 changes: 4 additions & 4 deletions src/Traits/Helpers/CustomisationsHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function hasExtends(): bool
return isset($this->extends) && $this->extends !== null;
}

public function getExtends()
public function getExtends(): ?string
{
return $this->extends;
}
Expand All @@ -25,7 +25,7 @@ public function hasSection(): bool
return isset($this->section) && $this->section !== null;
}

public function getSection()
public function getSection(): ?string
{
return $this->section;
}
Expand All @@ -38,7 +38,7 @@ public function hasSlot(): bool
return isset($this->slot) && $this->slot !== null;
}

public function getSlot()
public function getSlot(): ?string
{
return $this->slot;
}
Expand All @@ -51,7 +51,7 @@ public function hasLayout(): bool
return isset($this->layout) && $this->layout !== null;
}

public function getLayout()
public function getLayout(): ?string
{
return $this->layout;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Helpers/FilterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public function getFiltersByRow(): array
return $orderedFilters;
}

public function hasFilterGenericData()
public function hasFilterGenericData(): bool
{
return ! empty($this->filterGenericData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/WithPagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait WithPagination
public bool $perPageVisibilityStatus = true;

// standard, simple, cursor
public string $paginationMethod = 'standard';
protected string $paginationMethod = 'standard';

public array $paginationCurrentItems = [];

Expand Down
1 change: 1 addition & 0 deletions src/Traits/WithTableAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rappasoft\LaravelLivewireTables\Traits;

use Closure;
use Rappasoft\LaravelLivewireTables\Traits\Configuration\TableAttributeConfiguration;
use Rappasoft\LaravelLivewireTables\Traits\Helpers\TableAttributeHelpers;

Expand Down
2 changes: 2 additions & 0 deletions src/Views/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Column

protected bool $displayColumnLabel = true;

protected string $view = '';

public function __construct(string $title, ?string $from = null)
{
$this->title = trim($title);
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Columns/BooleanColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\BooleanColumnConfiguration;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasCallback;
use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\BooleanColumnHelpers;

class BooleanColumn extends Column
{
use BooleanColumnConfiguration,
BooleanColumnHelpers;
BooleanColumnHelpers,
HasCallback;

protected string $type = 'icons';

protected bool $successValue = true;

protected string $view = 'livewire-tables::includes.columns.boolean';

protected mixed $callback = null;

public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
{
if ($this->isLabel()) {
Expand Down
2 changes: 0 additions & 2 deletions src/Views/Columns/ButtonGroupColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class ButtonGroupColumn extends Column

protected string $view = 'livewire-tables::includes.columns.button-group';

protected mixed $attributesCallback = null;

public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
Expand Down
10 changes: 4 additions & 6 deletions src/Views/Columns/ColorColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Model;
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Traits\Columns\HasDefaultStringValue;
use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ColorColumnConfiguration;
use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ColorColumnHelpers;
use Rappasoft\LaravelLivewireTables\Views\Traits\IsColumn;
Expand All @@ -14,14 +15,11 @@ class ColorColumn extends Column
use IsColumn;
use ColorColumnConfiguration,
ColorColumnHelpers;
use HasDefaultStringValue;

public ?object $colorCallback = null;

public ?object $attributesCallback = null;

public string $defaultValue = '';

public string $view = 'livewire-tables::includes.columns.color';
protected string $view = 'livewire-tables::includes.columns.color';

public function __construct(string $title, ?string $from = null)
{
Expand All @@ -41,7 +39,7 @@ public function getContents(Model $row): null|string|\Illuminate\Support\HtmlStr
->withAttributeBag($this->getAttributeBag($row));
}

public function getValue(Model $row)
public function getValue(Model $row): string
{
return parent::getValue($row) ?? $this->getDefaultValue();
}
Expand Down
2 changes: 0 additions & 2 deletions src/Views/Columns/ComponentColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class ComponentColumn extends Column

protected string $componentView;

protected mixed $attributesCallback = null;

protected mixed $slotCallback = null;

public function __construct(string $title, ?string $from = null)
Expand Down
8 changes: 3 additions & 5 deletions src/Views/Columns/ImageColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\ImageColumnConfiguration;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\HasLocationCallback;
use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\ImageColumnHelpers;

class ImageColumn extends Column
{
use ImageColumnConfiguration,
ImageColumnHelpers;
ImageColumnHelpers,
HasLocationCallback;

protected string $view = 'livewire-tables::includes.columns.image';

protected mixed $locationCallback = null;

protected mixed $attributesCallback = null;

public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
Expand Down
11 changes: 4 additions & 7 deletions src/Views/Columns/LinkColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Traits\Configuration\LinkColumnConfiguration;
use Rappasoft\LaravelLivewireTables\Views\Traits\Core\{HasLocationCallback,HasTitleCallback};
use Rappasoft\LaravelLivewireTables\Views\Traits\Helpers\LinkColumnHelpers;

class LinkColumn extends Column
{
use LinkColumnConfiguration,
LinkColumnHelpers;
LinkColumnHelpers,
HasLocationCallback,
HasTitleCallback;

protected string $view = 'livewire-tables::includes.columns.link';

protected mixed $titleCallback = null;

protected mixed $locationCallback = null;

protected mixed $attributesCallback = null;

public function __construct(string $title, ?string $from = null)
{
parent::__construct($title, $from);
Expand Down
6 changes: 2 additions & 4 deletions src/Views/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ abstract class Filter
{
use IsFilter;

protected string $view = '';

public function __construct(string $name, ?string $key = null)
{
$this->name = $name;
Expand All @@ -28,8 +30,4 @@ public static function make(string $name, ?string $key = null): Filter
{
return new static($name, $key);
}

abstract public function isEmpty(string $value): bool;

abstract public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory;
}
29 changes: 5 additions & 24 deletions src/Views/Filters/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

use DateTime;
use Rappasoft\LaravelLivewireTables\Views\Filter;
use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasConfig, IsStringFilter};

class DateFilter extends Filter
{
public string $viewPath = 'livewire-tables::components.tools.filters.date';
use HasConfig,
IsStringFilter;

public function config(array $config = []): DateFilter
{
$this->config = [...config('livewire-tables.dateFilter.defaultConfig'), ...$config];
protected string $view = 'livewire-tables::components.tools.filters.date';

return $this;
}
protected string $configPath = 'livewire-tables.dateFilter.defaultConfig';

public function validate(string $value): string|bool
{
Expand All @@ -25,11 +24,6 @@ public function validate(string $value): string|bool
return $value;
}

public function isEmpty(?string $value): bool
{
return is_null($value) || $value === '';
}

public function getFilterPillValue($value): ?string
{
if ($this->validate($value)) {
Expand All @@ -38,17 +32,4 @@ public function getFilterPillValue($value): ?string

return null;
}

/**
* Gets the Default Value for this Filter via the Component
*/
public function getFilterDefaultValue(): ?string
{
return $this->filterDefaultValue ?? null;
}

public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory
{
return view($this->getViewPath(), $this->getFilterDisplayData());
}
}
37 changes: 6 additions & 31 deletions src/Views/Filters/DateRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,18 @@
namespace Rappasoft\LaravelLivewireTables\Views\Filters;

use Rappasoft\LaravelLivewireTables\Views\Filter;
use Rappasoft\LaravelLivewireTables\Views\Traits\Filters\{HasConfig,HasOptions};

class DateRangeFilter extends Filter
{
public array $options = [];
use HasOptions,
HasConfig;

public string $viewPath = 'livewire-tables::components.tools.filters.date-range';
protected string $view = 'livewire-tables::components.tools.filters.date-range';

public function config(array $config = []): DateRangeFilter
{
$this->config = [...config('livewire-tables.dateRange.defaultConfig'), ...$config];
protected string $configPath = 'livewire-tables.dateRange.defaultConfig';

return $this;
}

public function getConfigs(): array
{
return ! empty($this->config) ? $this->config : $this->config = config('livewire-tables.dateRange.defaultConfig');

}

public function options(array $options = []): DateRangeFilter
{
$this->options = [...$this->options, ...$options];

return $this;
}

public function getOptions(): array
{
return $this->options ?? $this->options = config('livewire-tables.dateRange.defaultOptions');

}
protected string $optionsPath = 'livewire-tables.dateRange.defaultOptions';

public function getKeys(): array
{
Expand Down Expand Up @@ -189,9 +169,4 @@ public function getDateString(string|array $dateInput): string

return '';
}

public function render(): string|\Illuminate\Contracts\Foundation\Application|\Illuminate\View\View|\Illuminate\View\Factory
{
return view($this->getViewPath(), $this->getFilterDisplayData());
}
}
Loading

0 comments on commit 9b05c64

Please sign in to comment.