Commit 96a2b2e9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '340-dev-ngrams-tab-rc0.x' of...

Merge branch '340-dev-ngrams-tab-rc0.x' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents c0e20b33 9bab7a23
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,22 +71,22 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -70,22 +71,22 @@ 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
, 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 pure $
( charts chartParams tabNgramType R.fragment
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload [
ngramsView'
{ mode
, boxes
, session
, params
, listIds
, nodeId
, corpusData: props.corpusData
} []
,
NT.mainNgramsTable
{ afterSync: afterSync chartsReload
, boxes , boxes
, cacheState , cacheState
, defaultListId , defaultListId
...@@ -96,7 +97,6 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -96,7 +97,6 @@ ngramsViewCpt = here.component "ngramsView" cpt where
, withAutoUpdate: false , withAutoUpdate: false
} [] } []
] ]
)
where where
afterSync chartsReload _ = do afterSync chartsReload _ = do
case mNgramsType of case mNgramsType of
...@@ -118,6 +118,55 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -118,6 +118,55 @@ ngramsViewCpt = here.component "ngramsView" cpt where
, tabType , tabType
} }
----------------
-- @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 = [ charts _params CTabTerms = [
{- {-
H.div {className: "row"} H.div {className: "row"}
...@@ -148,9 +197,13 @@ ngramsViewCpt = here.component "ngramsView" cpt where ...@@ -148,9 +197,13 @@ 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 Authors = pie { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Institutes = tree { 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 Sources = bar { boxes, path, session, onClick: Nothing, onInit: Nothing }
chart path Terms = metrics { boxes, path, session, onClick: Nothing, onInit: Nothing } chart path Terms = metrics { boxes, path, session, onClick: Nothing, onInit: Nothing }
tabType = TabCorpus (TabNgramType tabNgramType)
tabNgramType = modeTabType mode
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