Commit 92e919e9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/638-tree-search-enrich-search-results-with-the-path-of-the-node' into dev
parents f60d62f9 c6d891bb
...@@ -172,12 +172,10 @@ treeSearchRender = R2.leaf treeSearchRenderCpt ...@@ -172,12 +172,10 @@ treeSearchRender = R2.leaf treeSearchRenderCpt
treeSearchRenderCpt :: R.Component RenderProps treeSearchRenderCpt :: R.Component RenderProps
treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
cpt { visible, session, searchData, goToRoute } _ = do cpt { visible, session, searchData, goToRoute } _ = do
{ route } <- AppStore.use
route' <- T.useLive T.unequal route
pure $ H.div {className: "search-modal__results"} (results route' searchData) pure $ H.div {className: "search-modal__results"} (results searchData)
where where
results route' s = map searchResult s results s = map searchResult s
where where
searchResult sd = H.div searchResult sd = H.div
{ className: "result py-1"} { className: "result py-1"}
...@@ -197,7 +195,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where ...@@ -197,7 +195,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
[ [
H.text " Path: " H.text " Path: "
, breadcrumbView { format: "text" , breadcrumbView { format: "text"
, route: route' , route: getRouteFromSearchResult sd session
, session , session
} }
] ]
...@@ -207,7 +205,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where ...@@ -207,7 +205,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
{ className: "result__button" { className: "result__button"
, callback: \_ -> do , callback: \_ -> do
T.write_ false visible T.write_ false visible
goToRoute $ fromMaybe Home $ nodeTypeAppRoute sd.type (sessionId session) sd.id goToRoute $ getRouteFromSearchResult sd session
, variant: ButtonVariant Light } , variant: ButtonVariant Light }
[ [
B.icon {name: getIcon sd.type true} B.icon {name: getIcon sd.type true}
...@@ -220,7 +218,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where ...@@ -220,7 +218,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
[ [
H.text " — " H.text " — "
, breadcrumbView { format: "text" , breadcrumbView { format: "text"
, route: route' , route: getRouteFromSearchResult sd session
, session: session , session: session
} }
] ]
...@@ -231,3 +229,6 @@ type LoadProps = ( session :: Session, query :: String ) ...@@ -231,3 +229,6 @@ type LoadProps = ( session :: Session, query :: String )
loadSearch :: Record LoadProps -> AffRESTError (Array SearchData) loadSearch :: Record LoadProps -> AffRESTError (Array SearchData)
loadSearch { session: s, query: q} = get s $ appPath (TreeFlat (sessionId s) (sessionRoot s) q) loadSearch { session: s, query: q} = get s $ appPath (TreeFlat (sessionId s) (sessionRoot s) q)
where sessionRoot (Session {treeId}) = treeId where sessionRoot (Session {treeId}) = treeId
getRouteFromSearchResult :: SearchData -> Session -> AppRoute
getRouteFromSearchResult sd session = fromMaybe Home $ nodeTypeAppRoute sd.type (sessionId session) sd.id
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment