From 992a961965547e0b97a6696e10fcaaa760470887 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:53:21 +0000 Subject: [PATCH 01/29] Move render methods to traits --- src/DataTableComponent.php | 5 ----- src/Traits/WithData.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 4ab38e826..55d331900 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -99,11 +99,6 @@ public function customView(): string public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { - $this->setupColumnSelect(); - $this->setupPagination(); - $this->setupSecondaryHeader(); - $this->setupFooter(); - $this->setupReordering(); return view('livewire-tables::datatable') ->with([ diff --git a/src/Traits/WithData.php b/src/Traits/WithData.php index 02832dcf9..8abfcaeae 100644 --- a/src/Traits/WithData.php +++ b/src/Traits/WithData.php @@ -214,4 +214,14 @@ protected function getTableAlias(?string $currentTableAlias, string $relationPar return $currentTableAlias.'_'.$relationPart; } + + public function renderingWithData() + { + $this->setupColumnSelect(); + $this->setupPagination(); + $this->setupSecondaryHeader(); + $this->setupFooter(); + $this->setupReordering(); + } + } From 4b5e4845b07c177be0fe5a3a450b7e8da308cc12 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 17:53:52 +0000 Subject: [PATCH 02/29] Fix styling --- src/Traits/WithData.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/WithData.php b/src/Traits/WithData.php index 8abfcaeae..7ab38bbd2 100644 --- a/src/Traits/WithData.php +++ b/src/Traits/WithData.php @@ -223,5 +223,4 @@ public function renderingWithData() $this->setupFooter(); $this->setupReordering(); } - } From 47f8d8e44cf7e78467c06d85bccf5a81f25bea7b Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:59:13 +0000 Subject: [PATCH 03/29] Shifting Methods --- src/DataTableComponent.php | 11 ++++++++++- src/Traits/WithData.php | 8 -------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 55d331900..9606484f3 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -97,9 +97,18 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View + public function rendering() { + $this->setupColumnSelect(); + $this->setupPagination(); + $this->setupSecondaryHeader(); + $this->setupFooter(); + $this->setupReordering(); + + } + public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View + { return view('livewire-tables::datatable') ->with([ 'filterGenericData' => $this->getFilterGenericData(), diff --git a/src/Traits/WithData.php b/src/Traits/WithData.php index 7ab38bbd2..b833deaac 100644 --- a/src/Traits/WithData.php +++ b/src/Traits/WithData.php @@ -215,12 +215,4 @@ protected function getTableAlias(?string $currentTableAlias, string $relationPar return $currentTableAlias.'_'.$relationPart; } - public function renderingWithData() - { - $this->setupColumnSelect(); - $this->setupPagination(); - $this->setupSecondaryHeader(); - $this->setupFooter(); - $this->setupReordering(); - } } From 2508d54c99e435d0a71b3a07687e395368496d66 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 17:59:42 +0000 Subject: [PATCH 04/29] Fix styling --- src/Traits/WithData.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/WithData.php b/src/Traits/WithData.php index b833deaac..02832dcf9 100644 --- a/src/Traits/WithData.php +++ b/src/Traits/WithData.php @@ -214,5 +214,4 @@ protected function getTableAlias(?string $currentTableAlias, string $relationPar return $currentTableAlias.'_'.$relationPart; } - } From 0b3321ed36b201ffcf0fc64ea94bf0792514473d Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 18:07:08 +0000 Subject: [PATCH 05/29] Move methods back into render() --- src/DataTableComponent.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 9606484f3..4ab38e826 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -97,7 +97,7 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - public function rendering() + public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { $this->setupColumnSelect(); $this->setupPagination(); @@ -105,10 +105,6 @@ public function rendering() $this->setupFooter(); $this->setupReordering(); - } - - public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View - { return view('livewire-tables::datatable') ->with([ 'filterGenericData' => $this->getFilterGenericData(), From 869d1fa512b7788d2e56aeced8322cf3701ded7f Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:00:34 +0000 Subject: [PATCH 06/29] Move setupColumnSelect into Trait --- docs/misc/lifecycle-hooks.md | 8 +++++++- src/DataTableComponent.php | 29 +++++++++++++++++++---------- src/Traits/WithColumnSelect.php | 5 +++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/misc/lifecycle-hooks.md b/docs/misc/lifecycle-hooks.md index 8220faa86..86a4b70ea 100644 --- a/docs/misc/lifecycle-hooks.md +++ b/docs/misc/lifecycle-hooks.md @@ -9,4 +9,10 @@ With the migration to Livewire 3, there we are implementing several Lifecycle Ho This is called immediately prior to the configure() method being called ## configured -This is called immediately after the configure() method is called \ No newline at end of file +This is called immediately after the configure() method is called + +## settingColumns +This is called prior to setting up the available Columns via the columns() method + +## columnsSet +This is called immediately after the Columns are set up diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 4ab38e826..6b069c912 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -44,22 +44,32 @@ public function boot(): void */ public function booted(): void { - // Fire hook for configuring - $this->callHook('configuring'); - $this->callTraitHook('configuring'); + // Configuring + // Fire hook for configuring + $this->callHook('configuring'); + $this->callTraitHook('configuring'); - // Call the configure() method - $this->configure(); + // Call the configure() method + $this->configure(); - // Fire hook for configured - $this->callHook('configured'); - $this->callTraitHook('configured'); + // Fire hook for configured + $this->callHook('configured'); + $this->callTraitHook('configured'); //Sets up the Builder Instance $this->setBuilder($this->builder()); // Sets Columns - $this->setColumns(); + // Fire hook for settingColumns + $this->callHook('settingColumns'); + $this->callTraitHook('settingColumns'); + + // Set Columns + $this->setColumns(); + + // Fire hook for columnsSet + $this->callHook('columnsSet'); + $this->callTraitHook('columnsSet'); // Make sure a primary key is set if (! $this->hasPrimaryKey()) { @@ -99,7 +109,6 @@ public function customView(): string public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { - $this->setupColumnSelect(); $this->setupPagination(); $this->setupSecondaryHeader(); $this->setupFooter(); diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index 4d051b1f8..0ea325dc5 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -124,4 +124,9 @@ public function allSelectedColumnsAreVisibleByDefault(): bool { return count($this->selectedColumns) === count($this->getDefaultVisibleColumns()); } + + public function renderingWithColumnSelect() + { + $this->setupColumnSelect(); + } } From bb61a1645619da6a43e759ed3d6d3e9ad00748d9 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:00:58 +0000 Subject: [PATCH 07/29] Fix styling --- src/DataTableComponent.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 6b069c912..f8c44c7db 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -45,31 +45,31 @@ public function boot(): void public function booted(): void { // Configuring - // Fire hook for configuring - $this->callHook('configuring'); - $this->callTraitHook('configuring'); + // Fire hook for configuring + $this->callHook('configuring'); + $this->callTraitHook('configuring'); - // Call the configure() method - $this->configure(); + // Call the configure() method + $this->configure(); - // Fire hook for configured - $this->callHook('configured'); - $this->callTraitHook('configured'); + // Fire hook for configured + $this->callHook('configured'); + $this->callTraitHook('configured'); //Sets up the Builder Instance $this->setBuilder($this->builder()); // Sets Columns - // Fire hook for settingColumns - $this->callHook('settingColumns'); - $this->callTraitHook('settingColumns'); + // Fire hook for settingColumns + $this->callHook('settingColumns'); + $this->callTraitHook('settingColumns'); - // Set Columns - $this->setColumns(); + // Set Columns + $this->setColumns(); - // Fire hook for columnsSet - $this->callHook('columnsSet'); - $this->callTraitHook('columnsSet'); + // Fire hook for columnsSet + $this->callHook('columnsSet'); + $this->callTraitHook('columnsSet'); // Make sure a primary key is set if (! $this->hasPrimaryKey()) { From 99dc05b2595dfc51fe361e90b45e8edcd31a1b03 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:03:23 +0000 Subject: [PATCH 08/29] Update Test Case --- tests/TestCase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/TestCase.php b/tests/TestCase.php index 70aa12839..7d2284a8f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -76,7 +76,9 @@ protected function setUp(): void $this->basicTable = new PetsTable(); $this->basicTable->boot(); $this->basicTable->booted(); + $this->basicTable->rendering(); $this->basicTable->render(); + $this->basicTable->rendered(); } protected function getPackageProviders($app): array From 58fc67abc3279815e9245e533d4d599f85414468 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:06:01 +0000 Subject: [PATCH 09/29] Update DTC --- src/DataTableComponent.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index f8c44c7db..379ca1fab 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -46,7 +46,7 @@ public function booted(): void { // Configuring // Fire hook for configuring - $this->callHook('configuring'); + $this->clalHook('configuring'); $this->callTraitHook('configuring'); // Call the configure() method @@ -107,6 +107,8 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } + abstract public function rendering(): void; + public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { $this->setupPagination(); @@ -122,4 +124,7 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina 'customView' => $this->customView(), ]); } + + abstract public function rendered(): void; + } From aa23f00f5a0e81aca70f53d7d0d64fdeb9737438 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:06:24 +0000 Subject: [PATCH 10/29] Fix styling --- src/DataTableComponent.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 379ca1fab..5b954e3c2 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -124,7 +124,6 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina 'customView' => $this->customView(), ]); } - - abstract public function rendered(): void; + abstract public function rendered(): void; } From 781360e1b4ea58090d1be22573c88849ca8e86c7 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:07:26 +0000 Subject: [PATCH 11/29] Test --- src/DataTableComponent.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 5b954e3c2..9f2ede3d3 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -107,7 +107,7 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - abstract public function rendering(): void; + public function rendering(): void; public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { @@ -125,5 +125,6 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina ]); } - abstract public function rendered(): void; + public function rendered(): void; + } From dafc43f49b8ec92707c45d7bf3288b00242de370 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:13:08 +0000 Subject: [PATCH 12/29] Test moving to rendering --- src/DataTableComponent.php | 10 ++++++---- src/Traits/WithColumnSelect.php | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 9f2ede3d3..c86593d3d 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -107,15 +107,18 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - public function rendering(): void; - - public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View + public function rendering() { $this->setupPagination(); $this->setupSecondaryHeader(); $this->setupFooter(); $this->setupReordering(); + $this->setupColumnSelect(); + + } + public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View + { return view('livewire-tables::datatable') ->with([ 'filterGenericData' => $this->getFilterGenericData(), @@ -125,6 +128,5 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina ]); } - public function rendered(): void; } diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index 0ea325dc5..3dbc029d4 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -125,8 +125,4 @@ public function allSelectedColumnsAreVisibleByDefault(): bool return count($this->selectedColumns) === count($this->getDefaultVisibleColumns()); } - public function renderingWithColumnSelect() - { - $this->setupColumnSelect(); - } } From 01ee2723913a7348141d5bdebb25c467f7737d40 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:13:40 +0000 Subject: [PATCH 13/29] Fix styling --- src/DataTableComponent.php | 2 -- src/Traits/WithColumnSelect.php | 1 - 2 files changed, 3 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index c86593d3d..37ee584f3 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -127,6 +127,4 @@ public function render(): \Illuminate\Contracts\Foundation\Application|\Illumina 'customView' => $this->customView(), ]); } - - } diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index 3dbc029d4..4d051b1f8 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -124,5 +124,4 @@ public function allSelectedColumnsAreVisibleByDefault(): bool { return count($this->selectedColumns) === count($this->getDefaultVisibleColumns()); } - } From abe2f4ae575260adf90ebfbd358cb7f72dd951a0 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:15:02 +0000 Subject: [PATCH 14/29] clalHook fix --- src/DataTableComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 37ee584f3..811944a0e 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -46,7 +46,7 @@ public function booted(): void { // Configuring // Fire hook for configuring - $this->clalHook('configuring'); + $this->callHook('configuring'); $this->callTraitHook('configuring'); // Call the configure() method From 558712c687ec8d0731dc0eecb0fa1b5d36dc9cf5 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:16:43 +0000 Subject: [PATCH 15/29] Remove rendered test --- tests/TestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 7d2284a8f..60dddc6ab 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -78,7 +78,6 @@ protected function setUp(): void $this->basicTable->booted(); $this->basicTable->rendering(); $this->basicTable->render(); - $this->basicTable->rendered(); } protected function getPackageProviders($app): array From 2612568604349cea242ffebf9023380642b748e9 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:34:15 +0000 Subject: [PATCH 16/29] Use hooks for methods --- src/DataTableComponent.php | 1 - tests/TestCase.php | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 811944a0e..00c0fdfa4 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -114,7 +114,6 @@ public function rendering() $this->setupFooter(); $this->setupReordering(); $this->setupColumnSelect(); - } public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View diff --git a/tests/TestCase.php b/tests/TestCase.php index 60dddc6ab..7576b1a3d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,10 +10,7 @@ use Orchestra\Testbench\TestCase as Orchestra; use Rappasoft\LaravelLivewireTables\LaravelLivewireTablesServiceProvider; use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; -use Rappasoft\LaravelLivewireTables\Tests\Models\Breed; -use Rappasoft\LaravelLivewireTables\Tests\Models\Pet; -use Rappasoft\LaravelLivewireTables\Tests\Models\Species; -use Rappasoft\LaravelLivewireTables\Tests\Models\Veterinary; +use Rappasoft\LaravelLivewireTables\Tests\Models\{Breed,Pet,Species,Veterinary}; class TestCase extends Orchestra { @@ -76,8 +73,9 @@ protected function setUp(): void $this->basicTable = new PetsTable(); $this->basicTable->boot(); $this->basicTable->booted(); - $this->basicTable->rendering(); + $this->basicTable->callHook('rendering'); $this->basicTable->render(); + $this->basicTable->callHook('rendered'); } protected function getPackageProviders($app): array From 80ca401748f429d1aad8c2be46be9f4e06a4de32 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:34:40 +0000 Subject: [PATCH 17/29] Fix styling --- tests/TestCase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 7576b1a3d..2e9138cdf 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,7 +10,10 @@ use Orchestra\Testbench\TestCase as Orchestra; use Rappasoft\LaravelLivewireTables\LaravelLivewireTablesServiceProvider; use Rappasoft\LaravelLivewireTables\Tests\Http\Livewire\PetsTable; -use Rappasoft\LaravelLivewireTables\Tests\Models\{Breed,Pet,Species,Veterinary}; +use Rappasoft\LaravelLivewireTables\Tests\Models\Breed; +use Rappasoft\LaravelLivewireTables\Tests\Models\Pet; +use Rappasoft\LaravelLivewireTables\Tests\Models\Species; +use Rappasoft\LaravelLivewireTables\Tests\Models\Veterinary; class TestCase extends Orchestra { From be0e7c66e203c82ea7bbb55725195a164db1465f Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:38:38 +0000 Subject: [PATCH 18/29] Update rendering approach --- src/DataTableComponent.php | 2 -- src/Traits/WithColumnSelect.php | 5 +++++ src/Traits/WithReordering.php | 6 ++++++ tests/TestCase.php | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 00c0fdfa4..344f8412f 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -112,8 +112,6 @@ public function rendering() $this->setupPagination(); $this->setupSecondaryHeader(); $this->setupFooter(); - $this->setupReordering(); - $this->setupColumnSelect(); } public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index 4d051b1f8..0ea325dc5 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -124,4 +124,9 @@ public function allSelectedColumnsAreVisibleByDefault(): bool { return count($this->selectedColumns) === count($this->getDefaultVisibleColumns()); } + + public function renderingWithColumnSelect() + { + $this->setupColumnSelect(); + } } diff --git a/src/Traits/WithReordering.php b/src/Traits/WithReordering.php index d7b86af25..b0a5bd9a7 100644 --- a/src/Traits/WithReordering.php +++ b/src/Traits/WithReordering.php @@ -169,4 +169,10 @@ public function storeReorder(array $rows = []) $this->forgetReorderingSession(); $this->getReorderingBackup(); } + + public function renderingWithReordering() + { + $this->setupReordering(); + } + } diff --git a/tests/TestCase.php b/tests/TestCase.php index 2e9138cdf..fd6eae49b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -77,6 +77,7 @@ protected function setUp(): void $this->basicTable->boot(); $this->basicTable->booted(); $this->basicTable->callHook('rendering'); + $this->basicTable->callTraitHook('rendering'); $this->basicTable->render(); $this->basicTable->callHook('rendered'); } From c5810da127c764f4be42a88099efc8e8e49e205b Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:39:07 +0000 Subject: [PATCH 19/29] Fix styling --- src/Traits/WithReordering.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/WithReordering.php b/src/Traits/WithReordering.php index b0a5bd9a7..375bdda10 100644 --- a/src/Traits/WithReordering.php +++ b/src/Traits/WithReordering.php @@ -174,5 +174,4 @@ public function renderingWithReordering() { $this->setupReordering(); } - } From 59633eca3303651f829d9ac7095d774d2e59fbd1 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:40:58 +0000 Subject: [PATCH 20/29] Move methods to Traits --- src/DataTableComponent.php | 6 ------ src/Traits/WithFooter.php | 6 ++++++ src/Traits/WithPagination.php | 7 ++++++- src/Traits/WithSecondaryHeader.php | 6 ++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 344f8412f..24ed84e23 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -107,12 +107,6 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - public function rendering() - { - $this->setupPagination(); - $this->setupSecondaryHeader(); - $this->setupFooter(); - } public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { diff --git a/src/Traits/WithFooter.php b/src/Traits/WithFooter.php index d6e620299..3acdceffa 100644 --- a/src/Traits/WithFooter.php +++ b/src/Traits/WithFooter.php @@ -28,4 +28,10 @@ public function setupFooter(): void } } } + + public function renderingWithFooter() + { + $this->setupFooter(); + } + } diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index ad4a7cfa3..2f7b68c7b 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -79,4 +79,9 @@ private function getPerPagePaginationSessionKey(): string { return $this->tableName.'-perPage'; } -} + + public function renderingWithReordering() + { + $this->setupPagination(); + } +} \ No newline at end of file diff --git a/src/Traits/WithSecondaryHeader.php b/src/Traits/WithSecondaryHeader.php index 568eaf086..5a392a04b 100644 --- a/src/Traits/WithSecondaryHeader.php +++ b/src/Traits/WithSecondaryHeader.php @@ -26,4 +26,10 @@ public function setupSecondaryHeader(): void } } } + + public function renderingWithSecondaryHeader() + { + $this->setupSecondaryHeader(); + } + } From 28c8c341aaf1e8583072a78ff2e16f227fe851d0 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:41:24 +0000 Subject: [PATCH 21/29] Fix styling --- src/DataTableComponent.php | 1 - src/Traits/WithFooter.php | 1 - src/Traits/WithPagination.php | 4 ++-- src/Traits/WithSecondaryHeader.php | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/DataTableComponent.php b/src/DataTableComponent.php index 24ed84e23..6200ba35b 100644 --- a/src/DataTableComponent.php +++ b/src/DataTableComponent.php @@ -107,7 +107,6 @@ public function customView(): string return 'livewire-tables::stubs.custom'; } - public function render(): \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View { return view('livewire-tables::datatable') diff --git a/src/Traits/WithFooter.php b/src/Traits/WithFooter.php index 3acdceffa..1ae76fb36 100644 --- a/src/Traits/WithFooter.php +++ b/src/Traits/WithFooter.php @@ -33,5 +33,4 @@ public function renderingWithFooter() { $this->setupFooter(); } - } diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index 2f7b68c7b..b32bb02fb 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -79,9 +79,9 @@ private function getPerPagePaginationSessionKey(): string { return $this->tableName.'-perPage'; } - + public function renderingWithReordering() { $this->setupPagination(); } -} \ No newline at end of file +} diff --git a/src/Traits/WithSecondaryHeader.php b/src/Traits/WithSecondaryHeader.php index 5a392a04b..7812dd50f 100644 --- a/src/Traits/WithSecondaryHeader.php +++ b/src/Traits/WithSecondaryHeader.php @@ -31,5 +31,4 @@ public function renderingWithSecondaryHeader() { $this->setupSecondaryHeader(); } - } From ea2fb6a3466033673d9815a47b28355bf0c33db5 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 20:42:56 +0000 Subject: [PATCH 22/29] Update rendering method for pagination --- src/Traits/WithPagination.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index b32bb02fb..3f8d280f6 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -79,8 +79,8 @@ private function getPerPagePaginationSessionKey(): string { return $this->tableName.'-perPage'; } - - public function renderingWithReordering() + + public function renderingWithPagination() { $this->setupPagination(); } From 7706ef732cd7b0861017451ef7fc57d7e620d781 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 20:43:24 +0000 Subject: [PATCH 23/29] Fix styling --- src/Traits/WithPagination.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Traits/WithPagination.php b/src/Traits/WithPagination.php index 3f8d280f6..078f58e0e 100644 --- a/src/Traits/WithPagination.php +++ b/src/Traits/WithPagination.php @@ -79,7 +79,7 @@ private function getPerPagePaginationSessionKey(): string { return $this->tableName.'-perPage'; } - + public function renderingWithPagination() { $this->setupPagination(); From 8515a77211442edbe54b28ec9b80acb5d088cdbd Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:12:38 +0000 Subject: [PATCH 24/29] Update Changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89021b0a7..2c8fdb65f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,17 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## [v3.1.3] - 2023-11-03 +- Add additional Lifecycle Hook by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 + - SettingColumns/ColumnsSet +- Migrate methods for pre-render out of render by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 +- Update tests to reflect hooks by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 + ## [v3.1.2] - 2023-11-03 - Add Initial Lifecycle Hooks - Configuring/Configured by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1520 - Configuring/Configured - Add missing tests for DateFilter and DateTimeFilter by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1527 - ## [v3.1.1] - 2023-11-02 ### New Features - Add setCustomView for Filters From 1b4dc2ff198c0c69352ad22e92defc5966f29c10 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:26:17 +0000 Subject: [PATCH 25/29] Clean up maps, tests --- CHANGELOG.md | 2 ++ src/Mechanisms/RappasoftFrontendAssets.php | 3 ++- tests/Views/Filters/DateFilterTest.php | 11 +++++++++++ tests/Views/Filters/DateTimeFilterTest.php | 11 +++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8fdb65f..603fe19df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file - SettingColumns/ColumnsSet - Migrate methods for pre-render out of render by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 - Update tests to reflect hooks by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 +- Update tests to add invalid string tests for dates +- Remove maps and minimise functions from FrontendAssets ## [v3.1.2] - 2023-11-03 - Add Initial Lifecycle Hooks - Configuring/Configured by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1520 diff --git a/src/Mechanisms/RappasoftFrontendAssets.php b/src/Mechanisms/RappasoftFrontendAssets.php index 0704de080..9a9eec1c3 100644 --- a/src/Mechanisms/RappasoftFrontendAssets.php +++ b/src/Mechanisms/RappasoftFrontendAssets.php @@ -109,6 +109,7 @@ protected function pretendResponseIsCSS(string $file): \Symfony\Component\HttpFo return response()->file($file, $headers); } + /* public function maps(): \Symfony\Component\HttpFoundation\Response { return Utils::pretendResponseIsFile(__DIR__.'/../../../resources/js/laravel-livewire-tables.min.js.map'); @@ -117,5 +118,5 @@ public function maps(): \Symfony\Component\HttpFoundation\Response protected static function minify(string $subject): array|string|null { return preg_replace('~(\v|\t|\s{2,})~m', '', $subject); - } + }*/ } diff --git a/tests/Views/Filters/DateFilterTest.php b/tests/Views/Filters/DateFilterTest.php index 1c5e785e4..2c6b411ed 100644 --- a/tests/Views/Filters/DateFilterTest.php +++ b/tests/Views/Filters/DateFilterTest.php @@ -167,4 +167,15 @@ public function test_can_get_filter_pills_value(): void $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue($dateTime->format('Y-m-d'))); } + + /** + * @test + */ + public function test_can_not_get_filter_pills_invalid_value(): void + { + $dateTime = (new DateTime('now')); + + $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); + } + } diff --git a/tests/Views/Filters/DateTimeFilterTest.php b/tests/Views/Filters/DateTimeFilterTest.php index 8418105a4..d3714b0f0 100644 --- a/tests/Views/Filters/DateTimeFilterTest.php +++ b/tests/Views/Filters/DateTimeFilterTest.php @@ -146,4 +146,15 @@ public function test_can_get_filter_pills_value(): void $this->assertSame($dateTime->format('d M Y - H:i'), self::$filterInstance->getFilterPillValue($dateTime->format('Y-m-d\TH:i'))); } + + /** + * @test + */ + public function test_can_not_get_filter_pills_invalid_value(): void + { + $dateTime = (new DateTime('now')); + + $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); + } + } From b451b17742b41882225e96d7a991a27330120057 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Fri, 3 Nov 2023 21:26:42 +0000 Subject: [PATCH 26/29] Fix styling --- tests/Views/Filters/DateFilterTest.php | 1 - tests/Views/Filters/DateTimeFilterTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/Views/Filters/DateFilterTest.php b/tests/Views/Filters/DateFilterTest.php index 2c6b411ed..e113765ec 100644 --- a/tests/Views/Filters/DateFilterTest.php +++ b/tests/Views/Filters/DateFilterTest.php @@ -177,5 +177,4 @@ public function test_can_not_get_filter_pills_invalid_value(): void $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); } - } diff --git a/tests/Views/Filters/DateTimeFilterTest.php b/tests/Views/Filters/DateTimeFilterTest.php index d3714b0f0..0b53d4785 100644 --- a/tests/Views/Filters/DateTimeFilterTest.php +++ b/tests/Views/Filters/DateTimeFilterTest.php @@ -156,5 +156,4 @@ public function test_can_not_get_filter_pills_invalid_value(): void $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); } - } From 04048d8313ab01f8076147162f5dba4227f471ef Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:28:25 +0000 Subject: [PATCH 27/29] Update test toassertNull --- tests/Views/Filters/DateFilterTest.php | 2 +- tests/Views/Filters/DateTimeFilterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Views/Filters/DateFilterTest.php b/tests/Views/Filters/DateFilterTest.php index e113765ec..91efc8fe4 100644 --- a/tests/Views/Filters/DateFilterTest.php +++ b/tests/Views/Filters/DateFilterTest.php @@ -175,6 +175,6 @@ public function test_can_not_get_filter_pills_invalid_value(): void { $dateTime = (new DateTime('now')); - $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); + $this->assertNull($self::$filterInstance->getFilterPillValue('2022-2111')); } } diff --git a/tests/Views/Filters/DateTimeFilterTest.php b/tests/Views/Filters/DateTimeFilterTest.php index 0b53d4785..7321b9259 100644 --- a/tests/Views/Filters/DateTimeFilterTest.php +++ b/tests/Views/Filters/DateTimeFilterTest.php @@ -154,6 +154,6 @@ public function test_can_not_get_filter_pills_invalid_value(): void { $dateTime = (new DateTime('now')); - $this->assertSame($dateTime->format('d M Y'), self::$filterInstance->getFilterPillValue('2022-1111')); + $this->assertNull($self::$filterInstance->getFilterPillValue('2022-1111')); } } From d7264b3fd417c0b8ba508752584f8ddd4e829faa Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:29:51 +0000 Subject: [PATCH 28/29] Update $self to self --- tests/Views/Filters/DateFilterTest.php | 2 +- tests/Views/Filters/DateTimeFilterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Views/Filters/DateFilterTest.php b/tests/Views/Filters/DateFilterTest.php index 91efc8fe4..78155c9c7 100644 --- a/tests/Views/Filters/DateFilterTest.php +++ b/tests/Views/Filters/DateFilterTest.php @@ -175,6 +175,6 @@ public function test_can_not_get_filter_pills_invalid_value(): void { $dateTime = (new DateTime('now')); - $this->assertNull($self::$filterInstance->getFilterPillValue('2022-2111')); + $this->assertNull(self::$filterInstance->getFilterPillValue('2022-2111')); } } diff --git a/tests/Views/Filters/DateTimeFilterTest.php b/tests/Views/Filters/DateTimeFilterTest.php index 7321b9259..4b24d04e9 100644 --- a/tests/Views/Filters/DateTimeFilterTest.php +++ b/tests/Views/Filters/DateTimeFilterTest.php @@ -154,6 +154,6 @@ public function test_can_not_get_filter_pills_invalid_value(): void { $dateTime = (new DateTime('now')); - $this->assertNull($self::$filterInstance->getFilterPillValue('2022-1111')); + $this->assertNull(self::$filterInstance->getFilterPillValue('2022-1111')); } } From 642b4353519e6b80d1fe0a7eb8ad1ceb14559d07 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:31:43 +0000 Subject: [PATCH 29/29] Update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 603fe19df..d5ebe7647 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file - SettingColumns/ColumnsSet - Migrate methods for pre-render out of render by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 - Update tests to reflect hooks by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 -- Update tests to add invalid string tests for dates -- Remove maps and minimise functions from FrontendAssets +- Update tests to add invalid string tests for dates by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 +- Remove maps and minimise functions from FrontendAssets by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1534 ## [v3.1.2] - 2023-11-03 - Add Initial Lifecycle Hooks - Configuring/Configured by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1520