From e37b67e0cb8531a811ec2d939b37a86ea47280f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Fri, 5 Feb 2021 12:53:31 +0100 Subject: [PATCH] [BUGFIX:BP:10] Make relevance sorting option markable as active * Makes it possible to mark relevance sorting option as active. Fixes: #2541 --- .../Search/ResultSet/ResultSetReconstitutionProcessor.php | 4 ++++ Resources/Private/Partials/Result/Sorting.html | 2 +- .../Search/ResultSet/ResultSetReconstitutionProcessorTest.php | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php b/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php index 7eb0e7f699..0a239644fa 100644 --- a/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php +++ b/Classes/Domain/Search/ResultSet/ResultSetReconstitutionProcessor.php @@ -134,6 +134,10 @@ protected function parseSortingIntoObjects(SearchResultSet $resultSet) $label = $cObj->stdWrap($label, $sortingOptions['label.']); } + if ($isResetOption && !$hasSorting) { + $selected = true; + } + $sorting = $this->getObjectManager()->get(Sorting::class, $resultSet, $sortingName, $field, $direction, $label, $selected, $isResetOption); $resultSet->addSorting($sorting); } diff --git a/Resources/Private/Partials/Result/Sorting.html b/Resources/Private/Partials/Result/Sorting.html index 0cf7fafb46..ec36b807da 100644 --- a/Resources/Private/Partials/Result/Sorting.html +++ b/Resources/Private/Partials/Result/Sorting.html @@ -14,7 +14,7 @@ -
  • +
  • {sorting.label}
  • diff --git a/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php b/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php index c5f5b4c549..43eaa07508 100644 --- a/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php +++ b/Tests/Unit/Domain/Search/ResultSet/ResultSetReconstitutionProcessorTest.php @@ -1059,7 +1059,8 @@ public function returnsResultSetWithConfiguredSortingOptions() $processor->process($searchResultSet); $this->assertEquals(1, $searchResultSet->getSortings()->getCount(), 'No sorting was created'); - $this->assertFalse($searchResultSet->getSortings()->getHasSelected(), 'Expected that no selected sorting was present'); + $this->assertEquals('relevance', $searchResultSet->getSortings()->getSelected()->getName()); + $this->assertTrue($searchResultSet->getSortings()->getHasSelected(), 'The sorting by "relevance/score" is active but not marked as selected.'); } /**