From 30d65ac20b5b6d035f13bf2785134da13e3de043 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:59:25 +0100 Subject: [PATCH 001/103] Add explanation of setRefreshMethod (#1857) --- docs/misc/refreshing.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/misc/refreshing.md b/docs/misc/refreshing.md index e318bfdc7..5e07f69b6 100644 --- a/docs/misc/refreshing.md +++ b/docs/misc/refreshing.md @@ -42,11 +42,16 @@ public function configure(): void ## setRefreshMethod -Fire a specific action when polling. +Fire a specific action when polling. This is only necessary when you wish to call additional actions on each refresh. You must have a public function with the same name as the refresh method. ```php public function configure(): void { - $this->setRefreshMethod('refresh'); + $this->setRefreshMethod('refreshTable'); +} + +public function refreshTable() +{ + // Custom Code Here } ``` From b3137d95e5d5bb7c7f5c60e587567d6960d55d6e Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sat, 17 Aug 2024 23:23:27 +0100 Subject: [PATCH 002/103] Unlocking Entangled Items (#1859) * Unlock properties locked in error --------- Co-authored-by: lrljoe --- CHANGELOG.md | 4 ++++ src/Traits/WithBulkActions.php | 4 ++++ src/Traits/WithFilters.php | 4 +++- src/Traits/WithPagination.php | 3 +++ src/Traits/WithReordering.php | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5957e1bac..55abcde31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.4.7] - 2024-08-18 +### Bug Fixes +- Correct a locked property that is entangled in js, and add comments around some key properties to prevent reoccurrence by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1859 + ## [v3.4.6] - 2024-08-15 ### New Features - Column Features - deselectedIf/selectedIf by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1846 diff --git a/src/Traits/WithBulkActions.php b/src/Traits/WithBulkActions.php index f7121cf2d..c36b87bb4 100644 --- a/src/Traits/WithBulkActions.php +++ b/src/Traits/WithBulkActions.php @@ -12,14 +12,17 @@ trait WithBulkActions public bool $bulkActionsStatus = true; + // Entangled in JS public bool $selectAll = false; public array $bulkActions = []; public array $bulkActionConfirms = []; + // Entangled in JS public array $selected = []; + // Entangled in JS public bool $hideBulkActionsWhenEmpty = false; public ?string $bulkActionConfirmDefaultMessage; @@ -46,6 +49,7 @@ trait WithBulkActions protected array $bulkActionsMenuItemAttributes = ['default-colors' => true, 'default-styling' => true]; + // Entangled in JS public bool $delaySelectAll = false; public function bulkActions(): array diff --git a/src/Traits/WithFilters.php b/src/Traits/WithFilters.php index 1499fa1d0..d843f2a71 100644 --- a/src/Traits/WithFilters.php +++ b/src/Traits/WithFilters.php @@ -22,7 +22,7 @@ trait WithFilters #[Locked] public bool $filterPillsStatus = true; - #[Locked] + // Entangled in JS public bool $filterSlideDownDefaultVisible = false; #[Locked] @@ -31,8 +31,10 @@ trait WithFilters #[Locked] public int $filterCount; + // Set in JS public array $filterComponents = []; + // Set in Frontend public array $appliedFilters = []; public array $filterGenericData = []; diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index 28be97ee5..571c2b76c 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -32,10 +32,13 @@ trait WithPagination #[Locked] public bool $perPageVisibilityStatus = true; + // Entangled in JS public array $paginationCurrentItems = []; + // Entangled in JS public int $paginationCurrentCount = 0; + // Entangled in JS public ?int $paginationTotalItemCount = null; public array $numberOfPaginatorsRendered = []; diff --git a/src/Traits/WithReordering.php b/src/Traits/WithReordering.php index f9e833e4b..2251fe2c4 100644 --- a/src/Traits/WithReordering.php +++ b/src/Traits/WithReordering.php @@ -11,14 +11,19 @@ trait WithReordering use ReorderingConfiguration, ReorderingHelpers; + // Entangled in JS public bool $reorderStatus = false; + // Entangled in JS public bool $currentlyReorderingStatus = false; + // Entangled in JS public bool $hideReorderColumnUnlessReorderingStatus = false; + // Entangled in JS public bool $reorderDisplayColumn = false; + // Retrieved in JS public string $defaultReorderColumn = 'sort'; public array $orderedItems = []; From b6890e920324c7366533b346d14d3c3323bdfb26 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 18 Aug 2024 03:10:38 +0100 Subject: [PATCH 003/103] Add dispatch on updated filter components (#1861) * Add additional dispatch * Add FilterApplied Event * Add Filter Event Dispatch Tests --------- Co-authored-by: lrljoe --- CHANGELOG.md | 4 ++++ src/Traits/WithFilters.php | 5 +++++ tests/Traits/Visuals/FilterVisualsTest.php | 14 ++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55abcde31..5843df9ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## UNRELEASED +### New Features +- Add an event dispatch for Filter Was Set when filterComponents is updated by @lrljoe + ## [v3.4.7] - 2024-08-18 ### Bug Fixes - Correct a locked property that is entangled in js, and add comments around some key properties to prevent reoccurrence by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1859 diff --git a/src/Traits/WithFilters.php b/src/Traits/WithFilters.php index d843f2a71..49c91da8c 100644 --- a/src/Traits/WithFilters.php +++ b/src/Traits/WithFilters.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use Livewire\Attributes\Locked; +use Rappasoft\LaravelLivewireTables\Events\FilterApplied; use Rappasoft\LaravelLivewireTables\Traits\Configuration\FilterConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\FilterHelpers; @@ -103,6 +104,10 @@ public function updatedFilterComponents(string|array|null $value, string $filter } elseif ($filter) { $this->callHook('filterUpdated', ['filter' => $filter->getKey(), 'value' => $value]); $this->callTraitHook('filterUpdated', ['filter' => $filter->getKey(), 'value' => $value]); + if ($this->getEventStatusFilterApplied() && $filter->getKey() != null && $value != null) { + event(new FilterApplied($this->getTableName(), $filter->getKey(), $value)); + } + $this->dispatch('filter-was-set', tableName: $this->getTableName(), filterKey: $filter->getKey(), value: $value); } } diff --git a/tests/Traits/Visuals/FilterVisualsTest.php b/tests/Traits/Visuals/FilterVisualsTest.php index 221ee7836..5b34da945 100644 --- a/tests/Traits/Visuals/FilterVisualsTest.php +++ b/tests/Traits/Visuals/FilterVisualsTest.php @@ -49,6 +49,20 @@ public function test_filter_pills_show_when_enabled(): void ->assertSee('Applied Filters'); } + public function test_event_dispatched_when_filterComponents_set(): void + { + Livewire::test(PetsTable::class) + ->set('filterComponents.breed', [1]) + ->assertDispatched('filter-was-set'); + } + + public function test_event_dispatched_when_setFilter_dispatched(): void + { + Livewire::test(PetsTable::class) + ->dispatch('setFilter', filterKey: 'breed', value: [1]) + ->assertDispatched('filter-was-set'); + } + public function test_filter_pills_show_when_visible(): void { Livewire::test(PetsTable::class) From fb646a54fe929aa76ff44caa76b7470923ded6aa Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 18 Aug 2024 03:12:50 +0100 Subject: [PATCH 004/103] v3.4.8 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5843df9ce..7f47783c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,9 @@ All notable changes to `laravel-livewire-tables` will be documented in this file -## UNRELEASED +## [v3.4.8] - 2024-08-18 ### New Features -- Add an event dispatch for Filter Was Set when filterComponents is updated by @lrljoe +- Add an event dispatch for Filter Was Set when filterComponents is updated by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1861 ## [v3.4.7] - 2024-08-18 ### Bug Fixes From 8eafffe945c0af2a2f2333e162d3bb4f253a48c6 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:38:15 +0100 Subject: [PATCH 005/103] Fix superfluous bulk actions tr < (#1868) --- resources/views/components/table/tr/bulk-actions.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/components/table/tr/bulk-actions.blade.php b/resources/views/components/table/tr/bulk-actions.blade.php index 7c7815b91..73201debf 100644 --- a/resources/views/components/table/tr/bulk-actions.blade.php +++ b/resources/views/components/table/tr/bulk-actions.blade.php @@ -97,7 +97,7 @@ class="btn btn-primary btn-sm" - < diff --git a/resources/views/components/tools/filters/multi-select.blade.php b/resources/views/components/tools/filters/multi-select.blade.php index e09772b19..4b8f11a4e 100644 --- a/resources/views/components/tools/filters/multi-select.blade.php +++ b/resources/views/components/tools/filters/multi-select.blade.php @@ -15,7 +15,7 @@ class="text-indigo-600 rounded border-gray-300 shadow-sm transition duration-150 @if ($filter->getFirstOption() != "") {{ $filter->getFirstOption() }} @else - @lang('livewire-tables::All') + {{ __('livewire-tables::core.All') }} @endif @@ -42,7 +42,7 @@ class="text-indigo-600 rounded border-gray-300 shadow-sm transition duration-150 wire:input="selectAllFilterOptions('{{ $filter->getKey() }}')" class="form-check-input" > - + @foreach($filter->getOptions() as $key => $value) diff --git a/resources/views/components/tools/sorting-pills.blade.php b/resources/views/components/tools/sorting-pills.blade.php index b633cf1d8..f84391319 100644 --- a/resources/views/components/tools/sorting-pills.blade.php +++ b/resources/views/components/tools/sorting-pills.blade.php @@ -4,7 +4,7 @@
@if ($this->sortingPillsAreEnabled() && $this->hasSorts())
- @lang('livewire-tables::Applied Sorting'): + {{ __('livewire-tables::core.Applied Sorting') }}: @foreach($this->getSorts() as $columnSelectName => $direction) @php($column = $this->getColumnBySelectName($columnSelectName) ?? $this->getColumnBySlug($columnSelectName)) @@ -24,7 +24,7 @@ class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium l type="button" class="flex-shrink-0 ml-0.5 h-4 w-4 rounded-full inline-flex items-center justify-center text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:outline-none focus:bg-indigo-500 focus:text-white" > - @lang('livewire-tables::Remove sort option') + {{ __('livewire-tables::core.Remove sort option') }} @@ -35,7 +35,7 @@ class="flex-shrink-0 ml-0.5 h-4 w-4 rounded-full inline-flex items-center justif class="focus:outline-none active:outline-none" > - @lang('livewire-tables::Clear') + {{ __('livewire-tables::core.Clear') }}
@@ -45,7 +45,7 @@ class="focus:outline-none active:outline-none"
@if ($this->sortingPillsAreEnabled() && $this->hasSorts())
- @lang('livewire-tables::Applied Sorting'): + {{ __('livewire-tables::core.Applied Sorting') }}: @foreach($this->getSorts() as $columnSelectName => $direction) @php($column = $this->getColumnBySelectName($columnSelectName) ?? $this->getColumnBySlug($columnSelectName)) @@ -65,7 +65,7 @@ class="badge badge-pill badge-info d-inline-flex align-items-center" wire:click="clearSort('{{ $columnSelectName }}')" class="text-white ml-2" > - @lang('livewire-tables::Remove sort option') + {{ __('livewire-tables::core.Remove sort option') }} @@ -76,7 +76,7 @@ class="text-white ml-2" wire:click.prevent="clearSorts" class="badge badge-pill badge-light" > - @lang('livewire-tables::Clear') + {{ __('livewire-tables::core.Clear') }}
@endif @@ -85,7 +85,7 @@ class="badge badge-pill badge-light"
@if ($this->sortingPillsAreEnabled() && $this->hasSorts())
- @lang('livewire-tables::Applied Sorting'): + {{ __('livewire-tables::core.Applied Sorting') }}: @foreach($this->getSorts() as $columnSelectName => $direction) @php($column = $this->getColumnBySelectName($columnSelectName) ?? $this->getColumnBySlug($columnSelectName)) @@ -105,7 +105,7 @@ class="badge rounded-pill bg-info d-inline-flex align-items-center" wire:click="clearSort('{{ $columnSelectName }}')" class="text-white ms-2" > - @lang('livewire-tables::Remove sort option') + {{ __('livewire-tables::core.Remove sort option') }} @@ -116,7 +116,7 @@ class="text-white ms-2" wire:click.prevent="clearSorts" class="badge rounded-pill bg-light text-dark text-decoration-none" > - @lang('livewire-tables::Clear') + {{ __('livewire-tables::core.Clear') }}
@endif diff --git a/resources/views/components/tools/toolbar/items/bulk-actions.blade.php b/resources/views/components/tools/toolbar/items/bulk-actions.blade.php index 3be95e799..6e7cd4948 100644 --- a/resources/views/components/tools/toolbar/items/bulk-actions.blade.php +++ b/resources/views/components/tools/toolbar/items/bulk-actions.blade.php @@ -34,7 +34,8 @@ @endif aria-haspopup="true" aria-expanded="false"> - @lang('livewire-tables::Bulk Actions') + {{ __('livewire-tables::core.Bulk Actions') }} + @if($this->isTailwind) @endif diff --git a/resources/views/components/tools/toolbar/items/column-select.blade.php b/resources/views/components/tools/toolbar/items/column-select.blade.php index 24033daee..d74d71efd 100644 --- a/resources/views/components/tools/toolbar/items/column-select.blade.php +++ b/resources/views/components/tools/toolbar/items/column-select.blade.php @@ -18,7 +18,7 @@ class="inline-flex justify-center px-4 py-2 w-full text-sm font-medium text-gray x-bind:aria-expanded="open" aria-expanded="true" > - @lang('livewire-tables::Columns') + {{ __('livewire-tables::core.Columns') }} @@ -51,7 +51,7 @@ class="text-indigo-600 transition duration-150 ease-in-out border-gray-300 round @checked($component->getSelectableSelectedColumns()->count() == $component->getSelectableColumns()->count()) @if($component->getSelectableSelectedColumns()->count() == $component->getSelectableColumns()->count()) wire:click="deselectAllColumns" @else wire:click="selectAllColumns" @endif > - @lang('livewire-tables::All Columns') + {{ __('livewire-tables::core.All Columns') }}
@@ -104,7 +104,7 @@ class="text-indigo-600 rounded border-gray-300 shadow-sm transition duration-150 type="button" id="{{ $tableName }}-columnSelect" aria-haspopup="true" x-bind:aria-expanded="open" > - @lang('livewire-tables::Columns') + {{ __('livewire-tables::core.Columns') }}
- @lang('livewire-tables::All Columns') + {{ __('livewire-tables::core.All Columns') }} @@ -139,7 +139,7 @@ class="form-check-input" />
@endif diff --git a/resources/views/components/tools/toolbar/items/filter-button.blade.php b/resources/views/components/tools/toolbar/items/filter-button.blade.php index f3488639e..225f71dd0 100644 --- a/resources/views/components/tools/toolbar/items/filter-button.blade.php +++ b/resources/views/components/tools/toolbar/items/filter-button.blade.php @@ -33,7 +33,7 @@ @endif @if ($this->isFilterLayoutSlideDown()) x-on:click="filtersOpen = !filtersOpen" @endif > - @lang('livewire-tables::Filters') + {{ __('livewire-tables::core.Filters') }} @if ($count = $this->getFilterBadgeCount()) $this->isBootstrap5, ]) > - @lang('livewire-tables::Clear') + {{ __('livewire-tables::core.Clear') }} @endif @@ -74,7 +74,7 @@ class="block px-4 py-2 text-sm text-gray-700 space-y-1" type="button" class="w-full inline-flex items-center justify-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-800 dark:border-gray-600 dark:text-white dark:hover:border-gray-500 dark:hover:bg-gray-600" > - @lang('livewire-tables::Clear') + {{ __('livewire-tables::core.Clear') }}
@endif diff --git a/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php b/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php index 5a2ae1845..46f2e83ff 100644 --- a/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php +++ b/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php @@ -21,7 +21,7 @@ value="{{ $item }}" wire:key="{{ $tableName }}-per-page-{{ $item }}" > - {{ $item === -1 ? __('livewire-tables::All') : $item }} + {{ $item === -1 ? __('livewire-tables::core.All') : $item }} @endforeach diff --git a/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php b/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php index 061b2ea8c..b33ea1d86 100644 --- a/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php +++ b/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php @@ -14,11 +14,11 @@ ]) > - @lang('livewire-tables::Cancel') + {{ __('livewire-tables::core.Cancel') }} - @lang('livewire-tables::Reorder') + {{ __('livewire-tables::core.Reorder') }} @@ -33,7 +33,7 @@ ]) > - @lang('livewire-tables::Save') + {{ __('livewire-tables::core.Save') }}
diff --git a/resources/views/includes/debug.blade.php b/resources/views/includes/debug.blade.php index d737f6941..791a7cfbb 100644 --- a/resources/views/includes/debug.blade.php +++ b/resources/views/includes/debug.blade.php @@ -1,6 +1,7 @@
@if ($this->debugIsEnabled()) -

@lang('livewire-tables::Debugging Values'):

+

{{ __('livewire-tables::core.Debugging Values') }}:

+ @if (! app()->runningInConsole())
@dump((new \Rappasoft\LaravelLivewireTables\DataTransferObjects\DebuggableData($this))->toArray())
diff --git a/resources/views/includes/offline.blade.php b/resources/views/includes/offline.blade.php index ae5dc5f37..c4889608b 100644 --- a/resources/views/includes/offline.blade.php +++ b/resources/views/includes/offline.blade.php @@ -9,7 +9,7 @@

- @lang('livewire-tables::You are not connected to the internet.') + {{ __('livewire-tables::core.You are not connected to the internet') }}.

@@ -19,7 +19,8 @@
- @lang('livewire-tables::You are not connected to the internet.') + {{ __('livewire-tables::core.You are not connected to the internet') }}. +
@endif diff --git a/src/LaravelLivewireTablesServiceProvider.php b/src/LaravelLivewireTablesServiceProvider.php index e10027b51..7002ae8d0 100644 --- a/src/LaravelLivewireTablesServiceProvider.php +++ b/src/LaravelLivewireTablesServiceProvider.php @@ -25,14 +25,7 @@ public function boot(): void ); // Load Default Translations - $this->loadJsonTranslationsFrom( - __DIR__.'/../resources/lang' - ); - - // Override if Published - $this->loadJsonTranslationsFrom( - $this->app->langPath('vendor/livewire-tables') - ); + $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'livewire-tables'); $this->loadViewsFrom(__DIR__.'/../resources/views', 'livewire-tables'); diff --git a/src/Traits/ComponentUtilities.php b/src/Traits/ComponentUtilities.php index de24d0e72..a8aa3832e 100644 --- a/src/Traits/ComponentUtilities.php +++ b/src/Traits/ComponentUtilities.php @@ -34,7 +34,7 @@ trait ComponentUtilities protected bool $eagerLoadAllRelationsStatus = false; - protected string $emptyMessage = 'No items found. Try to broaden your search.'; + protected string $emptyMessage = 'No items found, try to broaden your search'; protected array $additionalSelects = []; diff --git a/src/Traits/Helpers/BulkActionsHelpers.php b/src/Traits/Helpers/BulkActionsHelpers.php index 95c116900..7093f574c 100644 --- a/src/Traits/Helpers/BulkActionsHelpers.php +++ b/src/Traits/Helpers/BulkActionsHelpers.php @@ -181,7 +181,7 @@ public function getBulkActionConfirmMessage(string $bulkAction): string public function getBulkActionDefaultConfirmationMessage(): string { - return isset($this->bulkActionConfirmDefaultMessage) ? $this->bulkActionConfirmDefaultMessage : __('livewire-tables::Bulk Actions Confirm'); + return isset($this->bulkActionConfirmDefaultMessage) ? $this->bulkActionConfirmDefaultMessage : __('livewire-tables::core.Bulk Actions Confirm'); } #[Computed] diff --git a/src/Traits/Helpers/ComponentHelpers.php b/src/Traits/Helpers/ComponentHelpers.php index 980d8d28e..7ddce544b 100644 --- a/src/Traits/Helpers/ComponentHelpers.php +++ b/src/Traits/Helpers/ComponentHelpers.php @@ -62,7 +62,11 @@ public function getModel() */ public function getEmptyMessage(): string { - return __($this->emptyMessage); + if ($this->emptyMessage == 'No items found, try to broaden your search') { + return __('livewire-tables::core.No items found, try to broaden your search'); + } + + return $this->emptyMessage; } public function getOfflineIndicatorStatus(): bool diff --git a/src/Traits/Helpers/LoadingPlaceholderHelpers.php b/src/Traits/Helpers/LoadingPlaceholderHelpers.php index cd43c583f..ff3ee633e 100644 --- a/src/Traits/Helpers/LoadingPlaceholderHelpers.php +++ b/src/Traits/Helpers/LoadingPlaceholderHelpers.php @@ -16,7 +16,7 @@ public function getDisplayLoadingPlaceholder(): bool public function getLoadingPlaceholderContent(): string { - return $this->loadingPlaceholderContent ?? __('livewire-tables::loading'); + return $this->loadingPlaceholderContent ?? __('livewire-tables::core.loading'); } public function hasLoadingPlaceholderBlade(): bool diff --git a/src/Traits/Helpers/SearchHelpers.php b/src/Traits/Helpers/SearchHelpers.php index 059c17d32..1027778e5 100644 --- a/src/Traits/Helpers/SearchHelpers.php +++ b/src/Traits/Helpers/SearchHelpers.php @@ -127,7 +127,7 @@ public function getSearchPlaceholder(): string return $this->searchPlaceholder; } - return __('livewire-tables::Search'); + return __('livewire-tables::core.Search'); } public function hasSearchPlaceholder(): bool diff --git a/src/Views/Filters/DateRangeFilter.php b/src/Views/Filters/DateRangeFilter.php index 3c0d0a95e..7fae05c82 100644 --- a/src/Views/Filters/DateRangeFilter.php +++ b/src/Views/Filters/DateRangeFilter.php @@ -189,7 +189,7 @@ public function getFilterPillValue($value): array|string|bool|null if (($minDate instanceof Carbon) && $maxDate instanceof Carbon) { return $this->outputTranslatedDate($minDate) - .' '.__('livewire-tables::to').' '. + .' '.__('livewire-tables::core.to').' '. $this->outputTranslatedDate($maxDate); } } diff --git a/src/Views/Filters/NumberRangeFilter.php b/src/Views/Filters/NumberRangeFilter.php index a32a83667..ce02cb26d 100644 --- a/src/Views/Filters/NumberRangeFilter.php +++ b/src/Views/Filters/NumberRangeFilter.php @@ -89,7 +89,7 @@ public function getDefaultValue(): array|string public function getFilterPillValue($values): array|string|bool|null { if ($this->validate($values)) { - return __('livewire-tables::min').':'.$values['min'].', '.__('livewire-tables::max').':'.$values['max']; + return __('livewire-tables::core.min').':'.$values['min'].', '.__('livewire-tables::core.max').':'.$values['max']; } return ''; diff --git a/src/Views/Traits/Columns/IsSortable.php b/src/Views/Traits/Columns/IsSortable.php index b53c729d8..d21916001 100644 --- a/src/Views/Traits/Columns/IsSortable.php +++ b/src/Views/Traits/Columns/IsSortable.php @@ -99,7 +99,7 @@ public function getCustomSortingPillDirections(string $direction, ?string $defau return $this->sortingPillDirectionDesc ?? $defaultLabelDesc; } - return __('livewire-tables::not_applicable'); + return __('livewire-tables::core.not_applicable'); } public function getCustomSortingPillDirectionsLabel(string $direction, ?string $defaultLabelAsc = 'A-Z', ?string $defaultLabelDesc = 'Z-A'): string @@ -112,7 +112,7 @@ public function getCustomSortingPillDirectionsLabel(string $direction, ?string $ return $this->sortingPillDirectionDesc ?? $defaultLabelDesc; } - return __('livewire-tables::not_applicable'); + return __('livewire-tables::core.not_applicable'); } public function getSortingPillDirection(DataTableComponent $component, string $direction): string diff --git a/tests/Http/Livewire/PetsTable.php b/tests/Http/Livewire/PetsTable.php index 59b52049d..32024f7a5 100644 --- a/tests/Http/Livewire/PetsTable.php +++ b/tests/Http/Livewire/PetsTable.php @@ -3,6 +3,7 @@ namespace Rappasoft\LaravelLivewireTables\Tests\Http\Livewire; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\App; use Livewire\Attributes\On; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Tests\Models\Breed; @@ -25,6 +26,11 @@ class PetsTable extends DataTableComponent public string $paginationTest = 'standard'; + public function changeLocale(string $locale) + { + App::setLocale($locale); + } + public function enableDetailedPagination(string $type = 'standard') { $this->setPerPageAccepted([1, 3, 5, 10, 15, 25, 50])->setPerPage(3); diff --git a/tests/Localisations/BaseLocalisationCase.php b/tests/Localisations/BaseLocalisationCase.php new file mode 100644 index 000000000..b95b606cc --- /dev/null +++ b/tests/Localisations/BaseLocalisationCase.php @@ -0,0 +1,72 @@ + $availableLocale, + // 'localisationStrings' => $array, + ]; + } + + return $localisations; + } +} diff --git a/tests/Localisations/Presence/CheckKeyPresenceTest.php b/tests/Localisations/Presence/CheckKeyPresenceTest.php new file mode 100644 index 000000000..46aedc84e --- /dev/null +++ b/tests/Localisations/Presence/CheckKeyPresenceTest.php @@ -0,0 +1,29 @@ +basicTable->changeLocale($locale); + $this->assertEquals($localisedString, $this->basicTable->getEmptyMessage()); + } + + #[DataProvider('localisationProvider')] + public function test_can_check_presence_of_keys(string $locale): void + { + $engStrings = self::getEnLocaleStrings(); + $localisedStrings = self::getLocaleStrings($locale); + foreach ($engStrings as $key => $value) { + $this->assertNotNull($localisedStrings[$key]); + } + } +} diff --git a/tests/Localisations/Unit/Component/EmptyStringTest.php b/tests/Localisations/Unit/Component/EmptyStringTest.php new file mode 100644 index 000000000..bed7acd91 --- /dev/null +++ b/tests/Localisations/Unit/Component/EmptyStringTest.php @@ -0,0 +1,17 @@ +basicTable->changeLocale($locale); + $this->assertEquals($localisedString, $this->basicTable->getEmptyMessage()); + } +} diff --git a/tests/Unit/Traits/Configuration/SearchConfigurationTest.php b/tests/Unit/Traits/Configuration/SearchConfigurationTest.php index c4704d03b..20e788849 100644 --- a/tests/Unit/Traits/Configuration/SearchConfigurationTest.php +++ b/tests/Unit/Traits/Configuration/SearchConfigurationTest.php @@ -170,7 +170,7 @@ public function test_cant_set_search_throttle_with_other_search_modifiers(): voi public function test_can_set_search_placeholder(): void { - $this->assertSame(__('livewire-tables::Search'), $this->basicTable->getSearchPlaceholder()); + $this->assertSame(__('livewire-tables::core.Search'), $this->basicTable->getSearchPlaceholder()); $this->basicTable->setSearchPlaceholder('Anthony'); diff --git a/tests/Unit/Traits/Helpers/ComponentHelpersTest.php b/tests/Unit/Traits/Helpers/ComponentHelpersTest.php index 38be7f469..0eed6b930 100644 --- a/tests/Unit/Traits/Helpers/ComponentHelpersTest.php +++ b/tests/Unit/Traits/Helpers/ComponentHelpersTest.php @@ -22,9 +22,9 @@ public function test_can_get_current_theme(): void $this->assertEquals('tailwind', $this->basicTable->getTheme()); } - public function test_can_get_empty_message(): void + public function test_can_get_default_empty_message(): void { - $this->assertEquals('No items found. Try to broaden your search.', $this->basicTable->getEmptyMessage()); + $this->assertEquals(__('livewire-tables::core.No items found, try to broaden your search'), $this->basicTable->getEmptyMessage()); } public function test_can_get_offline_status(): void From 7748021eeb323ff070c1e5b703167010cac8e1eb Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 10 Nov 2024 04:07:34 +0000 Subject: [PATCH 100/103] Add "save", "cancel" to Core Localisation (#2039) --- resources/lang/en/core.php | 2 ++ .../components/tools/toolbar/items/reorder-buttons.blade.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/resources/lang/en/core.php b/resources/lang/en/core.php index 3a562980d..631762dba 100644 --- a/resources/lang/en/core.php +++ b/resources/lang/en/core.php @@ -7,6 +7,7 @@ 'Applied Sorting' => 'Applied Sorting', 'Bulk Actions' => 'Bulk Actions', 'Bulk Actions Confirm' => 'Are you sure?', + 'cancel' => 'Cancel', 'Clear' => 'Clear', 'Columns' => 'Columns', 'Debugging Values' => 'Debugging Values', @@ -27,6 +28,7 @@ 'row' => 'row', 'rows' => 'rows', 'rows, do you want to select all' => 'rows, do you want to select all', + 'save' => 'Save', 'Search' => 'Search', 'Select All' => 'Select All', 'Select All On Page' => 'Select All On Page', diff --git a/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php b/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php index b33ea1d86..00d89e384 100644 --- a/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php +++ b/resources/views/components/tools/toolbar/items/reorder-buttons.blade.php @@ -14,7 +14,7 @@ ]) > - {{ __('livewire-tables::core.Cancel') }} + {{ __('livewire-tables::core.cancel') }} @@ -33,7 +33,7 @@ ]) > - {{ __('livewire-tables::core.Save') }} + {{ __('livewire-tables::core.save') }} From d4f62e8808d4f0c99becff9424e828d64fbfa5cb Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 10 Nov 2024 04:27:13 +0000 Subject: [PATCH 101/103] Minor Localisation Tweaks (#2042) --- .../filter-pills/buttons/reset-all.blade.php | 25 +++++++++++++++++++ .../buttons/reset-filter.blade.php | 7 +++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php b/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php index e69de29bb..1ffec0b94 100644 --- a/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php +++ b/resources/views/components/tools/filter-pills/buttons/reset-all.blade.php @@ -0,0 +1,25 @@ +@aware(['isTailwind','isBootstrap','isBootstrap4','isBootstrap5']) +@if ($isTailwind) + +@else + $isBootstrap4, + 'badge rounded-pill bg-light text-dark text-decoration-none' => $isBootstrap5, + ])> + {{ __('livewire-tables::core.Clear') }} + +@endif diff --git a/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php index 5dfd85457..f65d13c5a 100644 --- a/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php +++ b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php @@ -9,7 +9,7 @@ "text-indigo-400 hover:bg-indigo-200 hover:text-indigo-500 focus:bg-indigo-500 focus:text-white", ]) > - @lang('livewire-tables::Remove filter option') + {{ __('livewire-tables::core.Remove filter option') }} @else @@ -23,9 +23,8 @@ $isBootstrap4, 'visually-hidden' => $isBootstrap5, - ])> - @lang('livewire-tables::Remove filter option') - + ])>{{ __('livewire-tables::core.Remove filter option') }} + @endif From f7cd9080ef0ac1cbcf9ed57d01b9d865ab6b81bc Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 10 Nov 2024 06:25:39 +0000 Subject: [PATCH 102/103] Remove Duplicate Item (#2043) --- .../buttons/reset-filter.blade.php | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php index f65d13c5a..912611188 100644 --- a/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php +++ b/resources/views/components/tools/filter-pills/buttons/reset-filter.blade.php @@ -28,34 +28,3 @@ @endif -@aware(['tableName','isTailwind','isBootstrap','isBootstrap4','isBootstrap5']) -@props(['filterKey']) -@if ($isTailwind) - -@else - ($isBootstrap), - ]) - > - $isBootstrap4, - 'visually-hidden' => $isBootstrap5, - ])>{{ __('livewire-tables::core.Remove filter option') }} - - - - -@endif \ No newline at end of file From 38966bf7948aef38bc8fee554024a9740c0d9c65 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 10 Nov 2024 06:37:21 +0000 Subject: [PATCH 103/103] Update ChangeLog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20254a641..d2fdcb052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.5.2] - 2024-11-09 +## Bug Fixes +- Migrate Localisation back to PHP Files from JSON by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2038 + ## [v3.5.1] - 2024-11-09 ### Bug Fixes - Fix NumberFilter bug for string values by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/2034