Commit 754b9eb2 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[ERGO] Tree.Node is not leaf then chevron

parent 305410c7
......@@ -31,7 +31,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr
import Gargantext.Components.Forest.Tree.Node.Tools.Task (Tasks, tasksStruct)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>), (==))
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>), (==), (<<<), not)
import Gargantext.Routes (AppRoute)
import Gargantext.Routes as GR
import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get)
......@@ -200,7 +200,8 @@ toHtml p@{ asyncTasks
let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li {} $
[ nodeMainSpan { id
[ nodeMainSpan (isLeaf ary)
{ id
, dispatch: pAction
, folderOpen
, frontends
......@@ -223,6 +224,9 @@ toHtml p@{ asyncTasks
}
)
isLeaf :: Array FTree -> Boolean
isLeaf = not <<< A.null
type ChildNodesProps =
( asyncTasks :: R.State GAT.Storage
, children :: Array FTree
......
......@@ -49,9 +49,12 @@ type NodeMainSpanProps =
| CommonProps
)
nodeMainSpan :: Record NodeMainSpanProps
-> R.Element
nodeMainSpan p@{ dispatch, folderOpen, frontends, handed, session } = R.createElement el p []
type IsLeaf = Boolean
nodeMainSpan :: IsLeaf
-> Record NodeMainSpanProps
-> R.Element
nodeMainSpan isLeaf p@{ dispatch, folderOpen, frontends, handed, session } = R.createElement el p []
where
el = R2.hooksComponent thisModule "nodeMainSpan" cpt
cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do
......@@ -69,7 +72,7 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, handed, session } = R.createEl
pure $ H.span (dropProps droppedFile isDragOver)
$ ordering
[ folderIcon nodeType folderOpen
, chevronIcon handed nodeType folderOpen
, chevronIcon isLeaf handed nodeType folderOpen
, nodeLink { frontends
, id
, isSelected: mCurrentRoute
......@@ -123,17 +126,20 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, handed, session } = R.createEl
then show session
else name
chevronIcon handed' nodeType folderOpen'@(open /\ _) =
H.a { className: "chevron-icon"
, onClick: R2.effToggler folderOpen'
}
[ H.i {
className: if open
then "fa fa-chevron-down"
else if handed' == GT.RightHanded
then "fa fa-chevron-right"
else "fa fa-chevron-left"
} [] ]
chevronIcon isLeaf handed' nodeType folderOpen'@(open /\ _) =
if isLeaf
then
H.a { className: "chevron-icon"
, onClick: R2.effToggler folderOpen'
}
[ H.i {
className: if open
then "fa fa-chevron-down"
else if handed' == GT.RightHanded
then "fa fa-chevron-right"
else "fa fa-chevron-left"
} [] ]
else H.div {} []
folderIcon nodeType folderOpen'@(open /\ _) =
H.a { className: "folder-icon"
......
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