[NGRAMS]: add mode to path

parent 1e1a2c3e
...@@ -52,7 +52,7 @@ import Gargantext.Pages.Corpus.Tabs.Types (CorpusInfo(..), PropsRow) ...@@ -52,7 +52,7 @@ import Gargantext.Pages.Corpus.Tabs.Types (CorpusInfo(..), PropsRow)
type Props = { mode :: Mode | PropsRow } type Props = { mode :: Mode | PropsRow }
type PageParams = {nodeId :: Int, params :: T.Params} type PageParams = {nodeId :: Int, params :: T.Params, mode :: Mode}
type Props' = { path :: PageParams type Props' = { path :: PageParams
, loaded :: Maybe NgramsTable , loaded :: Maybe NgramsTable
...@@ -299,6 +299,8 @@ data Action ...@@ -299,6 +299,8 @@ data Action
data Mode = Authors | Sources | Institutes | Terms data Mode = Authors | Sources | Institutes | Terms
derive instance eqMode :: Eq Mode
type Dispatch = Action -> Effect Unit type Dispatch = Action -> Effect Unit
tableContainer :: { searchQuery :: String tableContainer :: { searchQuery :: String
...@@ -429,14 +431,14 @@ ngramsTableSpec' = simpleSpec performAction render ...@@ -429,14 +431,14 @@ ngramsTableSpec' = simpleSpec performAction render
-- patch the root of the child to be equal to the root of the parent. -- patch the root of the child to be equal to the root of the parent.
render :: Render State Props' Action render :: Render State Props' Action
render dispatch { path: {nodeId} render dispatch { path: {nodeId, mode}
, loaded: initTable , loaded: initTable
, dispatch: loaderDispatch } , dispatch: loaderDispatch }
{ ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery } { ngramsTablePatch, ngramsParent, ngramsChildren, searchQuery }
_reactChildren = _reactChildren =
[ T.tableElt [ T.tableElt
{ rows { rows
, setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params}) , setParams: \params -> loaderDispatch (Loader.SetPath {nodeId, params, mode})
, container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable} , container: tableContainer {searchQuery, dispatch, ngramsParent, ngramsChildren, ngramsTable}
, colNames: , colNames:
T.ColumnName <$> T.ColumnName <$>
...@@ -480,8 +482,8 @@ ngramsTableSpec' = simpleSpec performAction render ...@@ -480,8 +482,8 @@ ngramsTableSpec' = simpleSpec performAction render
, delete: false , delete: false
} }
initialPageParams :: Int -> PageParams initialPageParams :: Int -> Mode -> PageParams
initialPageParams nodeId = {nodeId, params: T.initialParams} initialPageParams nodeId mode = {nodeId, params: T.initialParams, mode}
type PageLoaderProps = type PageLoaderProps =
{ path :: PageParams { path :: PageParams
...@@ -505,9 +507,9 @@ ngramsTableSpec :: Spec {} Props Void ...@@ -505,9 +507,9 @@ ngramsTableSpec :: Spec {} Props Void
ngramsTableSpec = simpleSpec defaultPerformAction render ngramsTableSpec = simpleSpec defaultPerformAction render
where where
render :: Render {} Props Void render :: Render {} Props Void
render _ {path: nodeId} _ _ = render _ {path: nodeId, mode} _ _ =
-- TODO: ignored mode, ignored loaded: corpusInfo -- TODO: ignored ignored loaded: corpusInfo
[ ngramsLoader { path: initialPageParams nodeId [ ngramsLoader { path: initialPageParams nodeId mode
, component: createClass "NgramsTableLayout" ngramsTableSpec' initialState , component: createClass "NgramsTableLayout" ngramsTableSpec' initialState
} ] } ]
......
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