From 984d24e8cbb091213a5ff5693841497d3f1e0f6d Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Fri, 24 Nov 2023 12:01:17 +0000 Subject: [PATCH] fix author search not working since last stable Properly render the index name in the Form rendered for htmx. fix #1082 --- CHANGELOG.md | 2 ++ src/Monocle/Api/ServerHTMX.hs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44fdb3762..59239cf36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file. ### Removed ### Fixed +- [web] authors search returning no results #1082 + ## [1.10.0] - 2023-11-06 ### Added diff --git a/src/Monocle/Api/ServerHTMX.hs b/src/Monocle/Api/ServerHTMX.hs index 318544a2f..9a8b5f305 100644 --- a/src/Monocle/Api/ServerHTMX.hs +++ b/src/Monocle/Api/ServerHTMX.hs @@ -27,9 +27,10 @@ searchAuthorsHandler :: ApiEffects es => AuthResult AuthenticatedUser -> Maybe C searchAuthorsHandler _ Nothing _ = pure $ pure () searchAuthorsHandler auth (Just index) queryM = do case queryM of - Just query -> do + Just authorName -> do + logInfo "Search request for author" ["author" .= authorName, "index" .= index] (SearchPB.AuthorResponse results) <- - searchAuthor auth (AuthorRequest (from index) (from query)) + searchAuthor auth (AuthorRequest (from index) (from authorName)) case toList results of [] -> pure $ div_ "No Results" _xs -> pure $ mapM_ authorToMarkup results @@ -47,7 +48,7 @@ searchAuthorsHandler auth (Just index) queryM = do , class_ "pf-c-form-control" , placeholder_ "Start typing to search authors" , hxGet "/htmx/authors_search" - , hxVals [iii|{"index": "#{index}"}|] + , hxVals [iii|{"index": "#{indexVal}"}|] , hxTrigger "keyup changed delay:500ms, search" , hxTarget "#search-results" ] @@ -55,6 +56,8 @@ searchAuthorsHandler auth (Just index) queryM = do div_ [id_ "search-results"] "" script_ pushToRouter where + indexVal :: Text + indexVal = from index countCachedAuthors = do resp <- esCountByIndex (tenantIndexName index) $ BH.CountQuery $ documentType ECachedAuthor case resp of