Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.10.0 #1024

Merged
merged 33 commits into from
Jan 17, 2023
Merged

v2.10.0 #1024

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a5c94f0
:sparkles: add support for MorphOne relationships
DanielGSoftware Jul 14, 2022
902f707
Merge branch 'rappasoft:master' into master
DanielGSoftware Sep 1, 2022
caa307d
Missing )
ken-tam Dec 22, 2022
65d3d99
Adding default slidedown capability
lrljoe Dec 29, 2022
179dc65
Adding default slidedown capability
lrljoe Dec 29, 2022
02f49ea
Fix styling
lrljoe Dec 29, 2022
5a29b9a
Update en.json
gpibarra Dec 29, 2022
206edd1
Update es.json
gpibarra Dec 29, 2022
7022f52
Adding MultiSelectDropdownFilter
lrljoe Jan 10, 2023
8ae3261
Fix styling
lrljoe Jan 10, 2023
f67aa00
Correcting test criteria
lrljoe Jan 10, 2023
f9c1ab8
Merge branch 'MultiSelectDropdownFilter' of https://github.com/LowerR…
lrljoe Jan 10, 2023
046ef8a
Fix for simple pagination bulk actions
lrljoe Jan 12, 2023
9849983
Fixing typo toolbar-right-end
lrljoe Jan 12, 2023
b66558e
Created docs to explain additional switch option
lrljoe Jan 13, 2023
3ed580a
Adding first option, and fix for emptying array
lrljoe Jan 13, 2023
037747c
Fix styling
lrljoe Jan 13, 2023
83ee742
Changelog
rappasoft Jan 17, 2023
a337555
Merge branch 'master' of https://github.com/DanielGSoftware/laravel-l…
rappasoft Jan 17, 2023
4359f84
Merge branch 'DanielGSoftware-master' into develop
rappasoft Jan 17, 2023
976e079
Changelog
rappasoft Jan 17, 2023
d15deb0
Merge branch 'gpibarra-patch-1' into develop
rappasoft Jan 17, 2023
4361e46
Merge branch 'patch-2' of https://github.com/gpibarra/laravel-livewir…
rappasoft Jan 17, 2023
7fbb93b
Changelog
rappasoft Jan 17, 2023
851201f
Merge branch 'LowerRockLabs-MultiSelectDropdownFilter' into develop
rappasoft Jan 17, 2023
7214613
Changelog
rappasoft Jan 17, 2023
f5ca949
Merge branch 'LowerRockLabs-BulkActionsCount' into develop
rappasoft Jan 17, 2023
3ca6e23
Changelog
rappasoft Jan 17, 2023
93f30c2
Merge branch 'LowerRockLabs-SlideDown-Menus' into develop
rappasoft Jan 17, 2023
f93a75d
Fix tests & changelog
rappasoft Jan 17, 2023
95d8b4f
Merge branch 'ken-tam-patch-2' into develop
rappasoft Jan 17, 2023
22ca3f6
Changelog
rappasoft Jan 17, 2023
e34df25
Changelog
rappasoft Jan 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased]

## [2.10.0] - 2023-01-16

### Added

- Added support for MorphOne relationships - https://github.com/rappasoft/laravel-livewire-tables/pull/844
- Added MultiSelectDropdownFilter - https://github.com/rappasoft/laravel-livewire-tables/pull/1011
- FilterSlideDown - Ability to set Default to Open or Closed - https://github.com/rappasoft/laravel-livewire-tables/pull/1017

### Changed

- Updated EN translations - https://github.com/rappasoft/laravel-livewire-tables/pull/999
- Updated ES translations - https://github.com/rappasoft/laravel-livewire-tables/pull/1000
- Bulk Actions Simple Pagination fix & typo in toolbar.blade.php - https://github.com/rappasoft/laravel-livewire-tables/pull/1015

## [2.9.0] - 2022-12-21

### Added
Expand Down Expand Up @@ -705,7 +719,9 @@ Ground Up Rebuild

- Initial release

[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.8.0...development
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.10.0...development
[2.10.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.9.0...v2.10.0
[2.9.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.8.0...v2.9.0
[2.8.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.7.0...v2.8.0
[2.7.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.6.0...v2.7.0
[2.6.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.5.0...v2.6.0
Expand Down
2 changes: 1 addition & 1 deletion docs/columns/relationships.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Relationships
weight: 2
---

Out of the box the columns support `hasOne` and `belongsTo` relationships for display, sorting, and searching. The component will automatically join the necessary tables.
Out of the box the columns support `hasOne`, `belongsTo`, and `MorphOne` relationships for display, sorting, and searching. The component will automatically join the necessary tables.

To call these relationships, just use the relationship dot-notation string as the field name:

Expand Down
2 changes: 1 addition & 1 deletion docs/filters/applying-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ You may wish to apply default filters i.e. current month on accessing the view i

```php
public function mount() {
$this->setFilter('created_after', date('Y-m-d', strtotime('now -1 month'));
$this->setFilter('created_after', date('Y-m-d', strtotime('now -1 month')));
}
```

Expand Down
25 changes: 25 additions & 0 deletions docs/filters/available-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,31 @@ public function configure(): void
}
```

### setFilterSlideDownDefaultStatusEnabled

Set the filter slide down to visible by default

```php
public function configure(): void
{
// Shorthand for $this->setFilterSlideDownDefaultStatus(true)
$this->setFilterSlideDownDefaultStatusEnabled();
}
```

### setFilterSlideDownDefaultStatusDisabled

Set the filter slide down to collapsed by default

```php
public function configure(): void
{
// Shorthand for $this->setFilterSlideDownDefaultStatus(false)
$this->setFilterSlideDownDefaultStatusDisabled();
}
```


----

## Filter Methods
Expand Down
31 changes: 30 additions & 1 deletion docs/filters/creating-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@ public function filters(): array
25 => 'Type Y',
26 => 'Type Z',
],
]),
])
->setFirstOption('All Tags'),
];
}
```
To set a defualt "All" option at the start of the dropdown, you can do so by utilising the
```
->SetFirstOption('NAME')
```

## Multi-select Filters

Expand All @@ -89,6 +94,30 @@ public function filters(): array
}
```

## Multi-select dropdown Filters

Multi-select dropdown filters are a simple dropdown list. The user can select multiple options from the list. There is also an 'All' option that will select all values

```php
use Rappasoft\LaravelLivewireTables\Views\Filters\SelectFilter;

public function filters(): array
{
return [
SelectFilter::make('Tags')
->options(
Tag::query()
->orderBy('name')
->get()
->keyBy('id')
->map(fn($tag) => $tag->name)
->toArray()
)
->setFirstOption('All Tags'),
];
}
```

## Date Filters

Date filters are HTML date elements.
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"All": "All",
"All Columns": "All Columns",
"Applied Filters": "Applied Filters",
"Applied Sorting": "Applied Sorting",
"Bulk Actions": "Bulk Actions",
Expand Down
1 change: 1 addition & 0 deletions resources/lang/es.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"All": "Todo",
"All Columns": "Todas las columnas",
"Applied Filters": "Filtros Aplicados",
"Applied Sorting": "Ordenamineto Aplicado",
"Bulk Actions": "Acciones Masivas",
Expand Down
9 changes: 5 additions & 4 deletions resources/views/components/table/tr/bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$colspan = $component->getColspanCount();
$selected = $component->getSelectedCount();
$selectAll = $component->selectAllIsEnabled();
$simplePagination = ($component->paginationMethod == "simple") ? true : false;
@endphp

@if ($theme === 'tailwind')
Expand All @@ -20,7 +21,7 @@ class="bg-indigo-50 dark:bg-gray-900 dark:text-white"
<div wire:key="all-selected-{{ $table }}">
<span>
@lang('You are currently selecting all')
<strong>{{ number_format($rows->total()) }}</strong>
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
@lang('rows').
</span>

Expand All @@ -39,7 +40,7 @@ class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium
@lang('You have selected')
<strong>{{ $selected }}</strong>
@lang('rows, do you want to select all')
<strong>{{ number_format($rows->total()) }}</strong>?
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
</span>

<button
Expand Down Expand Up @@ -72,7 +73,7 @@ class="ml-1 text-blue-600 underline text-gray-700 text-sm leading-5 font-medium
<div wire:key="all-selected-{{ $table }}">
<span>
@lang('You are currently selecting all')
<strong>{{ number_format($rows->total()) }}</strong>
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
@lang('rows').
</span>

Expand All @@ -91,7 +92,7 @@ class="btn btn-primary btn-sm"
@lang('You have selected')
<strong>{{ $selected }}</strong>
@lang('rows, do you want to select all')
<strong>{{ number_format($rows->total()) }}</strong>?
@if(!$simplePagination) <strong>{{ number_format($rows->total()) }}</strong> @endif
</span>

<button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@php
$theme = $component->getTheme();
@endphp

@if ($theme === 'tailwind')
<div class="rounded-md shadow-sm">
<select multiple
wire:model.stop="{{ $component->getTableName() }}.filters.{{ $filter->getKey() }}"
wire:key="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
id="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
class="block w-full transition duration-150 ease-in-out border-gray-300 rounded-md shadow-sm 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"
>
@if ($filter->getFirstOption() != "")
<option @if($filter->isEmpty($this)) selected @endif value="all">{{ $filter->getFirstOption()}}</option>
@endif
@foreach($filter->getOptions() as $key => $value)
@if (is_iterable($value))
<optgroup label="{{ $key }}">
@foreach ($value as $optionKey => $optionValue)
<option value="{{ $optionKey }}">{{ $optionValue }}</option>
@endforeach
</optgroup>
@else
<option value="{{ $key }}">{{ $value }}</option>
@endif
@endforeach
</select>
</div>
@elseif ($theme === 'bootstrap-4' || $theme === 'bootstrap-5')
<select multiple
wire:model.stop="{{ $component->getTableName() }}.filters.{{ $filter->getKey() }}"
wire:key="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
id="{{ $component->getTableName() }}-filter-{{ $filter->getKey() }}"
class="{{ $theme === 'bootstrap-4' ? 'form-control' : 'form-select' }}"
>
@if ($filter->getFirstOption() != "")
<option @if($filter->isEmpty($this)) selected @endif value="all">{{ $filter->getFirstOption()}}</option>
@endif
@foreach($filter->getOptions() as $key => $value)
@if (is_iterable($value))
<optgroup label="{{ $key }}">
@foreach ($value as $optionKey => $optionValue)
<option value="{{ $optionKey }}">{{ $optionValue }}</option>
@endforeach
</optgroup>
@else
<option value="{{ $key }}">{{ $value }}</option>
@endif
@endforeach
</select>
@endif
2 changes: 1 addition & 1 deletion resources/views/components/tools/toolbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ class="form-select"
@endif

@if ($component->hasConfigurableAreaFor('toolbar-right-end'))
@include($component->getConfigurableAreaFor('toolbar-right-end'), $component->getParametersForConfigurableArea('toolbar-righ-end'))
@include($component->getConfigurableAreaFor('toolbar-right-end'), $component->getParametersForConfigurableArea('toolbar-right-end'))
@endif
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/wrapper.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@endif

@if ($component->isFilterLayoutSlideDown())
x-data="{ filtersOpen: false }"
wire:ignore.self x-data="{ filtersOpen: $wire.filterSlideDownDefaultVisible }"
@endif
>
@include('livewire-tables::includes.debug')
Expand Down
32 changes: 32 additions & 0 deletions src/Traits/Configuration/FilterConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,36 @@ public function setFilterLayoutSlideDown(): self

return $this;
}

/**
* @param bool $status
*
* @return $this
*/
public function setFilterSlideDownDefaultStatus(bool $status): self
{
$this->filterSlideDownDefaultVisible = $status;

return $this;
}

/**
* @return $this
*/
public function setFilterSlideDownDefaultStatusDisabled(): self
{
$this->setFilterSlideDownDefaultStatus(false);

return $this;
}

/**
* @return $this
*/
public function setFilterSlideDownDefaultStatusEnabled(): self
{
$this->setFilterSlideDownDefaultStatus(true);

return $this;
}
}
20 changes: 18 additions & 2 deletions src/Traits/Helpers/FilterHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Collection;
use Rappasoft\LaravelLivewireTables\Views\Filter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectDropdownFilter;
use Rappasoft\LaravelLivewireTables\Views\Filters\MultiSelectFilter;

trait FilterHelpers
Expand Down Expand Up @@ -38,6 +39,21 @@ public function filtersVisibilityIsDisabled(): bool
return $this->getFiltersVisibilityStatus() === false;
}

public function getFilterSlideDownDefaultStatus(): bool
{
return $this->filterSlideDownDefaultVisible;
}

public function filtersSlideDownIsDefaultVisible(): bool
{
return $this->getFilterSlideDownDefaultStatus() === true;
}

public function filtersSlideDownIsDefaultHidden(): bool
{
return $this->getFilterSlideDownDefaultStatus() === false;
}

public function getFilterPillsStatus(): bool
{
return $this->filterPillsStatus;
Expand Down Expand Up @@ -91,7 +107,7 @@ public function selectAllFilterOptions(string $filterKey): void
{
$filter = $this->getFilterByKey($filterKey);

if (! $filter instanceof MultiSelectFilter) {
if (! $filter instanceof MultiSelectFilter && ! $filter instanceof MultiSelectDropdownFilter) {
return;
}

Expand Down Expand Up @@ -175,7 +191,7 @@ public function resetFilter($filter): void
if (! $filter instanceof Filter) {
$filter = $this->getFilterByKey($filter);
}

$this->setFilter($filter->getKey(), $filter->getDefaultValue());
}

Expand Down
4 changes: 3 additions & 1 deletion src/Traits/WithData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Rappasoft\LaravelLivewireTables\Views\Column;

trait WithData
Expand Down Expand Up @@ -77,6 +78,7 @@ protected function joinRelation(Column $column): Builder
$model = $lastQuery->getRelation($relationPart);

switch (true) {
case $model instanceof MorphOne:
case $model instanceof HasOne:
$table = $model->getRelated()->getTable();
$foreign = $model->getQualifiedForeignKeyName();
Expand Down Expand Up @@ -139,7 +141,7 @@ protected function getTableForColumn(Column $column): ?string
foreach ($column->getRelations() as $relationPart) {
$model = $lastQuery->getRelation($relationPart);

if ($model instanceof HasOne || $model instanceof BelongsTo) {
if ($model instanceof HasOne || $model instanceof BelongsTo || $model instanceof MorphOne) {
$table = $model->getRelated()->getTable();
}

Expand Down
1 change: 1 addition & 0 deletions src/Traits/WithFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ trait WithFilters
public bool $filtersStatus = true;
public bool $filtersVisibilityStatus = true;
public bool $filterPillsStatus = true;
public bool $filterSlideDownDefaultVisible = false;
public string $filterLayout = 'popover';

public function filters(): array
Expand Down
Loading