Skip to content

Commit

Permalink
Merge pull request #1667 from rappasoft/develop
Browse files Browse the repository at this point in the history
V3.2.1 Release
  • Loading branch information
lrljoe authored Feb 24, 2024
2 parents 9b05c64 + 52dac06 commit d49c0c7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 52 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

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

## [v3.2.0] - 2023-01-04
## [v3.2.1] - 2024-02-24
### Bug Fixes
- Fix collapsing columns not respecting view point collapse points by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1665

### Tweaks
- Migrate "updated" Search and FilterComponents calls to WithSearch and WithFilters by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1666
- Allow nullable search/filter values by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1666

## [v3.2.0] - 2024-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

Expand Down
8 changes: 4 additions & 4 deletions resources/views/components/table/td.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
$attributes->merge($customAttributes)
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $component->isTailwind() && ($customAttributes['default'] ?? true)])
->class(['hidden' => $component->isTailwind() && $column && $column->shouldCollapseAlways()])
->class(['hidden sm:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnMobile()])
->class(['hidden md:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnTablet()])
->class(['hidden md:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnMobile()])
->class(['hidden lg:table-cell' => $component->isTailwind() && $column && $column->shouldCollapseOnTablet()])
->class(['' => $component->isBootstrap() && ($customAttributes['default'] ?? true)])
->class(['d-none' => $component->isBootstrap() && $column && $column->shouldCollapseAlways()])
->class(['d-none d-sm-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-md-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnTablet()])
->class(['d-none d-md-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-lg-table-cell' => $component->isBootstrap() && $column && $column->shouldCollapseOnTablet()])
->style(['cursor:pointer' => $component->isBootstrap()])
->except('default')
}}
Expand Down
8 changes: 4 additions & 4 deletions resources/views/components/table/td/plain.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
->merge($customAttributes)
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true])
->class(['hidden' => $column && $column->shouldCollapseAlways()])
->class(['hidden sm:table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnTablet()])
->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet()])
->except('default')
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
{{ $slot }}
Expand All @@ -17,8 +17,8 @@
->merge($customAttributes)
->class(['' => $customAttributes['default'] ?? true])
->class(['d-none' => $column && $column->shouldCollapseAlways()])
->class(['d-none d-sm-table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnTablet()])
->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet()])
->except('default')
}}>
{{ $slot }}
Expand Down
8 changes: 6 additions & 2 deletions resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

<x-livewire-tables::table>
<x-slot name="thead">
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
@if($this->getCurrentlyReorderingStatus())
<x-livewire-tables::table.th.reorder x-cloak x-show="currentlyReorderingStatus" />
@endif
@if($this->bulkActionsAreEnabled() && $this->hasBulkActions())
<x-livewire-tables::table.th.bulk-actions :displayMinimisedOnReorder="true" />
@endif
<x-livewire-tables::table.th.collapsed-columns />

@foreach($columns as $index => $column)
Expand Down
2 changes: 1 addition & 1 deletion src/LaravelLivewireTablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LaravelLivewireTablesServiceProvider extends ServiceProvider
public function boot(): void
{

AboutCommand::add('Rappasoft Laravel Livewire Tables', fn () => ['Version' => '3.0.0']);
AboutCommand::add('Rappasoft Laravel Livewire Tables', fn () => ['Version' => '3.2.1']);

$this->mergeConfigFrom(
__DIR__.'/../config/livewire-tables.php', 'livewire-tables'
Expand Down
34 changes: 0 additions & 34 deletions src/Traits/ComponentUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,40 +87,6 @@ protected function generateDataTableFingerprint(): string
return base_convert($crc32, 10, 36);
}

/**
* Keep track of any properties on the custom query string key for this specific table
*/
public function updated(string $name, string|array $value): void
{
if ($name === 'search') {
$this->resetComputedPage();

// Clear bulk actions on search
$this->clearSelected();
$this->setSelectAllDisabled();

if ($value === '') {
$this->clearSearch();
}
}

if (Str::contains($name, 'filterComponents')) {
$this->resetComputedPage();

// Clear bulk actions on filter
$this->clearSelected();
$this->setSelectAllDisabled();

// Clear filters on empty value
$filterName = Str::after($name, 'filterComponents.');
$filter = $this->getFilterByKey($filterName);

if ($filter && $filter->isEmpty($value)) {
$this->resetFilter($filterName);
}
}
}

/**
* 1. After the sorting method is hit we need to tell the table to go back into reordering mode
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Traits/Helpers/TableAttributeHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@ public function getComponentWrapperAttributes(): array
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getTableWrapperAttributes(): array
{
return count($this->tableWrapperAttributes) ? $this->tableWrapperAttributes : ['default' => true];
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getTableAttributes(): array
{
return count($this->tableAttributes) ? $this->tableAttributes : ['id' => 'table-'.$this->getTableName(), 'default' => true];
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getTheadAttributes(): array
{
return count($this->theadAttributes) ? $this->theadAttributes : ['default' => true];
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getTbodyAttributes(): array
{
return count($this->tbodyAttributes) ? $this->tbodyAttributes : ['default' => true];
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getThAttributes(Column $column): array
{
return $this->thAttributesCallback ? call_user_func($this->thAttributesCallback, $column) : ['default' => true];
}

/**
* @return array<mixed>
* @return array<mixed>
*/
public function getThSortButtonAttributes(Column $column): array
{
Expand Down
16 changes: 16 additions & 0 deletions src/Traits/WithFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,20 @@ public function applyFilters(): Builder

return $this->getBuilder();
}

public function updatedFilterComponents(string|array|null $value, string $filterName): void
{
$this->resetComputedPage();

// Clear bulk actions on filter
$this->clearSelected();
$this->setSelectAllDisabled();

// Clear filters on empty value
$filter = $this->getFilterByKey($filterName);

if ($filter && $filter->isEmpty($value)) {
$this->resetFilter($filterName);
}
}
}
13 changes: 13 additions & 0 deletions src/Traits/WithSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,17 @@ public function applySearch(): Builder

return $this->getBuilder();
}

public function updatedSearch(string|array|null $value): void
{
$this->resetComputedPage();

// Clear bulk actions on search
$this->clearSelected();
$this->setSelectAllDisabled();

if (is_null($value) || $value === '') {
$this->clearSearch();
}
}
}

0 comments on commit d49c0c7

Please sign in to comment.