Skip to content

Commit

Permalink
filter search-views by passed-in default_type, else use default searc…
Browse files Browse the repository at this point in the history
…h-view, re #11546
  • Loading branch information
whatisgalen committed Oct 15, 2024
1 parent 4ebeb0d commit 40440ce
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions arches/app/search/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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
Expand Down

0 comments on commit 40440ce

Please sign in to comment.