Commit e95f63ee authored by arturo's avatar arturo

[ngrams] Search in Ngrams Table

* #340
parent 41ecf1e2
...@@ -264,7 +264,7 @@ type PropsNoReload = ...@@ -264,7 +264,7 @@ type PropsNoReload =
| CommonProps | CommonProps
) )
type Props = type Props =
( reloadForest :: T2.ReloadS ( reloadForest :: T2.ReloadS
, reloadRoot :: T2.ReloadS , reloadRoot :: T2.ReloadS
| PropsNoReload ) | PropsNoReload )
...@@ -275,13 +275,13 @@ loadedNgramsTableCpt :: R.Component PropsNoReload ...@@ -275,13 +275,13 @@ loadedNgramsTableCpt :: R.Component PropsNoReload
loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where loadedNgramsTableCpt = here.component "loadedNgramsTable" cpt where
cpt props@{ path } _ = do cpt props@{ path } _ = do
searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path searchQuery <- T.useFocused (_.searchQuery) (\a b -> b { searchQuery = a }) path
pure $ R.fragment $ pure $ R.fragment $
[ loadedNgramsTableHeader { searchQuery } [] [ loadedNgramsTableHeader { searchQuery } []
, loadedNgramsTableBody props [] ] , loadedNgramsTableBody props [] ]
type LoadedNgramsTableHeaderProps = type LoadedNgramsTableHeaderProps =
( searchQuery :: T.Box SearchQuery ) ( searchQuery :: T.Box SearchQuery )
loadedNgramsTableHeader :: R2.Component LoadedNgramsTableHeaderProps loadedNgramsTableHeader :: R2.Component LoadedNgramsTableHeaderProps
loadedNgramsTableHeader = R.createElement loadedNgramsTableHeaderCpt loadedNgramsTableHeader = R.createElement loadedNgramsTableHeaderCpt
...@@ -500,9 +500,10 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list} ...@@ -500,9 +500,10 @@ displayRow { ngramsElement: NgramsElement {ngrams, root, list}
, termListFilter , termListFilter
, termSizeFilter } = , termSizeFilter } =
( (
isNothing root -- isNothing root
-- ^ Display only nodes without parents -- ^ Display only nodes without parents
&& maybe true (_ == list) termListFilter -- ^^ (?) allow child nodes to be searched (see #340)
maybe true (_ == list) termListFilter
-- ^ and which matches the ListType filter. -- ^ and which matches the ListType filter.
&& ngramsChildren ^. at ngrams /= Just true && ngramsChildren ^. at ngrams /= Just true
-- ^ and which are not scheduled to be added already -- ^ and which are not scheduled to be added already
...@@ -562,7 +563,7 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where ...@@ -562,7 +563,7 @@ mainNgramsTableCacheOnCpt = here.component "mainNgramsTableCacheOn" cpt where
, path , path
, tabNgramType , tabNgramType
, withAutoUpdate } _ = do , withAutoUpdate } _ = do
-- let path = initialPageParams session nodeId [defaultListId] tabType -- let path = initialPageParams session nodeId [defaultListId] tabType
path' <- T.useLive T.unequal path path' <- T.useLive T.unequal path
...@@ -731,6 +732,3 @@ sumOccurrences nt = sumOccChildren mempty ...@@ -731,6 +732,3 @@ sumOccurrences nt = sumOccChildren mempty
optps1 :: forall a. Show a => { desc :: String, mval :: Maybe a } -> R.Element optps1 :: forall a. Show a => { desc :: String, mval :: Maybe a } -> R.Element
optps1 { desc, mval } = H.option { value: value } [H.text desc] optps1 { desc, mval } = H.option { value: value } [H.text desc]
where value = maybe "" show mval where value = maybe "" show mval
module Gargantext.Components.Nodes.Lists.Tabs where module Gargantext.Components.Nodes.Lists.Tabs where
import Gargantext.Components.Nodes.Lists.Types hiding (here)
import Data.Array as A import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
...@@ -12,15 +14,14 @@ import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar) ...@@ -12,15 +14,14 @@ import Gargantext.Components.Nodes.Corpus.Chart.Pie (pie, bar)
import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree) import Gargantext.Components.Nodes.Corpus.Chart.Tree (tree)
import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType) import Gargantext.Components.Nodes.Corpus.Chart.Utils (mNgramsTypeFromTabType)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData) import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Components.Nodes.Lists.Types hiding (here)
import Gargantext.Components.Tab as Tab import Gargantext.Components.Tab as Tab
import Gargantext.Prelude (bind, pure, unit, ($), (<>)) import Gargantext.Components.Table.Types (Params)
import Gargantext.Prelude (bind, pure, unit, ($))
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), modeTabType) import Gargantext.Types (CTabNgramType(..), Mode(..), TabSubType(..), TabType(..), modeTabType)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record import Record as Record
import Record.Extra as RX import Record.Extra as RX
import Toestand as T import Toestand as T
...@@ -70,33 +71,32 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -70,33 +71,32 @@ ngramsViewCpt = here.component "ngramsView" cpt where
path <- T.useBox $ NTC.initialPageParams props.session initialPath.corpusId [initialPath.listId] initialPath.tabType path <- T.useBox $ NTC.initialPageParams props.session initialPath.corpusId [initialPath.listId] initialPath.tabType
{ listIds, nodeId, params } <- T.useLive T.unequal path { listIds, nodeId, params } <- T.useLive T.unequal path
let path' = {
corpusId: nodeId pure $
, limit: params.limit R.fragment
, listId: fromMaybe defaultListId $ A.head listIds [
, tabType: tabType ngramsView'
} { mode
let chartParams = { , boxes
corpusId: path'.corpusId , session
, limit: Just path'.limit , params
, listId: path'.listId , listIds
, tabType: path'.tabType , nodeId
} , corpusData: props.corpusData
} []
pure $ R.fragment ,
( charts chartParams tabNgramType NT.mainNgramsTable
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload { afterSync: afterSync chartsReload
, boxes , boxes
, cacheState , cacheState
, defaultListId , defaultListId
, path , path
, session , session
, tabNgramType , tabNgramType
, tabType , tabType
, withAutoUpdate: false , withAutoUpdate: false
} [] } []
] ]
)
where where
afterSync chartsReload _ = do afterSync chartsReload _ = do
case mNgramsType of case mNgramsType of
...@@ -118,7 +118,56 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -118,7 +118,56 @@ ngramsViewCpt = here.component "ngramsView" cpt where
, tabType , tabType
} }
charts _params CTabTerms = [
----------------
-- @XXX re-render issue -> clone component
type NgramsViewProps' =
( mode :: Mode
, boxes :: Boxes
, session :: Session
, listIds :: Array Int
, params :: Params
, nodeId :: Int
, corpusData :: CorpusData
)
ngramsView' :: R2.Component NgramsViewProps'
ngramsView' = R.createElement ngramsViewCpt'
ngramsViewCpt' :: R.Memo NgramsViewProps'
ngramsViewCpt' = R.memo' $ here.component "ngramsView_clone" cpt where
cpt { mode
, boxes
, session
, listIds
, params
, nodeId
, corpusData: { defaultListId }
} _ = do
let path' = {
corpusId: nodeId
, limit: params.limit
, listId: fromMaybe defaultListId $ A.head listIds
, tabType: tabType
}
let chartParams = {
corpusId: path'.corpusId
, limit: Just path'.limit
, listId: path'.listId
, tabType: path'.tabType
}
pure $
R.fragment $
charts chartParams tabNgramType
where
charts _params CTabTerms = [
{- {-
H.div {className: "row"} H.div {className: "row"}
[ H.div {className: "col-12 d-flex justify-content-center"} [ H.div {className: "col-12 d-flex justify-content-center"}
...@@ -147,10 +196,14 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -147,10 +196,14 @@ ngramsViewCpt = here.component "ngramsView" cpt where
] ]
, getChartFunction chartType $ { path: params, session } , getChartFunction chartType $ { path: params, session }
-} -}
] ]
charts params _ = [ chart params mode ] charts params' _ = [ chart params' mode ]
chart path Authors = pie { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Institutes = tree { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Sources = bar { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Terms = metrics { boxes, path, session, onClick: Nothing, onInit: Nothing }
tabType = TabCorpus (TabNgramType tabNgramType)
chart path Authors = pie { boxes, path, session, onClick: Nothing, onInit: Nothing } tabNgramType = modeTabType mode
chart path Institutes = tree { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Sources = bar { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Terms = metrics { boxes, path, session, onClick: Nothing, onInit: Nothing }
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