From 4ebeb0d3a5a8af4a8e6eb7a153e0af05e4d76f1f Mon Sep 17 00:00:00 2001 From: Galen Date: Tue, 15 Oct 2024 00:15:01 -0700 Subject: [PATCH 1/3] expect kwargs in get_searchview_instance(), pass default_property to get_searchview_name, re #11546 --- arches/app/search/components/base.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arches/app/search/components/base.py b/arches/app/search/components/base.py index b0b6e06cf46..d8607abd27e 100644 --- a/arches/app/search/components/base.py +++ b/arches/app/search/components/base.py @@ -80,7 +80,7 @@ def get_filter(self, componentname): else: return None - def get_searchview_name(self): + def get_searchview_name(self, default_type=None): if not self.request: searchview_component_name = None elif self.request.method == "POST": @@ -101,8 +101,11 @@ def get_searchview_name(self): return searchview_component_name - def get_searchview_instance(self): - searchview_component_name = self.get_searchview_name() + def get_searchview_instance(self, **kwargs): + default_property = kwargs.get("default_property", None) + searchview_component_name = self.get_searchview_name( + default_property=default_property + ) return self.get_filter(searchview_component_name) def create_search_query_dict(self, key_value_pairs: List[Tuple[str, Any]]): From 40440ce9a23f9b3cbd62e888186b7102e655e188 Mon Sep 17 00:00:00 2001 From: Galen Date: Tue, 15 Oct 2024 00:17:25 -0700 Subject: [PATCH 2/3] filter search-views by passed-in default_type, else use default search-view, re #11546 --- arches/app/search/components/base.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/arches/app/search/components/base.py b/arches/app/search/components/base.py index d8607abd27e..74bbf66d6a3 100644 --- a/arches/app/search/components/base.py +++ b/arches/app/search/components/base.py @@ -81,6 +81,7 @@ def get_filter(self, componentname): return None def get_searchview_name(self, default_type=None): + searchview_component = [] if not self.request: searchview_component_name = None elif self.request.method == "POST": @@ -89,14 +90,23 @@ def get_searchview_name(self, default_type=None): searchview_component_name = self.request.GET.get("search-view", None) if not searchview_component_name: - # get default search_view component - searchview_component = list( - filter( - lambda x: x.config.get("default", False) - and x.type == "search-view", - list(self.search_filters.values()), + if default_type: # e.g. "searchViewDefault" + searchview_component = list( + filter( + lambda x: x.config.get(default_type, False) + and x.type == "search-view", + list(self.search_filters.values()), + ) + ) + if not default_type or len(searchview_component) == 0: + searchview_component = list( + filter( + lambda x: x.config.get("default", False) + and x.type == "search-view", + list(self.search_filters.values()), + ) ) - )[0] + searchview_component = searchview_component[0] searchview_component_name = searchview_component.componentname return searchview_component_name From 5eab3e42d4ea3546443b0cafdd7ab0c02989c61c Mon Sep 17 00:00:00 2001 From: Galen Date: Tue, 15 Oct 2024 00:20:25 -0700 Subject: [PATCH 3/3] update refs to be default_type, not default_property; pass in searchViewDefault in SearchView, re #11546 --- arches/app/search/components/base.py | 6 ++---- arches/app/views/search.py | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arches/app/search/components/base.py b/arches/app/search/components/base.py index 74bbf66d6a3..82a22413d89 100644 --- a/arches/app/search/components/base.py +++ b/arches/app/search/components/base.py @@ -112,10 +112,8 @@ def get_searchview_name(self, default_type=None): return searchview_component_name def get_searchview_instance(self, **kwargs): - default_property = kwargs.get("default_property", None) - searchview_component_name = self.get_searchview_name( - default_property=default_property - ) + default_type = kwargs.get("default_type", None) + searchview_component_name = self.get_searchview_name(default_type=default_type) return self.get_filter(searchview_component_name) def create_search_query_dict(self, key_value_pairs: List[Tuple[str, Any]]): diff --git a/arches/app/views/search.py b/arches/app/views/search.py index 2feeff1c99f..c1f22471d67 100644 --- a/arches/app/views/search.py +++ b/arches/app/views/search.py @@ -81,7 +81,9 @@ def get(self, request): ) geocoding_providers = Geocoder.objects.all() search_component_factory = SearchFilterFactory(request) - searchview_instance = search_component_factory.get_searchview_instance() + searchview_instance = search_component_factory.get_searchview_instance( + default_type="searchViewDefault" + ) search_components = searchview_instance.get_searchview_filters() datatypes = DDataType.objects.all()