From 40440ce9a23f9b3cbd62e888186b7102e655e188 Mon Sep 17 00:00:00 2001 From: Galen Date: Tue, 15 Oct 2024 00:17:25 -0700 Subject: [PATCH] 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