Commit 78875fb9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'feature/toestand-global-state' of...

Merge branch 'feature/toestand-global-state' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 6a0eb4d8 db7bcbe3
...@@ -91,7 +91,7 @@ forestCpt = here.component "forest" cpt where ...@@ -91,7 +91,7 @@ forestCpt = here.component "forest" cpt where
common = RX.pick props :: Record Common common = RX.pick props :: Record Common
cp handed' sessions' _ = cp handed' sessions' _ =
pure $ H.div { className: "forest" } pure $ H.div { className: "forest" }
(A.cons (plus handed' showLogin backend) (trees handed' sessions')) (A.cons (plus handed' showLogin) (trees handed' sessions'))
trees handed' sessions' = (tree handed') <$> unSessions sessions' trees handed' sessions' = (tree handed') <$> unSessions sessions'
tree handed' s@(Session {treeId}) = tree handed' s@(Session {treeId}) =
treeLoader { forestOpen treeLoader { forestOpen
...@@ -104,8 +104,8 @@ forestCpt = here.component "forest" cpt where ...@@ -104,8 +104,8 @@ forestCpt = here.component "forest" cpt where
, session: s , session: s
, tasks } [] , tasks } []
plus :: Handed -> T.Box Boolean -> T.Box (Maybe Backend) -> R.Element plus :: Handed -> T.Box Boolean -> R.Element
plus handed showLogin backend = H.div { className: "row" } plus handed showLogin = H.div { className: "row" }
[ H.button { className: buttonClass [ H.button { className: buttonClass
, on: { click } , on: { click }
, title } , title }
......
...@@ -102,20 +102,18 @@ treeCpt = here.component "tree" cpt where ...@@ -102,20 +102,18 @@ treeCpt = here.component "tree" cpt where
cpt p@{ session, tree: NTree (LNode { id, name, nodeType }) children } _ = do cpt p@{ session, tree: NTree (LNode { id, name, nodeType }) children } _ = do
setPopoverRef <- R.useRef Nothing setPopoverRef <- R.useRef Nothing
folderOpen <- T2.useMemberBox nodeId p.forestOpen folderOpen <- T2.useMemberBox nodeId p.forestOpen
open <- T.useLive T.unequal folderOpen folderOpen' <- T.useLive T.unequal folderOpen
pure $ H.ul { className: ulClass } pure $ H.ul { className: ulClass <> " " <> handedClass }
[ H.div { className: divClass } -- TODO: naughty div should not be in a ul
[ H.li { className: childrenClass children } [ H.li { className: childrenClass children }
[ nodeSpan (nsprops { folderOpen, name, id, nodeType, setPopoverRef, isLeaf }) [ nodeSpan (nsprops { folderOpen, name, id, nodeType, setPopoverRef, isLeaf })
(renderChildren open) (renderChildren folderOpen')
]
] ]
] ]
where where
isLeaf = A.null children isLeaf = A.null children
nodeId = mkNodeId session id nodeId = mkNodeId session id
ulClass = switchHanded "ml" "mr" p.handed <> "-auto tree" ulClass = switchHanded "ml" "mr" p.handed <> "-auto tree"
divClass = switchHanded "left" "right" p.handed <> "handed" handedClass = switchHanded "left" "right" p.handed <> "handed"
children' = A.sortWith fTreeID pubChildren children' = A.sortWith fTreeID pubChildren
pubChildren = if isPublic nodeType then map (map pub) children else children pubChildren = if isPublic nodeType then map (map pub) children else children
renderChildren false = [] renderChildren false = []
......
...@@ -59,11 +59,10 @@ routerCpt = here.component "router" cpt where ...@@ -59,11 +59,10 @@ routerCpt = here.component "router" cpt where
let sessionProps sId = Record.merge { session, sessionId: sId } props let sessionProps sId = Record.merge { session, sessionId: sId } props
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
showLogin <- T.useLive T.unequal boxes.showLogin
route' <- T.useLive T.unequal boxes.route route' <- T.useLive T.unequal boxes.route
pure $ R.fragment pure $ R.fragment
[ if showLogin then login' boxes else H.div {} [] [ loginModal { boxes } []
, case route' of , case route' of
GR.Annuaire s n -> annuaire (sessionNodeProps s n) [] GR.Annuaire s n -> annuaire (sessionNodeProps s n) []
GR.ContactPage s a n -> contact (Record.merge { annuaireId: a } $ sessionNodeProps s n) [] GR.ContactPage s a n -> contact (Record.merge { annuaireId: a } $ sessionNodeProps s n) []
...@@ -88,6 +87,22 @@ routerCpt = here.component "router" cpt where ...@@ -88,6 +87,22 @@ routerCpt = here.component "router" cpt where
GR.UserPage s n -> user (sessionNodeProps s n) [] GR.UserPage s n -> user (sessionNodeProps s n) []
] ]
type LoginModalProps = (
boxes :: Boxes
)
loginModal :: R2.Component LoginModalProps
loginModal = R.createElement loginModalCpt
loginModalCpt :: R.Component LoginModalProps
loginModalCpt = here.component "loginModal" cpt
where
cpt { boxes: boxes@{ showLogin } } _ = do
showLogin' <- T.useLive T.unequal showLogin
pure $ if showLogin' then login' boxes else H.div {} []
forested :: R2.Component Props forested :: R2.Component Props
forested = R.createElement forestedCpt forested = R.createElement forestedCpt
......
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