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.8.0 #854

Merged
merged 59 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
63067a9
implement feature
May 14, 2022
658917d
test and docs
May 14, 2022
3f36253
fix typo
inmanturbo May 14, 2022
df40939
Complete changelog
inmanturbo May 14, 2022
7889153
refactor to remove extra property
inmanturbo May 14, 2022
7570e3e
update tests to include columns key
inmanturbo May 14, 2022
cbccbab
Add getSlug Helper for identifying selected column
inmanturbo May 14, 2022
f1cdb4d
allow new feature to be configured
inmanturbo May 16, 2022
e8d99e2
revert multiple-tables.md, update changelog
inmanturbo May 16, 2022
7cc4876
additional tests
inmanturbo May 16, 2022
6026dab
Fix styling
inmanturbo May 16, 2022
a19e427
put setters in ComponentConfiguration Trait
inmanturbo May 16, 2022
58ab053
Merge branch 'column-select' of github.com:rappasoft/laravel-livewire…
inmanturbo May 16, 2022
cb476bb
Fix styling
inmanturbo May 16, 2022
605db7d
Column::make: return type static
May 17, 2022
f1e86e1
Configure on boot!
inmanturbo May 17, 2022
67525aa
Disable column selection for multiple of same
inmanturbo May 18, 2022
80783e1
use ->getSlug() everywhere in column selection
inmanturbo May 18, 2022
3a03091
check/uncheck all selected columns
inmanturbo May 18, 2022
6068b04
Revert "check/uncheck all selected columns"
inmanturbo May 18, 2022
9d1f7a7
check/uncheck all columns
inmanturbo May 18, 2022
86a3d1f
Merge pull request #1 from inmanturbo/column-select
inmanturbo May 18, 2022
80b3473
Cannot set alias during configure
inmanturbo May 26, 2022
fc1dcd4
Cannot set alias during configure (#3)
inmanturbo May 26, 2022
3dd2583
feat(lang) add brazilian portuguese translation
irineujunior Jun 3, 2022
4d22828
Update other-column-types.md
ken-tam Jun 3, 2022
7d2a8c8
Merge pull request #776 from rappasoft/column-select
rappasoft Jun 8, 2022
4ca262d
Merge pull request #802 from inmanturbo/select-deselect-all-columns
rappasoft Jun 8, 2022
2c46cce
Update WithSorting.php
pkeogan Jun 9, 2022
8b8e55f
Add files via upload
dgillier Jun 16, 2022
4c68848
Column style change
dgillier Jun 16, 2022
8bb1b29
Language correction
dgillier Jun 17, 2022
98de18e
add malay language
wanadri Jun 21, 2022
dffc8fa
Fix: Removed :mixed return type hint as it requires PHP8.0
james-mckinnon Jun 22, 2022
b469542
Add Dutch translation
spekkie2002 Jun 30, 2022
7cb921a
added uk locale
Oleksandr-Moik Jul 9, 2022
d43d87a
Add static return type
standaniels Jul 23, 2022
0d8ea0d
Update
rappasoft Jul 24, 2022
ee529c4
Fix styling
rappasoft Jul 24, 2022
7a907b8
Merge branch 'levu42-patch-1' into develop
rappasoft Jul 24, 2022
e1da75f
Changelog
rappasoft Jul 24, 2022
7cfe5ba
Merge branch 'irineujunior-master' into develop
rappasoft Jul 24, 2022
7607516
Merge branch 'ken-tam-patch-1' into develop
rappasoft Jul 24, 2022
7fce4ec
Merge branch 'develop' of https://github.com/rappasoft/laravel-livewi…
rappasoft Jul 24, 2022
0ffd743
Merge branch 'pkeogan-master' into develop
rappasoft Jul 25, 2022
d527b12
Changelog
rappasoft Jul 25, 2022
69705cc
Revert file
rappasoft Jul 25, 2022
3953241
Merge branch 'dgillier-master' into develop
rappasoft Jul 25, 2022
0a2d513
Changelog
rappasoft Jul 25, 2022
47ca009
Merge branch 'wanadri-feature/malay-lang' into develop
rappasoft Jul 25, 2022
c2c3eba
Merge branch 'master' of https://github.com/spekkie2002/laravel-livew…
rappasoft Jul 25, 2022
8eea08e
Changelog
rappasoft Jul 25, 2022
b0be094
Merge branch 'Oleksandr-Moik-add-uk-locale' into develop
rappasoft Jul 25, 2022
289af23
Changelog
rappasoft Jul 25, 2022
0d80d43
Merge branch 'james-mckinnon-patch-1' into develop
rappasoft Jul 25, 2022
686233c
Changelog
rappasoft Jul 25, 2022
58bd703
Merge branch 'standaniels-patch-2' into develop
rappasoft Jul 25, 2022
a2275ad
Fix spacing
rappasoft Jul 25, 2022
518e474
Changelog
rappasoft Jul 25, 2022
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
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to `laravel-livewire-tables` will be documented in this file

## [Unreleased]

## [2.8.0] - 2022-07-24

### Added

- Added functionality to bookmark or deep link column selection
- Added functionality to identify different datatable components as unique in column selection
- Added funcitonality to configure query string alias
- Added funcitonality to configure session key for column selection (dataTableFingerprint)
- Added functionality to select/desect all columns in column selection dropdown
- Added French translation - https://github.com/rappasoft/laravel-livewire-tables/pull/816
- Added Malay translation - https://github.com/rappasoft/laravel-livewire-tables/pull/821
- Added Dutch translation - https://github.com/rappasoft/laravel-livewire-tables/pull/834
- Added Ukranian translation - https://github.com/rappasoft/laravel-livewire-tables/pull/840

### Changed

- Fixed bug with sort callback on newer versions of Livewire - https://github.com/rappasoft/laravel-livewire-tables/pull/805
- Fixed: Removed :mixed return type hint as it requires PHP8.0 - https://github.com/rappasoft/laravel-livewire-tables/pull/822
## [2.7.0] - 2022-05-07

### Added
Expand All @@ -13,6 +31,7 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
- Added functionality to hide individual filters from the active filter count
- Added functionality to say which filters get reset by the clear button
- Added functionality to set filters as secondaryHeader or footer of columns
- Added Brazilian Portuguese translation - https://github.com/rappasoft/laravel-livewire-tables/pull/797

## [2.6.0] - 2022-05-05

Expand Down Expand Up @@ -669,7 +688,8 @@ Ground Up Rebuild

- Initial release

[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.7.0...development
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.8.0...development
[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
[2.5.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v2.4.0...v2.5.0
Expand Down
17 changes: 16 additions & 1 deletion docs/columns/column-selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,19 @@ public function configure(): void
// Shorthand for $this->setRememberColumnSelectionStatus(false)
$this->setRememberColumnSelectionDisabled();
}
```
```

### setDataTableFingerprint

In order to idenfify each table and prevent conflicts on column selection, each table is given a unique fingerprint.
This fingerprint is generated using the static::class name of the component. If you are reusing
the same component in different parts of your application, you may need to set your own custom fingerprint.

```php
public function configure(): void
{
// Default fingerprint is output of protected method dataTableFingerprint()
// Below will prepend the current route name
$this->setDataTableFingerprint(route()->getName() . '-' . $this->dataTableFingerprint());
}
```
6 changes: 3 additions & 3 deletions docs/columns/other-column-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,20 @@ ButtonGroupColumn::make('Actions')
->buttons([
LinkColumn::make('View') // make() has no effect in this case but needs to be set anyway
->title(fn($row) => 'View ' . $row->name)
->location(fn($row) => route('user.show', $row)),
->location(fn($row) => route('user.show', $row))
->attributes(function($row) {
return [
'class' => 'underline text-blue-500 hover:no-underline',
];
}),
LinkColumn::make('Edit')
->title(fn($row) => 'Edit ' . $row->name)
->location(fn($row) => route('user.edit', $row)),
->location(fn($row) => route('user.edit', $row))
->attributes(function($row) {
return [
'target' => '_blank',
'class' => 'underline text-blue-500 hover:no-underline',
];
}),
]),
```
```
11 changes: 11 additions & 0 deletions docs/misc/multiple-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,14 @@ public function configure(): void
$this->setQueryStringDisabled();
}
```

## Disabling column selection for multiple of the same component

You should also disable the columns selection for those components so the column selection state does not get replaced by one or the other:

```php
public function configure(): void
{
$this->setColumnSelectStatus(false);
}
```
27 changes: 27 additions & 0 deletions resources/lang/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"All": "Tous",
"Applied Filters": "Filtres appliqués",
"Applied Sorting": "Tris appliqués",
"Bulk Actions": "Actions en masse",
"Clear": "Effacer",
"Columns": "Colonnes",
"Debugging Values": "Debugging Values",
"Done Reordering": "Réordonnancement terminé",
"Filters": "Filtres",
"Remove filter option": "Supprimer l'option de filtrage",
"Remove sort option": "Supprimer l'option de tri",
"Search": "Rechercher",
"Select All": "Tout sélectionner",
"Showing": "Montrant",
"Deselect All": "Tout désélectionner ",
"You are currently selecting all": "Vous êtes en train de sélectionner ",
"You are not connected to the internet.": "Vous n'êtes pas connecté à l'Internet.",
"You have selected": "Vous avez sélectionné",
"of": "sur",
"Reorder": "Réordonner",
"results": "résultats",
"rows": "lignes",
"rows, do you want to select all": "lignes, voulez-vous tout sélectionner ?",
"No items found. Try to broaden your search.": "Aucun élément trouvé. Essayez d'élargir votre recherche.",
"to": "à"
}
26 changes: 26 additions & 0 deletions resources/lang/ms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"All": "Semua",
"Applied Filters": "Tapisan Digunakan",
"Applied Sorting": "Susunan Digunakan",
"Bulk Actions": "Tindakan Pukal",
"Clear": "Kosongkan",
"Columns": "Kolum",
"Done Reordering": "Selesai Menyusun Semula",
"Filters": "Tapisan",
"Remove filter option": "Keluarkan pilihan tapisan",
"Remove sort option": "Keluarkan pilihan sususan",
"Search": "Carian",
"Select All": "Pilih Semua",
"Showing": "Menunjukkan",
"Deselect All": "Nyahpilih semua",
"You are currently selecting all": "Anda sedang memilih semua",
"You are not connected to the internet.": "Anda tidak disambungkan ke internet.",
"You have selected": "Anda telah memilih",
"of": "daripada",
"Reorder": "menyusun semula",
"results": "keputusan",
"rows": "barisan",
"rows, do you want to select all": "barisan, adakah anda mahu pilih semua?",
"No items found. Try to broaden your search.": "Tiada data ditemui. Sila perluaskan carian anda",
"to": "ke"
}
27 changes: 27 additions & 0 deletions resources/lang/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"All": "Alle",
"Applied Filters": "Toegepaste filters",
"Applied Sorting": "Toegepaste sortering",
"Bulk Actions": "Bulkacties",
"Clear": "Wissen",
"Columns": "Kolommen",
"Debugging Values": "Debugging waarden",
"Done Reordering": "Hersortering voltooid",
"Filters": "Filters",
"Remove filter option": "Filteroptie verwijderen",
"Remove sort option": "Sorteeroptie verwijderen",
"Search": "Zoeken",
"Select All": "Alles selecteren",
"Showing": "Toont",
"Deselect All": "Alles deselecteren",
"You are currently selecting all": "U selecteerde alle",
"You are not connected to the internet.": "U bent niet verbonden met het internet.",
"You have selected": "U selecteerde",
"of": "van",
"Reorder": "Hersorteren",
"results": "resultaten",
"rows": "rijen",
"rows, do you want to select all": "rijen, wilt u alles selecteren",
"No items found. Try to broaden your search.": "Geen items gevonden. Probeer uw zoekopdracht te verfijnen.",
"to": "tot"
}
27 changes: 27 additions & 0 deletions resources/lang/pt_BR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"All": "Tudo",
"Applied Filters": "Filtros aplicados",
"Applied Sorting": "Ordenação aplicada",
"Bulk Actions": "Ações em massa",
"Clear": "Limpar",
"Columns": "Colunas",
"Done Reordering": "Ordenação finalizada",
"Filters": "Filtros",
"Remove filter option": "Remover opção de filtro",
"Remove sort option": "Remover opção de ordenação",
"Search": "Pesquisar",
"Select All": "Selecionar tudo",
"Showing": "Exibindo",
"Deselect All": "Desmarcar Tudo",
"You are currently selecting all": "Você selecionou tudo",
"You are not connected to the internet.": "Você não está conectado na internet.",
"You have selected": "Você selecionou",
"of": "de",
"Reorder": "Reordenar",
"results": "resultados",
"row": "linha",
"rows": "linhas",
"rows, do you want to select all": "linhas, você deseja selecionar tudo?",
"No items found. Try to broaden your search.": "Nenhum resultado encontrado. Tente ampliar a sua pesquisa.",
"to": "a"
}
26 changes: 26 additions & 0 deletions resources/lang/uk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"All": "Всі",
"Applied Filters": "Застосовані фільтри",
"Applied Sorting": "Застосовані сортування",
"Bulk Actions": "Масові дії",
"Clear": "Очистити",
"Columns": "Колонки",
"Done Reordering": "Сортування виконанно",
"Filters": "Фільтри",
"Remove filter option": "Видалити опцію фільтра",
"Remove sort option": "Видалити параметр сортування",
"Search": "Пошук",
"Select All": "Вибрати все",
"Showing": "Показано",
"Unselect All": "Прибрати вибір усіх",
"You are currently selecting all": "Наразі ви вибираєте всі",
"You are not connected to the internet.": "Ви не підключені до Інтернету.",
"You have selected": "Ви вибрали",
"of": "від",
"Reorder": "Змінити порядок",
"results": "результатів",
"rows": "рядки",
"rows, do you want to select all": "рядків, ви хочете вибрати всі",
"No items found. Try to broaden your search.": "Немає елементів. Спробуйте розширити пошук.",
"to": "до"
}
66 changes: 62 additions & 4 deletions resources/views/components/tools/toolbar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,26 @@ class="absolute right-0 z-50 mt-2 w-full bg-white rounded-md divide-y divide-gra
>
<div class="bg-white rounded-md shadow-xs dark:bg-gray-700 dark:text-white">
<div class="p-2" role="menu" aria-orientation="vertical" aria-labelledby="column-select-menu">
<div>
<label
wire:loading.attr="disabled"
class="inline-flex items-center px-2 py-1 disabled:opacity-50 disabled:cursor-wait"
>
<input
class="text-indigo-600 transition duration-150 ease-in-out border-gray-300 rounded shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600 disabled:opacity-50 disabled:cursor-wait"
@if($component->allDefaultVisibleColumnsAreSelected())
checked
wire:click="deselectAllColumns"
@else
unchecked
wire:click="selectAllColumns"
@endif
wire:loading.attr="disabled"
type="checkbox"
/>
<span class="ml-2">{{ __('All Columns') }}</span>
</label>
</div>
@foreach($component->getColumns() as $column)
@if ($column->isVisible() && $column->isSelectable())
<div wire:key="columnSelect-{{ $loop->index }}-{{ $component->getTableName() }}">
Expand All @@ -260,7 +280,7 @@ class="text-indigo-600 rounded border-gray-300 shadow-sm transition duration-150
wire:target="selectedColumns"
wire:loading.attr="disabled"
type="checkbox"
value="{{ $column->getHash() }}"
value="{{ $column->getSlug() }}"
/>
<span class="ml-2">{{ $column->getTitle() }}</span>
</label>
Expand Down Expand Up @@ -498,6 +518,25 @@ class="dropdown-menu dropdown-menu-right w-100 mt-0 mt-md-3"
x-bind:class="{'show' : open}"
aria-labelledby="columnSelect-{{ $component->getTableName() }}"
>
<div>
<label
wire:loading.attr="disabled"
class="px-2 mb-1"
>
<input
@if($component->allDefaultVisibleColumnsAreSelected())
checked
wire:click="deselectAllColumns"
@else
unchecked
wire:click="selectAllColumns"
@endif
wire:loading.attr="disabled"
type="checkbox"
/>
<span class="ml-2">{{ __('All Columns') }}</span>
</label>
</div>
@foreach($component->getColumns() as $column)
@if ($column->isVisible() && $column->isSelectable())
<div wire:key="columnSelect-{{ $loop->index }}-{{ $component->getTableName() }}">
Expand All @@ -511,7 +550,7 @@ class="px-2 {{ $loop->last ? 'mb-0' : 'mb-1' }}"
wire:target="selectedColumns"
wire:loading.attr="disabled"
type="checkbox"
value="{{ $column->getHash() }}"
value="{{ $column->getSlug() }}"
/>
<span class="ml-2">{{ $column->getTitle() }}</span>
</label>
Expand Down Expand Up @@ -741,6 +780,25 @@ class="dropdown-menu dropdown-menu-end w-100"
x-bind:class="{'show' : open}"
aria-labelledby="columnSelect-{{ $component->getTableName() }}"
>
<div>
<label
wire:loading.attr="disabled"
class="px-2 mb-1"
>
<input
@if($component->allDefaultVisibleColumnsAreSelected())
checked
wire:click="deselectAllColumns"
@else
unchecked
wire:click="selectAllColumns"
@endif
wire:loading.attr="disabled"
type="checkbox"
/>
<span class="ml-2">{{ __('All Columns') }}</span>
</label>
</div>
@foreach($component->getColumns() as $column)
@if ($column->isVisible() && $column->isSelectable())
<div wire:key="columnSelect-{{ $loop->index }}-{{ $component->getTableName() }}">
Expand All @@ -754,7 +812,7 @@ class="px-2 {{ $loop->last ? 'mb-0' : 'mb-1' }}"
wire:target="selectedColumns"
wire:loading.attr="disabled"
type="checkbox"
value="{{ $column->getHash() }}"
value="{{ $column->getSlug() }}"
/>
<span class="ml-2">{{ $column->getTitle() }}</span>
</label>
Expand Down Expand Up @@ -813,4 +871,4 @@ class="d-block">

@if ($component->hasConfigurableAreaFor('after-toolbar'))
@include($component->getConfigurableAreaFor('after-toolbar'), $component->getParametersForConfigurableArea('after-toolbar'))
@endif
@endif
14 changes: 13 additions & 1 deletion src/DataTableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ abstract class DataTableComponent extends Component
'clearFilters' => 'clearFilterEvent',
];

/**
* returns a unique id for the table, used as an alias to identify one table from another session and query string to prevent conflicts
*/
protected function dataTableFingerprint(): string
{
$className = str_split(static::class);
$crc32 = sprintf('%u', crc32(serialize($className)));

return base_convert($crc32, 10, 36);
}

/**
* Runs on every request, immediately after the component is instantiated, but before any other lifecycle methods are called
*/
Expand All @@ -55,8 +66,9 @@ public function boot(): void
$this->{$this->tableName} = [
'sorts' => $this->{$this->tableName}['sorts'] ?? [],
'filters' => $this->{$this->tableName}['filters'] ?? [],
'columns' => $this->{$this->tableName}['columns'] ?? [],
];

// Set the filter defaults based on the filter type
$this->setFilterDefaults();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/ComponentUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function queryString(): array
{
if ($this->queryStringIsEnabled()) {
return [
$this->getTableName() => ['except' => null],
$this->getTableName() => ['except' => null, 'as' => $this->getQueryStringAlias()],
];
}

Expand Down
Loading