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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
28af3ffe
Commit
28af3ffe
authored
Jun 23, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] move node in Tree implemented (needs refact and security)
parent
d9a9615c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
9 deletions
+70
-9
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+8
-0
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+10
-1
Move.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
+27
-0
SubTree.purs
...Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
+19
-8
REST.purs
src/Gargantext/Config/REST.purs
+3
-0
Sessions.purs
src/Gargantext/Sessions.purs
+3
-0
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
28af3ffe
...
...
@@ -13,6 +13,7 @@ import Gargantext.Components.Forest.Tree.Node (nodeMainSpan)
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.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNode)
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.Update (updateRequest)
...
...
@@ -304,6 +305,13 @@ performAction (UploadFile nodeType fileType mName contents) { session
performAction DownloadNode _ = do
liftEffect $ log "[performAction] DownloadNode"
-------
performAction (MoveNode n1 n2) p@{session} = do
void $ moveNode session n1 n2
performAction RefreshTree p
-------
performAction RefreshTree { reload: (_ /\ setReload) } = do
liftEffect $ setReload (_ + 1)
-------
performAction NoAction _ = do
liftEffect $ log "[performAction] NoAction"
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
28af3ffe
...
...
@@ -5,7 +5,7 @@ import Effect.Aff (Aff)
import Gargantext.Prelude (class Show, Unit)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), glyphiconNodeAction)
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), glyphiconNodeAction
, SubTreeParams(..)
)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType, UploadFileContents)
import Gargantext.Components.Forest.Tree.Node.Action.Update.Types (UpdateNodeParams)
...
...
@@ -28,6 +28,8 @@ data Action = AddNode String GT.NodeType
| UploadFile GT.NodeType FileType (Maybe String) UploadFileContents
| DownloadNode
| RefreshTree
| MoveNode GT.NodeID GT.NodeID
| NoAction
instance showShow :: Show Action where
show (AddNode _ _ )= "AddNode"
...
...
@@ -39,6 +41,8 @@ instance showShow :: Show Action where
show (UploadFile _ _ _ _)= "UploadFile"
show RefreshTree = "RefreshTree"
show DownloadNode = "Download"
show (MoveNode _ _) = "MoveNode"
show NoAction = "NoAction"
type Props =
( dispatch :: Action -> Aff Unit
...
...
@@ -57,6 +61,9 @@ icon (DoSearch _) = glyphiconNodeAction SearchBox
icon (UploadFile _ _ _ _) = glyphiconNodeAction Upload
icon RefreshTree = glyphiconNodeAction Refresh
icon DownloadNode = glyphiconNodeAction Download
icon (MoveNode _ _) = glyphiconNodeAction (Move { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon NoAction = "hand-o-right"
-- icon _ = "hand-o-right"
text :: Action -> String
...
...
@@ -69,4 +76,6 @@ text (DoSearch _ )= "Launch search !"
text (UploadFile _ _ _ _)= "Upload File !"
text RefreshTree = "Refresh Tree !"
text DownloadNode = "Download !"
text (MoveNode _ _ ) = "Move !"
text NoAction = "No Action"
-----------------------------------------------------------------------
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
0 → 100644
View file @
28af3ffe
module Gargantext.Components.Forest.Tree.Node.Action.Move
where
import Data.Argonaut as Argonaut
import Data.Maybe (Maybe(..))
import Data.Generic.Rep (class Generic)
import Gargantext.Prelude
import Effect.Aff (Aff)
import Gargantext.Types as GT
import Gargantext.Sessions (Session, put_)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Data.Generic.Rep.Show (genericShow)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Reactix as R
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Reactix.DOM.HTML as H
moveNode :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNode session fromId toId=
put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId)
src/Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
View file @
28af3ffe
...
...
@@ -5,8 +5,9 @@ import Data.Array as A
import Data.Maybe (Maybe(..))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Props)
import Effect.Uncurried (mkEffectFn1)
import Effect.Aff (Aff, launchAff)
import Gargantext.Components.Forest.Tree.Node.Action (Props, Action(..))
import Gargantext.Components.Forest.Tree.Node.Settings (SubTreeParams(..))
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
import Gargantext.Hooks.Loader (useLoader)
...
...
@@ -83,7 +84,15 @@ subTreeTreeView props = R.createElement subTreeTreeViewCpt props []
subTreeTreeViewCpt :: R.Component CorpusTreeProps
subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
where
cpt p@{id, tree: NTree (LNode { id: sourceId, name, nodeType }) ary, subTreeParams} _ = do
cpt p@{ id
, tree: NTree (LNode { id: sourceId
, name
, nodeType
}
) ary
, subTreeParams
, dispatch
} _ = do
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
, -} H.div { className: "node" }
( [ H.span { className: "name " <> clickable
...
...
@@ -103,11 +112,13 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
clickable = if validNodeType then "clickable" else ""
onClick _ = case validNodeType of
false -> pure unit
onClick _ = mkEffectFn1
$ \_ -> case validNodeType of
false -> launchAff $ dispatch NoAction
true -> do
log2 "[subTreeTreeViewCpt] issue copy into" id
log2 "[subTreeTreeViewCpt] issue copy from" sourceId
log2 "[subTreeTreeViewCpt] from" sourceId
log2 "[subTreeTreeViewCpt] to" id
launchAff $ dispatch (MoveNode id sourceId)
--------------------------------------------------------------------------------------------
src/Gargantext/Config/REST.purs
View file @
28af3ffe
...
...
@@ -64,6 +64,9 @@ get mtoken url = send GET mtoken url noReqBody
put :: forall a b. EncodeJson a => DecodeJson b => Maybe Token -> String -> a -> Aff b
put mtoken url = send PUT mtoken url <<< Just
put_ :: forall a. DecodeJson a => Maybe Token -> String -> Aff a
put_ mtoken url = send PUT mtoken url noReqBody
delete :: forall a. DecodeJson a => Maybe Token -> String -> Aff a
delete mtoken url = send DELETE mtoken url noReqBody
...
...
src/Gargantext/Sessions.purs
View file @
28af3ffe
...
...
@@ -223,6 +223,9 @@ get session@(Session {token}) p = REST.get (Just token) (toUrl session p)
put :: forall a b p. EncodeJson a => DecodeJson b => ToUrl Session p => Session -> p -> a -> Aff b
put session@(Session {token}) p = REST.put (Just token) (toUrl session p)
put_ :: forall a b p. DecodeJson b => ToUrl Session p => Session -> p -> Aff b
put_ session@(Session {token}) p = REST.put_ (Just token) (toUrl session p)
delete :: forall a p. DecodeJson a => ToUrl Session p => Session -> p -> Aff a
delete session@(Session {token}) p = REST.delete (Just token) (toUrl session p)
...
...
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