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