Skip to content

Commit

Permalink
new entity type 'multiselect' for filters in setup.typoscript Filters…
Browse files Browse the repository at this point in the history
… with this entity are multi selectable
  • Loading branch information
thomas-sc committed Jan 13, 2025
1 parent b6dc2b7 commit 880b805
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Classes/Common/QueryParamsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ private function getAggs(): array

$entityField = $entityType['field'];
$entityTypeKey = $entityType['key'] ?? null;
$entityTypeMultiselect = $entityType['multiselect'] ?? null;

// create filter in aggs for filtering aggs (without filtering the own key for multiple selections)
// create filter in aggs for filtering aggs (without filtering the own key for multiple selections if multiselect == yes)
$filters = array_values(
array_filter(
array_map(
function ($key, $values) use ($entityField, $filterTypes) {
if ($key !== $entityField) {
function ($key, $values) use ($entityField, $filterTypes, $entityType) {
if ($key !== $entityField || ($filterTypes[$key]['multiselect'] !== 'yes')) {
// handle nested fields
if (($filterTypes[$key]['type'] == 'nested') && (isset($filterTypes[$key]['key']))) {
return [
Expand Down Expand Up @@ -215,7 +216,8 @@ function ($key, $values) use ($entityField, $filterTypes) {
$entityField => [
'terms' => [
'field' => $entityField . '.keyword',
'min_doc_count' => 0
// show docs with count 0 only for multiple select fields
'min_doc_count' => $entityTypeMultiselect === 'yes' ? 0 : 1,
]
]
],
Expand Down Expand Up @@ -327,7 +329,8 @@ private function getFilterTypes(): array
return [
$filter['field'] => [
'type' => $filter['type'],
'key' => $filter['key'] ?? ''
'key' => $filter['key'] ?? '',
'multiselect' => $filter['multiselect'] ?? ''
]
];
})
Expand Down

0 comments on commit 880b805

Please sign in to comment.