Commit c6497f31 authored by arturo's avatar arturo

[subtree] Fold subtree node by default

* #308 (2): resolve re-render issue
parent e4531010
module Gargantext.Components.Forest.Tree.Node.Action.Move where
module Gargantext.Components.Forest.Tree.Node.Action.Move
( moveNodeReq
, moveNode
) where
import Data.Either (Either)
import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTreeParamsIn)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsIn, subTreeView)
import Gargantext.Config.REST (RESTError)
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
......@@ -30,22 +33,47 @@ moveNodeCpt = here.component "moveNode" cpt
where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do
action :: T.Box Action <- T.useBox (MoveNode {params: Nothing})
action' <- T.useLive T.unequal action
let button = case action' of
MoveNode { params } -> case params of
Just val -> submitButton (MoveNode {params: Just val}) dispatch
Nothing -> H.div {} []
_ -> H.div {} []
pure $
panel [ subTreeView { action
, boxes
, dispatch
, id
, nodeType
, session
, subTreeParams
} []
] button
moveNode' { action
, boxes
, dispatch
, id
, nodeType
, session
, subTreeParams
} []
type Props =
( action :: T.Box Action
| SubTreeParamsIn
)
-- @XXX re-render issue -> clone component
moveNode' :: R2.Component Props
moveNode' = R.createElement moveNodeCpt'
moveNodeCpt' :: R.Component Props
moveNodeCpt' = here.component "foo" cpt where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams, action } _ = do
action' <- T.useLive T.unequal action
let button = case action' of
MoveNode { params } -> case params of
Just val -> submitButton (MoveNode {params: Just val}) dispatch
Nothing -> H.div {} []
_ -> H.div {} []
pure $
panel
[ subTreeView { action
, boxes
, dispatch
, id
, nodeType
, session
, subTreeParams
} []
] button
......@@ -44,7 +44,7 @@ type SubTreeParamsProps =
)
subTreeView :: R2.Component SubTreeParamsProps
subTreeView = R.createElement subTreeViewCpt
subTreeView = R.createElement $ R.memo' subTreeViewCpt
subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = here.component "subTreeView" cpt
where
......
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