[GRAPH] container is now a prop of FacetsTable allowing customization in graph

parent 39181a8c
......@@ -64,6 +64,7 @@ type Props =
, query :: Array String
, totalRecords :: Int
, chart :: ReactElement
, container :: T.TableContainerProps -> Array ReactElement
}
type State =
......@@ -168,6 +169,7 @@ instance decodeResponse :: DecodeJson Response where
-- | Filter
-- TODO: unused
filterSpec :: forall state props action. Spec state props action
filterSpec = simpleSpec defaultPerformAction render
where
......@@ -196,7 +198,7 @@ layoutDocview = simpleSpec performAction render
}
render :: Render State Props Action
render dispatch {nodeId, query, totalRecords, chart} deletionState _ =
render dispatch {nodeId, query, totalRecords, chart, container} deletionState _ =
[ br'
, div [ style {textAlign : "center"}] [ text " Filter "
, input [className "form-control", style {width : "120px", display : "inline-block"}, placeholder "Filter here"]
......@@ -212,6 +214,7 @@ layoutDocview = simpleSpec performAction render
, totalRecords
, deletionState
, dispatch
, container
}
]
, div [className "col-md-12"]
......@@ -245,7 +248,7 @@ layoutDocviewGraph = simpleSpec performAction render
}
render :: Render State Props Action
render dispatch {nodeId, query, totalRecords, chart} deletionState _ =
render dispatch {nodeId, query, totalRecords, chart, container} deletionState _ =
[ br'
, p [] [text ""]
......@@ -259,6 +262,7 @@ layoutDocviewGraph = simpleSpec performAction render
, totalRecords
, deletionState
, dispatch
, container
}
, button [ style {backgroundColor: "peru", padding : "9px", color : "white", border : "white", float: "right"}
, onClick $ (\_ -> dispatch Trash)
......@@ -311,6 +315,7 @@ type PageLoaderProps row =
, totalRecords :: Int
, dispatch :: Action -> Effect Unit
, deletionState :: State
, container :: T.TableContainerProps -> Array ReactElement
| row
}
......@@ -319,17 +324,18 @@ renderPage :: forall props path.
{ totalRecords :: Int
, dispatch :: Action -> Effect Unit
, deletionState :: State
, container :: T.TableContainerProps -> Array ReactElement
| props
}
(Loader.Action PageParams)
renderPage _ _ {loaded: Nothing} _ = [] -- TODO loading spinner
renderPage loaderDispatch { totalRecords, dispatch
renderPage loaderDispatch { totalRecords, dispatch, container
, deletionState: {documentIdsToDelete, documentIdsDeleted}}
{currentPath: {nodeId, query}, loaded: Just res} _ =
[ T.tableElt
{ rows
, setParams: \params -> liftEffect $ loaderDispatch (Loader.SetPath {nodeId, query, params})
, container: T.graphContainer { title: "Documents" }
, container
, colNames:
T.ColumnName <$>
[ ""
......
......@@ -187,13 +187,15 @@ defaultContainer {title} props =
]
]
-- TODO: this needs to be in Gargantext.Pages.Corpus.Graph.Tabs
graphContainer :: {title :: String} -> TableContainerProps -> Array ReactElement
graphContainer {title} props =
[ div [className "row"]
[ div [className "col-md-12"] [b [] [text title]]
, div [className "col-md-12", style {marginTop : "10px"}] [props.pageSizeControl]
, div [className "col-md-12", style {marginTop : "10px"}] [props.pageSizeDescription]
, div [className "col-md-12", style {marginTop : "10px"}] [props.paginationLinks]
-- TODO better rendering of the paginationLinks
-- , div [className "col-md-12", style {marginTop : "10px"}] [props.paginationLinks]
]
, table [ className "table"]
[ thead [className "thead-dark"] [ props.tableHead ]
......
......@@ -7,6 +7,7 @@ import Data.Tuple (Tuple(..))
import Gargantext.Config (TabType(..), TabSubType(..))
import Gargantext.Components.GraphExplorer.Types (GraphSideCorpus(..))
import Gargantext.Components.FacetsTable as FT
import Gargantext.Components.Table as T
import Gargantext.Components.Tab as Tab
import React (ReactElement, ReactClass, Children, createElement)
import Thermite ( Spec, PerformAction, Render, _performAction, _render
......@@ -28,11 +29,12 @@ pureTabs = hideState (const {activeTab: 0}) statefulTabs
tab :: forall props state. Array String -> GraphSideCorpus -> Tuple String (Spec state props Tab.Action)
tab query (GraphSideCorpus {corpusId: nodeId, corpusLabel}) =
Tuple corpusLabel $
cmapProps (const {nodeId, query, chart, totalRecords: 4736}) $
cmapProps (const {nodeId, query, chart, totalRecords: 4736, container}) $
noState FT.docViewSpec
where
-- TODO totalRecords: probably need to insert a corpusLoader.
chart = mempty
container = T.graphContainer {title: corpusLabel}
statefulTabs :: Spec Tab.State Props Tab.Action
statefulTabs =
......
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