Commit 943d280e authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-warnings-cleanup' of...

Merge branch 'dev-warnings-cleanup' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev
parents 444a7106 62743a0e
module Gargantext.Components.Nodes.Annuaire where module Gargantext.Components.Nodes.Annuaire where
import Prelude (bind, identity, pure, const, ($), (<$>), (<>)) import Prelude (bind, identity, pure, const, discard, ($), (<$>), (<>))
import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?)) import Data.Argonaut (class DecodeJson, decodeJson, (.:), (.:?))
import Data.Array (head) import Data.Array (head)
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
...@@ -58,29 +58,31 @@ annuaire props = R.createElement annuaireCpt props [] ...@@ -58,29 +58,31 @@ annuaire props = R.createElement annuaireCpt props []
annuaireCpt :: R.Component AnnuaireProps annuaireCpt :: R.Component AnnuaireProps
annuaireCpt = R.hooksComponent "G.P.Annuaire.annuaire" cpt annuaireCpt = R.hooksComponent "G.P.Annuaire.annuaire" cpt
where where
cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ = cpt {session, path, info: info@(AnnuaireInfo {name, date: date'}), frontends} _ = do
pagePath <- R.useState' $ initialPagePath (fst path)
pure $ R.fragment pure $ R.fragment
[ T.tableHeaderLayout headerProps [ T.tableHeaderLayout headerProps
, H.p {} [] , H.p {} []
, H.div {className: "col-md-3"} , H.div {className: "col-md-3"}
[ H.text " Filter ", H.input { className: "form-control", style } ] [ H.text " Filter ", H.input { className: "form-control", style } ]
, H.br {} , H.br {}
, pageLayout { info, session, annuairePath: path, frontends} ] , pageLayout { info, session, pagePath, frontends} ]
where where
headerProps = { title: name, desc: name, query: "", date, user: ""} headerProps = { title: name, desc: name, query: "", date, user: ""}
date = "Last update: " <> date' date = "Last update: " <> date'
style = {width: "250px", display: "inline-block"} style = {width: "250px", display: "inline-block"}
initialPagePath nodeId = {nodeId, params: T.initialParams}
type PagePath = { nodeId :: Int type PagePath = { nodeId :: Int
, params :: T.Params , params :: T.Params
, frontends :: Frontends
} }
type PageLayoutProps = type PageLayoutProps =
( session :: Session ( session :: Session
, annuairePath :: R.State Int
, info :: AnnuaireInfo
, frontends :: Frontends , frontends :: Frontends
, info :: AnnuaireInfo
, pagePath :: R.State PagePath
) )
pageLayout :: Record PageLayoutProps -> R.Element pageLayout :: Record PageLayoutProps -> R.Element
...@@ -89,15 +91,13 @@ pageLayout props = R.createElement pageLayoutCpt props [] ...@@ -89,15 +91,13 @@ pageLayout props = R.createElement pageLayoutCpt props []
pageLayoutCpt :: R.Component PageLayoutProps pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponent "G.P.Annuaire.pageLayout" cpt pageLayoutCpt = R.hooksComponent "G.P.Annuaire.pageLayout" cpt
where where
cpt {annuairePath, info, session, frontends} _ = do cpt {info, frontends, pagePath, session} _ = do
pagePath <- R.useState' (initialPagePath frontends (fst annuairePath))
useLoader (fst pagePath) (loadPage session) $ useLoader (fst pagePath) (loadPage session) $
\table -> page {session, table, pagePath, annuairePath} \table -> page {session, table, frontends, pagePath}
initialPagePath frontends nodeId = {nodeId, params: T.initialParams, frontends}
type PageProps = type PageProps =
( session :: Session ( session :: Session
, annuairePath :: R.State Int , frontends :: Frontends
, pagePath :: R.State PagePath , pagePath :: R.State PagePath
-- , info :: AnnuaireInfo -- , info :: AnnuaireInfo
, table :: AnnuaireTable , table :: AnnuaireTable
...@@ -107,21 +107,21 @@ page :: Record PageProps -> R.Element ...@@ -107,21 +107,21 @@ page :: Record PageProps -> R.Element
page props = R.createElement pageCpt props [] page props = R.createElement pageCpt props []
pageCpt :: R.Component PageProps pageCpt :: R.Component PageProps
pageCpt = R.staticComponent "LoadedAnnuairePage" cpt pageCpt = R.hooksComponent "LoadedAnnuairePage" cpt
where where
cpt { session, annuairePath, pagePath cpt { session, pagePath, frontends
, table: (AnnuaireTable {annuaireTable})} _ = do , table: (AnnuaireTable {annuaireTable})} _ = do
T.table { rows, params, container, colNames, totalRecords, wrapColElts } pure $ T.table { rows, params, container, colNames, totalRecords, wrapColElts }
where where
totalRecords = 4361 -- TODO totalRecords = 4361 -- TODO
path = fst pagePath path = fst pagePath
rows = (\c -> {row: contactCells session path.frontends path.nodeId c, delete: false}) <$> annuaireTable rows = (\c -> {row: contactCells session frontends (fst pagePath).nodeId c, delete: false}) <$> annuaireTable
container = T.defaultContainer { title: "Annuaire" } -- TODO container = T.defaultContainer { title: "Annuaire" } -- TODO
colNames = T.ColumnName <$> [ "", "Name", "Company", "Service", "Role"] colNames = T.ColumnName <$> [ "", "Name", "Company", "Service", "Role"]
wrapColElts = const identity wrapColElts = const identity
setParams f = snd pagePath $ \pp@{nodeId, params: ps} -> setParams f = snd pagePath $ \pp@{params: ps} ->
pp {params = f ps, nodeId = fst annuairePath} pp {params = f ps}
params = T.initialParams /\ setParams params = (fst pagePath).params /\ setParams
type AnnuaireId = Int type AnnuaireId = Int
......
...@@ -86,10 +86,10 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element ...@@ -86,10 +86,10 @@ tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props [] tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.staticComponent "G.C.Table.tableHeaderLayout" cpt tableHeaderLayoutCpt = R.hooksComponent "G.C.Table.tableHeaderLayout" cpt
where where
cpt {title, desc, query, date, user} _ = cpt {title, desc, query, date, user} _ =
R.fragment pure $ R.fragment
[ H.div {className: "row"} [ H.div {className: "row"}
[ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ] [ H.div {className: "col-md-3"} [ H.h3 {} [H.text title] ]
, H.div {className: "col-md-9"} , H.div {className: "col-md-9"}
...@@ -146,7 +146,8 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt ...@@ -146,7 +146,8 @@ tableCpt = R.hooksComponent "G.C.Table.table" cpt
Just (ASC d) | c == d -> [lnk (Just (DESC c)) "DESC ", lnk Nothing (columnName c)] Just (ASC d) | c == d -> [lnk (Just (DESC c)) "DESC ", lnk Nothing (columnName c)]
Just (DESC d) | c == d -> [lnk (Just (ASC c)) "ASC ", lnk Nothing (columnName c)] Just (DESC d) | c == d -> [lnk (Just (ASC c)) "ASC ", lnk Nothing (columnName c)]
_ -> [lnk (Just (ASC c)) (columnName c)] _ -> [lnk (Just (ASC c)) (columnName c)]
R.useEffect1' state $ when (fst params /= stateParams state) $ (snd params) (const $ stateParams state) R.useEffect2' params state do
when (fst params /= stateParams state) $ (snd params) (const $ stateParams state)
pure $ container pure $ container
{ pageSizeControl: sizeDD pageSize { pageSizeControl: sizeDD pageSize
, pageSizeDescription: textDescription page pageSize' totalRecords , pageSizeDescription: textDescription page pageSize' totalRecords
......
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