Commit eae47cff authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] SubTree (WIP).

parent deb1a1b9
...@@ -13,7 +13,7 @@ import Gargantext.Components.Forest.Tree.Node (nodeMainSpan) ...@@ -13,7 +13,7 @@ import Gargantext.Components.Forest.Tree.Node (nodeMainSpan)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode) import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode) import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNode) import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename) import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share) import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share)
import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest) import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest)
...@@ -306,7 +306,7 @@ performAction DownloadNode _ = do ...@@ -306,7 +306,7 @@ performAction DownloadNode _ = do
liftEffect $ log "[performAction] DownloadNode" liftEffect $ log "[performAction] DownloadNode"
------- -------
performAction (MoveNode n1 n2) p@{session} = do performAction (MoveNode n1 n2) p@{session} = do
void $ moveNode session n1 n2 void $ moveNodeReq session n1 n2
performAction RefreshTree p performAction RefreshTree p
------- -------
performAction RefreshTree { reload: (_ /\ setReload) } = do performAction RefreshTree { reload: (_ /\ setReload) } = do
......
...@@ -15,13 +15,15 @@ import Data.Generic.Rep.Show (genericShow) ...@@ -15,13 +15,15 @@ import Data.Generic.Rep.Show (genericShow)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Reactix as R import Reactix as R
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel) import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsProps, subTreeView)
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
moveNode :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID) -- TODO moveNodeReq
moveNode session fromId toId= moveNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId) put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId)
moveNode :: Record SubTreeParamsProps -> R.Hooks R.Element
moveNode p = do
pure $ subTreeView p
...@@ -21,10 +21,11 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (default ...@@ -21,10 +21,11 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (default
import Gargantext.Components.Forest.Tree.Node.Action.Share as Share import Gargantext.Components.Forest.Tree.Node.Action.Share as Share
import Gargantext.Components.Forest.Tree.Node.Action.Update (update) import Gargantext.Components.Forest.Tree.Node.Action.Update (update)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (actionUpload) import Gargantext.Components.Forest.Tree.Node.Action.Upload (actionUpload)
import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNode)
import Gargantext.Components.Forest.Tree.Node.Box.Types (NodePopupProps, NodePopupS) import Gargantext.Components.Forest.Tree.Node.Box.Types (NodePopupProps, NodePopupS)
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox) import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
import Gargantext.Components.Forest.Tree.Node.Tools (textInputBox, fragmentPT) import Gargantext.Components.Forest.Tree.Node.Tools (textInputBox, fragmentPT)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTreeOut)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (Name, ID) import Gargantext.Types (Name, ID)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -247,13 +248,16 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt ...@@ -247,13 +248,16 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
----------- -----------
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams} subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session} _ = do cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams} subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
moveNode {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
cpt {action: Link {subTreeParams}, dispatch, id, nodeType, session} _ = do cpt {action: Link {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams} subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
----------- -----------
cpt {action : Share, dispatch, id, name } _ = do cpt {action : Share, dispatch, id, name } _ = do
......
...@@ -37,7 +37,7 @@ data SubTreeParams = SubTreeParams { showtypes :: Array NodeType ...@@ -37,7 +37,7 @@ data SubTreeParams = SubTreeParams { showtypes :: Array NodeType
derive instance eqSubTreeParams :: Eq SubTreeParams derive instance eqSubTreeParams :: Eq SubTreeParams
derive instance genericSubTreeParams :: Generic SubTreeParams _ derive instance genericSubTreeParams :: Generic SubTreeParams _
instance showSubTreeParams :: Show SubTreeParams where instance showSubTreeParams :: Show SubTreeParams where
show = genericShow show = genericShow
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
...@@ -19,9 +19,13 @@ import Reactix as R ...@@ -19,9 +19,13 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
data SubTreeOut = SubTreeOut { in :: GT.ID
, out :: GT.ID
}
------------------------------------------------------------------------ ------------------------------------------------------------------------
type SubTreeParamsProps = type SubTreeParamsProps =
( subTreeParams :: SubTreeParams ( subTreeParams :: SubTreeParams
, subTreeOut :: R.State (Maybe SubTreeOut)
| Props | Props
) )
...@@ -32,23 +36,25 @@ subTreeViewCpt :: R.Component SubTreeParamsProps ...@@ -32,23 +36,25 @@ subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeView" cpt subTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeView" cpt
where where
cpt params@{ dispatch cpt params@{ dispatch
, id , id
, nodeType , nodeType
, session , session
, subTreeParams , subTreeParams
} _ = , subTreeOut
} _ =
do do
let SubTreeParams {showtypes} = subTreeParams let SubTreeParams {showtypes} = subTreeParams
useLoader session (loadSubTree showtypes) $ useLoader session (loadSubTree showtypes) $
\tree -> \tree ->
subTreeViewLoaded { dispatch subTreeViewLoaded { dispatch
, id , id
, nodeType , nodeType
, session , session
, tree , tree
, subTreeParams , subTreeParams
} , subTreeOut
}
loadSubTree :: Array GT.NodeType -> Session -> Aff FTree loadSubTree :: Array GT.NodeType -> Session -> Aff FTree
loadSubTree nodetypes session = getSubTree session treeId nodetypes loadSubTree nodetypes session = getSubTree session treeId nodetypes
...@@ -116,8 +122,8 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt ...@@ -116,8 +122,8 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
$ \_ -> case validNodeType of $ \_ -> case validNodeType of
false -> launchAff $ dispatch NoAction false -> launchAff $ dispatch NoAction
true -> do true -> do
log2 "[subTreeTreeViewCpt] from" sourceId log2 "[subTreeTreeViewCpt] from" id
log2 "[subTreeTreeViewCpt] to" id log2 "[subTreeTreeViewCpt] to" sourceId
launchAff $ dispatch (MoveNode id sourceId) launchAff $ dispatch (MoveNode id sourceId)
-------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------
......
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