diff --git a/plugin/EstateList.php b/plugin/EstateList.php index a8c3e6c24..c92f56cdd 100644 --- a/plugin/EstateList.php +++ b/plugin/EstateList.php @@ -313,6 +313,8 @@ private function getEstateParameters(int $currentPage, bool $formatOutput) } } elseif ($this->getShowReferenceEstate() === DataListView::HIDE_REFERENCE_ESTATE) { $requestParams['filter']['referenz'][] = ['op' => '=', 'val' => 0]; + } elseif ($this->getShowReferenceEstate() === DataListView::SHOW_ONLY_REFERENCE_ESTATE) { + $requestParams['filter']['referenz'][] = ['op' => '=', 'val' => 1]; } $requestParams += $this->addExtraParams(); diff --git a/plugin/Filter/DefaultFilterBuilderListView.php b/plugin/Filter/DefaultFilterBuilderListView.php index c4b7dd83f..a4221044a 100644 --- a/plugin/Filter/DefaultFilterBuilderListView.php +++ b/plugin/Filter/DefaultFilterBuilderListView.php @@ -89,11 +89,7 @@ public function buildFilter(): array case DataListView::LISTVIEW_TYPE_FAVORITES: $filter = $this->getFavoritesFilter(); break; - case DataListView::LISTVIEW_TYPE_REFERENCE: - $filter = $this->getReferenceViewFilter(); - break; } - $filterWithRegion = $this->addSubRegionFilter($filter); return $filterWithRegion; @@ -161,17 +157,4 @@ private function getFavoritesFilter(): array return $filter; } - - /** - * @return array - */ - private function getReferenceViewFilter(): array - { - $filter = $this->_defaultFilter; - $filter['referenz'] = [ - ['op' => '=', 'val' => 1], - ]; - - return $filter; - } } \ No newline at end of file diff --git a/plugin/Form/Preview/FormPreviewEstate.php b/plugin/Form/Preview/FormPreviewEstate.php index dd1670375..a1711edea 100644 --- a/plugin/Form/Preview/FormPreviewEstate.php +++ b/plugin/Form/Preview/FormPreviewEstate.php @@ -10,6 +10,7 @@ use onOffice\SDK\onOfficeSDK; use onOffice\WPlugin\API\APIClientActionGeneric; use onOffice\WPlugin\API\ApiClientException; +use onOffice\WPlugin\DataView\DataListView; use onOffice\WPlugin\DataView\DataListViewFactory; use onOffice\WPlugin\DataView\UnknownViewException; use onOffice\WPlugin\Filter\DefaultFilterBuilderFactory; @@ -70,6 +71,16 @@ public function preview(string $listName): int } $pDefaultFilterBuilder = $this->_pDefaultFilterBuilderFactory->buildDefaultListViewFilter($pListView); $requestParams['filter'] = $pDefaultFilterBuilder->buildFilter(); + + switch ($pListView->getShowReferenceEstate()) { + case DataListView::HIDE_REFERENCE_ESTATE: + $requestParams['filter']['referenz'][] = ['op' => '=', 'val' => 0]; + break; + case DataListView::SHOW_ONLY_REFERENCE_ESTATE: + $requestParams['filter']['referenz'][] = ['op' => '=', 'val' => 1]; + break; + } + $pApiClientAction = $this->_pApiClientAction->withActionIdAndResourceType (onOfficeSDK::ACTION_ID_READ, 'estate'); $pApiClientAction->setParameters($requestParams); diff --git a/tests/TestClassDefaultFilterBuilderListView.php b/tests/TestClassDefaultFilterBuilderListView.php index 99df54ca1..d9e8503f8 100644 --- a/tests/TestClassDefaultFilterBuilderListView.php +++ b/tests/TestClassDefaultFilterBuilderListView.php @@ -160,12 +160,6 @@ public function testReferenceViewFilter() 'val' => 1, ], ], - 'referenz' => [ - [ - 'op' => '=', - 'val' => 1, - ], - ], ]; diff --git a/tests/TestClassFormPreviewEstate.php b/tests/TestClassFormPreviewEstate.php index 422b3a7f4..3a388cd8b 100644 --- a/tests/TestClassFormPreviewEstate.php +++ b/tests/TestClassFormPreviewEstate.php @@ -58,7 +58,7 @@ private function buildSubject(): FormPreviewEstate ->after("1") ->id("2") ->method('setParameters') - ->with(['listlimit' => 0, 'filter' => ['veroeffentlichen' => [['op' => '=', 'val' => 1]]], 'filterid' => 24]) + ->with(['listlimit' => 0, 'filter' => ['veroeffentlichen' => [['op' => '=', 'val' => 1]],'referenz' => [['op' => '=','val' => 0],],], 'filterid' => 24]) ->willReturnSelf(); $pApiClientAction ->expects($this->once())