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

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