Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
787a9d22
Commit
787a9d22
authored
Jun 25, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] state must be declared inside the component
parent
453c69ed
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
54 deletions
+69
-54
Link.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Link.purs
+18
-15
Merge.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Merge.purs
+19
-16
Move.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
+19
-11
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+3
-7
SubTree.purs
...Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
+10
-5
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Link.purs
View file @
787a9d22
module Gargantext.Components.Forest.Tree.Node.Action.Link
module Gargantext.Components.Forest.Tree.Node.Action.Link
where
where
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
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 (SubTreeParams
Props
, subTreeView, SubTreeOut(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParams
In
, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
...
@@ -23,13 +18,21 @@ linkNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
...
@@ -23,13 +18,21 @@ linkNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
linkNodeReq session fromId toId =
linkNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("link/" <> show toId)
put_ session $ NodeAPI GT.Node (Just fromId) ("link/" <> show toId)
linkNode :: Record SubTreeParamsProps -> R.Hooks R.Element
linkNode :: Record SubTreeParamsIn -> R.Hooks R.Element
linkNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
linkNode p@{dispatch, subTreeParams, id, nodeType, session} = do
where
subTreeOut@(subTreeOutParams /\ setSubTreeOut) :: R.State (Maybe SubTreeOut)
( subTreeOutParams /\ _ ) = subTreeOut
<- R.useState' Nothing
button = case subTreeOutParams of
let button = case subTreeOutParams of
Nothing -> H.div {} []
Nothing -> H.div {} []
Just sbto -> submitButton (LinkNode inId outId) dispatch
Just sbto -> submitButton (LinkNode inId outId) dispatch
where
where
(SubTreeOut { in:inId, out:outId}) = sbto
(SubTreeOut { in:inId, out:outId}) = sbto
pure $ panel [ subTreeView { subTreeOut
, dispatch
, subTreeParams
, id
, nodeType
, session
}
] button
src/Gargantext/Components/Forest/Tree/Node/Action/Merge.purs
View file @
787a9d22
module Gargantext.Components.Forest.Tree.Node.Action.Merge
module Gargantext.Components.Forest.Tree.Node.Action.Merge
where
where
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
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 Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsIn, subTreeView, SubTreeOut(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsProps, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
mergeNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
mergeNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
mergeNodeReq session fromId toId =
mergeNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("merge/" <> show toId)
put_ session $ NodeAPI GT.Node (Just fromId) ("merge/" <> show toId)
mergeNode :: Record SubTreeParamsProps -> R.Hooks R.Element
mergeNode :: Record SubTreeParamsIn -> R.Hooks R.Element
mergeNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
mergeNode p@{dispatch, subTreeParams, id, nodeType, session} = do
where
subTreeOut@(subTreeOutParams /\ setSubTreeOut) :: R.State (Maybe SubTreeOut)
( subTreeOutParams /\ _ ) = subTreeOut
<- R.useState' Nothing
button = case subTreeOutParams of
let button = case subTreeOutParams of
Nothing -> H.div {} []
Nothing -> H.div {} []
Just sbto -> submitButton (MergeNode inId outId) dispatch
Just sbto -> submitButton (MergeNode inId outId) dispatch
where
where
(SubTreeOut { in:inId, out:outId}) = sbto
(SubTreeOut { in:inId, out:outId}) = sbto
pure $ panel [ subTreeView { subTreeOut
, dispatch
, subTreeParams
, id
, nodeType
, session
}
] button
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
View file @
787a9d22
...
@@ -4,9 +4,9 @@ module Gargantext.Components.Forest.Tree.Node.Action.Move
...
@@ -4,9 +4,9 @@ module Gargantext.Components.Forest.Tree.Node.Action.Move
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action (
Props,
Action(..))
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 (SubTreeParams
Props
, subTreeView, SubTreeOut(..))
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParams
In
, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Sessions (Session, put_)
...
@@ -18,13 +18,21 @@ moveNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
...
@@ -18,13 +18,21 @@ moveNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNodeReq session fromId toId =
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 :: Record SubTreeParamsIn -> R.Hooks R.Element
moveNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
moveNode p@{dispatch, subTreeParams, id, nodeType, session} = do
where
subTreeOut@(subTreeOutParams /\ setSubTreeOut) :: R.State (Maybe SubTreeOut)
( subTreeOutParams /\ _ ) = subTreeOut
<- R.useState' Nothing
button = case subTreeOutParams of
let button = case subTreeOutParams of
Nothing -> H.div {} []
Nothing -> H.div {} []
Just sbto -> submitButton (MoveNode inId outId) dispatch
Just sbto -> submitButton (MoveNode inId outId) dispatch
where
where
(SubTreeOut { in:inId, out:outId}) = sbto
(SubTreeOut { in:inId, out:outId}) = sbto
pure $ panel [ subTreeView { subTreeOut
, dispatch
, subTreeParams
, id
, nodeType
, session
}
] button
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
787a9d22
...
@@ -27,7 +27,6 @@ import Gargantext.Components.Forest.Tree.Node.Action.Merge (mergeNode)
...
@@ -27,7 +27,6 @@ import Gargantext.Components.Forest.Tree.Node.Action.Merge (mergeNode)
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 (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
...
@@ -251,16 +250,13 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
...
@@ -251,16 +250,13 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
-----------
-----------
-- Functions using SubTree
-- Functions using SubTree
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do
subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
mergeNode {dispatch, id, nodeType, session, subTreeParams}
mergeNode {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session} _ = do
cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session} _ = do
subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
moveNode {dispatch, id, nodeType, session, subTreeParams}
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
subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
linkNode {dispatch, id, nodeType, session, subTreeParams}
linkNode {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
-----------
-----------
cpt {action : Share, dispatch, id, name } _ = do
cpt {action : Share, dispatch, id, name } _ = do
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
View file @
787a9d22
...
@@ -20,14 +20,19 @@ import Reactix as R
...
@@ -20,14 +20,19 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
type SubTreeParamsIn =
( subTreeParams :: SubTreeParams
| Props
)
------------------------------------------------------------------------
data SubTreeOut = SubTreeOut { in :: GT.ID
data SubTreeOut = SubTreeOut { in :: GT.ID
, out :: GT.ID
, out :: GT.ID
}
}
------------------------------------------------------------------------
------------------------------------------------------------------------
type SubTreeParamsProps =
type SubTreeParamsProps =
( subTreeParams :: SubTreeParams
( subTreeOut :: R.State (Maybe SubTreeOut)
, subTreeOut :: R.State (Maybe SubTreeOut)
| SubTreeParamsIn
| Props
)
)
subTreeView :: Record SubTreeParamsProps -> R.Element
subTreeView :: Record SubTreeParamsProps -> R.Element
...
@@ -69,7 +74,7 @@ getSubTree session treeId showtypes = get session $ GR.NodeAPI GT.Tree (Just tre
...
@@ -69,7 +74,7 @@ getSubTree session treeId showtypes = get session $ GR.NodeAPI GT.Tree (Just tre
------------------------------------------------------------------------
------------------------------------------------------------------------
type CorpusTreeProps =
type CorpusTreeProps =
( tree :: FTree
( tree
:: FTree
| SubTreeParamsProps
| SubTreeParamsProps
)
)
...
@@ -123,6 +128,6 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
...
@@ -123,6 +128,6 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
onClick _ = mkEffectFn1 $ \_ -> case validNodeType of
onClick _ = mkEffectFn1 $ \_ -> case validNodeType of
false -> setSubTreeOut (const Nothing)
false -> setSubTreeOut (const Nothing)
true -> setSubTreeOut (const $ Just $ SubTreeOut { in: id, out:sourceId})
true -> setSubTreeOut (const $ Just $ SubTreeOut { in: id, out:sourceId})
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment