From 369929e0a954d73190919873f07ff8969f32bf26 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 22 Aug 2023 11:49:09 +0200 Subject: [PATCH 1/3] fix: :ambulance: Fixes select all columns --- src/Traits/WithColumnSelect.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index a26dcb85c..af74bb035 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -63,7 +63,11 @@ public function getDefaultVisibleColumns(): array public function selectAllColumns() { - $this->{$this->tableName}['columns'] = []; + $this->selectedColumns = $this->getColumns()->map(function ($column) { + return $column->getSlug(); + })->toArray(); + $this->{$this->tableName}['columns'] = $this->selectedColumns; + $this->forgetColumnSelectSession(); $this->forgetColumnSelectSession(); event(new ColumnsSelected($this->getColumnSelectSessionKey(), $this->selectedColumns)); } From c8fed72227d3bc74a89890736f6bac332c330124 Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 22 Aug 2023 12:01:57 +0200 Subject: [PATCH 2/3] test: :ambulance: Fixes test on event when selecting all columns --- tests/Events/ColumnsSelectedTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Events/ColumnsSelectedTest.php b/tests/Events/ColumnsSelectedTest.php index 03f0b1cef..2bd03f75e 100644 --- a/tests/Events/ColumnsSelectedTest.php +++ b/tests/Events/ColumnsSelectedTest.php @@ -14,7 +14,9 @@ public function an_event_is_emitted_when_a_column_selection_are_updated() ColumnsSelected::class, ]); - $test['columns'] = $this->basicTable->selectedColumns; + $test['columns'] = $this->basicTable->getColumns()->map(function ($column) { + return $column->getSlug(); + })->toArray(); $test['key'] = $this->basicTable->getDataTableFingerprint().'-columnSelectEnabled'; // Select all columns to test event trigger From c0ac20ffca1c15e7acf245af3ef4a095d2ff4cae Mon Sep 17 00:00:00 2001 From: Tobias Date: Tue, 22 Aug 2023 12:02:54 +0200 Subject: [PATCH 3/3] refactor: Removed duplicated row --- src/Traits/WithColumnSelect.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Traits/WithColumnSelect.php b/src/Traits/WithColumnSelect.php index af74bb035..7079f47d6 100644 --- a/src/Traits/WithColumnSelect.php +++ b/src/Traits/WithColumnSelect.php @@ -68,7 +68,6 @@ public function selectAllColumns() })->toArray(); $this->{$this->tableName}['columns'] = $this->selectedColumns; $this->forgetColumnSelectSession(); - $this->forgetColumnSelectSession(); event(new ColumnsSelected($this->getColumnSelectSessionKey(), $this->selectedColumns)); }