From 0f70ecce66a858fcebbd25985999b0994c60a62e Mon Sep 17 00:00:00 2001
From: Miroslav Bauer <mirekys@gmail.com>
Date: Fri, 26 Jan 2024 14:47:57 +0100
Subject: [PATCH] feat(search): support single-instance use-cases

---
 .../semantic-ui/js/oarepo_ui/search/util.js   | 25 ++++++++++---------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/util.js b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/util.js
index 00f33ee2..6b5f27b5 100644
--- a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/util.js
+++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/search/util.js
@@ -34,20 +34,21 @@ export function createSearchAppInit ({
             rootElement.dataset[_camelCase(autoInitDataAttr)]
         );
 
+        const componentPrefix = multi ? `${appId}.` : ''
         const SearchAppSearchbarContainerWithConfig = parametrize(SearchAppSearchbarContainer, { appName: appId })
         const internalComponentDefaults = {
-            [`${appId}.ActiveFilters.element`]: ActiveFiltersElement,
-            [`${appId}.BucketAggregation.element`]: BucketAggregationElement,
-            [`${appId}.BucketAggregationValues.element`]: BucketAggregationValuesElement,
-            [`${appId}.Count.element`]: CountElement,
-            [`${appId}.EmptyResults.element`]: EmptyResultsElement,
-            [`${appId}.Error.element`]: ErrorElement,
-            [`${appId}.SearchApp.facets`]: SearchAppFacets,
-            [`${appId}.SearchApp.layout`]: SearchAppLayout,
-            [`${appId}.SearchApp.resultOptions`]: SearchAppResultOptions,
-            [`${appId}.SearchApp.searchbarContainer`]: SearchAppSearchbarContainerWithConfig,
-            [`${appId}.SearchFilters.Toggle.element`]: SearchFiltersToggleElement,
-            [`${appId}.SearchApp.sort`]: SearchAppSort,
+            [`${componentPrefix}ActiveFilters.element`]: ActiveFiltersElement,
+            [`${componentPrefix}BucketAggregation.element`]: BucketAggregationElement,
+            [`${componentPrefix}BucketAggregationValues.element`]: BucketAggregationValuesElement,
+            [`${componentPrefix}Count.element`]: CountElement,
+            [`${componentPrefix}EmptyResults.element`]: EmptyResultsElement,
+            [`${componentPrefix}Error.element`]: ErrorElement,
+            [`${componentPrefix}SearchApp.facets`]: SearchAppFacets,
+            [`${componentPrefix}SearchApp.layout`]: SearchAppLayout,
+            [`${componentPrefix}SearchApp.resultOptions`]: SearchAppResultOptions,
+            [`${componentPrefix}SearchApp.searchbarContainer`]: SearchAppSearchbarContainerWithConfig,
+            [`${componentPrefix}SearchFilters.Toggle.element`]: SearchFiltersToggleElement,
+            [`${componentPrefix}SearchApp.sort`]: SearchAppSort,
         };
 
         loadComponents(appId, {