Commit 79a264e5 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/208-dev-phylo-search-improvements' into dev

parents 7c64beb4 957458cc
...@@ -121,10 +121,10 @@ docListCpt = here.component "main" cpt where ...@@ -121,10 +121,10 @@ docListCpt = here.component "main" cpt where
-- | Helpers -- | Helpers
-- | -- |
errorHandler err = do errorHandler err = do
here.warn2 "[pageLayout] RESTError" err here.warn2 "[docList] RESTError" err
case err of case err of
ReadJSONError err' -> ReadJSONError err' ->
here.warn2 "[pageLayout] ReadJSONError" $ show err' here.warn2 "[docList] ReadJSONError" $ show err'
_ -> pure unit _ -> pure unit
-- | Component -- | Component
-- | -- |
......
...@@ -4,7 +4,7 @@ module Gargantext.Components.PhyloExplorer.Sidebar.DocList ...@@ -4,7 +4,7 @@ module Gargantext.Components.PhyloExplorer.Sidebar.DocList
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array (concat) import Data.Array as A
import Data.Foldable (intercalate) import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Sequence as Seq import Data.Sequence as Seq
...@@ -12,10 +12,9 @@ import Data.Tuple.Nested ((/\)) ...@@ -12,10 +12,9 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (Variant(..)) import Gargantext.Components.Bootstrap.Types (Variant(..))
import Gargantext.Components.FacetsTable (DocumentsView(..), Rows(..), initialPagePath, loadPage, publicationDate) import Gargantext.Components.FacetsTable (DocumentsView(..), Rows(..), publicationDate, initialPageGQL, loadPageGQL)
import Gargantext.Components.PhyloExplorer.Store as PhyloStore import Gargantext.Components.PhyloExplorer.Store as PhyloStore
import Gargantext.Components.PhyloExplorer.Types (CorpusId, DocId, FrameDoc(..), ListId) import Gargantext.Components.PhyloExplorer.Types (CorpusId, DocId, FrameDoc(..), ListId)
import Gargantext.Components.RandomText (words)
import Gargantext.Components.Search (SearchQuery(..), SearchType(..)) import Gargantext.Components.Search (SearchQuery(..), SearchType(..))
import Gargantext.Config (defaultFrontends) import Gargantext.Config (defaultFrontends)
import Gargantext.Config.REST (RESTError(..)) import Gargantext.Config.REST (RESTError(..))
...@@ -25,7 +24,7 @@ import Gargantext.Hooks.Session (useSession) ...@@ -25,7 +24,7 @@ import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1') import Gargantext.Hooks.UpdateEffect (useUpdateEffect1')
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
import Gargantext.Utils (getter, (?)) import Gargantext.Utils ((?))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import React.SyntheticEvent as SE import React.SyntheticEvent as SE
import Reactix as R import Reactix as R
...@@ -51,6 +50,7 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -51,6 +50,7 @@ docListWrapperCpt = here.component "wrapper" cpt where
extractedTerms <- R2.useLive' store.extractedTerms extractedTerms <- R2.useLive' store.extractedTerms
corpusId <- R2.useLive' store.corpusId corpusId <- R2.useLive' store.corpusId
listId <- R2.useLive' store.listId listId <- R2.useLive' store.listId
selectedTerm <- R2.useLive' store.selectedTerm
query' /\ query <- R2.useBox' Nothing query' /\ query <- R2.useBox' Nothing
...@@ -58,15 +58,15 @@ docListWrapperCpt = here.component "wrapper" cpt where ...@@ -58,15 +58,15 @@ docListWrapperCpt = here.component "wrapper" cpt where
-- | -- |
let let
toSearchQuery items = SearchQuery toSearchQuery t = SearchQuery
{ expected: SearchDoc { expected: SearchDoc
, query: concat $ words <$> (getter _.label) <$> items , query: A.catMaybes [t]
} }
-- | Hooks -- | Hooks
-- | -- |
R.useEffect1' extractedTerms $ R.useEffect1' selectedTerm $
T.write_ (extractedTerms # toSearchQuery >>> Just) query T.write_ (selectedTerm # toSearchQuery >>> Just) query
-- | Render -- | Render
-- | -- |
...@@ -113,14 +113,14 @@ docListCpt = here.component "main" cpt where ...@@ -113,14 +113,14 @@ docListCpt = here.component "main" cpt where
-- | Helpers -- | Helpers
-- | -- |
errorHandler err = do errorHandler err = do
here.warn2 "[pageLayout] RESTError" err here.warn2 "[docList] RESTError" err
case err of case err of
ReadJSONError err' -> ReadJSONError err' ->
here.warn2 "[pageLayout] ReadJSONError" $ show err' here.warn2 "[docList] ReadJSONError" $ show err'
_ -> pure unit _ -> pure unit
-- | Component -- | Component
-- | -- |
cpt { query cpt { query: query@(SearchQuery { query: q' })
, session , session
, corpusId: nodeId , corpusId: nodeId
, listId , listId
...@@ -130,8 +130,10 @@ docListCpt = here.component "main" cpt where ...@@ -130,8 +130,10 @@ docListCpt = here.component "main" cpt where
-- | States -- | States
-- | -- |
path' /\ path
<- R2.useBox' $ initialPagePath { nodeId, listId, query, session } path' /\ path <- R2.useBox' $ initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session }
state' /\ state <- state' /\ state <-
R2.useBox' Nothing R2.useBox' Nothing
...@@ -148,7 +150,7 @@ docListCpt = here.component "main" cpt where ...@@ -148,7 +150,7 @@ docListCpt = here.component "main" cpt where
useLoaderEffect useLoaderEffect
{ errorHandler { errorHandler
, state , state
, loader: loadPage , loader: loadPageGQL
, path: path' , path: path'
} }
...@@ -157,10 +159,13 @@ docListCpt = here.component "main" cpt where ...@@ -157,10 +159,13 @@ docListCpt = here.component "main" cpt where
-- (on query change, reload fetched docs) -- (on query change, reload fetched docs)
useUpdateEffect1' query $ useUpdateEffect1' query $
flip T.write_ path $ initialPagePath { nodeId, listId, query, session } T.write_ (initialPageGQL { corpusId: nodeId
, ngramsTerms: q'
, session }) path
-- (on fetch success, extract existing docs) -- (on fetch success, extract existing docs)
useUpdateEffect1' state' case state' of useUpdateEffect1' state' case state' of
Nothing -> T.write_ (Just Seq.empty) rows Nothing -> T.write_ (Just Seq.empty) rows
Just r -> case r of Just r -> case r of
Docs { docs } -> T.write_ (Just docs) rows Docs { docs } -> T.write_ (Just docs) rows
...@@ -217,7 +222,10 @@ docListCpt = here.component "main" cpt where ...@@ -217,7 +222,10 @@ docListCpt = here.component "main" cpt where
] ]
, ,
R2.when (not $ eq results Seq.empty) $ R2.when (not $ eq results Seq.empty) $
H.div {}
[
H.h6 {} [ H.text $ show (Seq.length results) <> " related documents"]
,
H.ul H.ul
{ className: intercalate " " { className: intercalate " "
[ "phylo-doc-list" [ "phylo-doc-list"
...@@ -236,6 +244,7 @@ docListCpt = here.component "main" cpt where ...@@ -236,6 +244,7 @@ docListCpt = here.component "main" cpt where
, frontends , frontends
} }
] ]
]
--------------------------------------------------------- ---------------------------------------------------------
......
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