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
7
Merge Requests
7
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
4b367cb2
Commit
4b367cb2
authored
Jun 24, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-refact' into dev
parents
976e1511
461ebdf9
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
159 additions
and
52 deletions
+159
-52
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+15
-2
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+9
-0
Link.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Link.purs
+35
-0
Merge.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Merge.purs
+36
-0
Move.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
+18
-15
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+18
-10
Settings.purs
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
+3
-4
SubTree.purs
...Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
+25
-21
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
4b367cb2
...
...
@@ -13,7 +13,9 @@ 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.Move (moveNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Merge (mergeNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Link (linkNodeReq)
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)
...
...
@@ -306,8 +308,19 @@ performAction DownloadNode _ = do
liftEffect $ log "[performAction] DownloadNode"
-------
performAction (MoveNode n1 n2) p@{session} = do
void
$ moveNode
session n1 n2
void
$ moveNodeReq
session n1 n2
performAction RefreshTree p
performAction (MergeNode n1 n2) p@{session} = do
void $ mergeNodeReq session n1 n2
performAction RefreshTree p
performAction (LinkNode n1 n2) p@{session} = do
void $ linkNodeReq session n1 n2
performAction RefreshTree p
-------
performAction RefreshTree { reload: (_ /\ setReload) } = do
liftEffect $ setReload (_ + 1)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
4b367cb2
...
...
@@ -29,6 +29,8 @@ data Action = AddNode String GT.NodeType
| DownloadNode
| RefreshTree
| MoveNode GT.NodeID GT.NodeID
| MergeNode GT.NodeID GT.NodeID
| LinkNode GT.NodeID GT.NodeID
| NoAction
instance showShow :: Show Action where
...
...
@@ -42,6 +44,8 @@ instance showShow :: Show Action where
show RefreshTree = "RefreshTree"
show DownloadNode = "Download"
show (MoveNode _ _) = "MoveNode"
show (MergeNode _ _) = "MergeNode"
show (LinkNode _ _) = "LinkNode"
show NoAction = "NoAction"
type Props =
...
...
@@ -62,6 +66,9 @@ icon (UploadFile _ _ _ _) = glyphiconNodeAction Upload
icon RefreshTree = glyphiconNodeAction Refresh
icon DownloadNode = glyphiconNodeAction Download
icon (MoveNode _ _) = glyphiconNodeAction (Move { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon (MergeNode _ _) = glyphiconNodeAction (Merge { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon (LinkNode _ _) = glyphiconNodeAction (Link { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon NoAction = "hand-o-right"
-- icon _ = "hand-o-right"
...
...
@@ -77,5 +84,7 @@ text (UploadFile _ _ _ _)= "Upload File !"
text RefreshTree = "Refresh Tree !"
text DownloadNode = "Download !"
text (MoveNode _ _ ) = "Move !"
text (MergeNode _ _ ) = "Merge !"
text (LinkNode _ _ ) = "Link !"
text NoAction = "No Action"
-----------------------------------------------------------------------
src/Gargantext/Components/Forest/Tree/Node/Action/Link.purs
0 → 100644
View file @
4b367cb2
module Gargantext.Components.Forest.Tree.Node.Action.Link
where
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsProps, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Reactix as R
import Reactix.DOM.HTML as H
linkNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
linkNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("link/" <> show toId)
linkNode :: Record SubTreeParamsProps -> R.Hooks R.Element
linkNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
where
( subTreeOutParams /\ _ ) = subTreeOut
button = case subTreeOutParams of
Nothing -> H.div {} []
Just sbto -> submitButton (LinkNode inId outId) dispatch
where
(SubTreeOut { in:inId, out:outId}) = sbto
src/Gargantext/Components/Forest/Tree/Node/Action/Merge.purs
0 → 100644
View file @
4b367cb2
module Gargantext.Components.Forest.Tree.Node.Action.Merge
where
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
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 (SubTreeParamsProps, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Reactix as R
import Reactix.DOM.HTML as H
mergeNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
mergeNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("merge/" <> show toId)
mergeNode :: Record SubTreeParamsProps -> R.Hooks R.Element
mergeNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
where
( subTreeOutParams /\ _ ) = subTreeOut
button = case subTreeOutParams of
Nothing -> H.div {} []
Just sbto -> submitButton (MergeNode inId outId) dispatch
where
(SubTreeOut { in:inId, out:outId}) = sbto
src/Gargantext/Components/Forest/Tree/Node/Action/Move.purs
View file @
4b367cb2
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 Data.Tuple.Nested ((/\))
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 Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsProps, subTreeView, SubTreeOut(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT
import Reactix as R
import Reactix.DOM.HTML as H
moveNode :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNode
session fromId toId
=
moveNode
Req
:: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNode
Req session fromId toId
=
put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId)
moveNode :: Record SubTreeParamsProps -> R.Hooks R.Element
moveNode p@{subTreeOut, dispatch} = pure $ panel [subTreeView p] button
where
( subTreeOutParams /\ _ ) = subTreeOut
button = case subTreeOutParams of
Nothing -> H.div {} []
Just sbto -> submitButton (MoveNode inId outId) dispatch
where
(SubTreeOut { in:inId, out:outId}) = sbto
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
4b367cb2
...
...
@@ -21,10 +21,13 @@ 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.Update (update)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (actionUpload)
import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNode)
import Gargantext.Components.Forest.Tree.Node.Action.Link (linkNode)
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.Settings (NodeAction(..), SettingsBox(..), glyphiconNodeAction, settingsBox)
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 (
SubTreeOut
)
import Gargantext.Sessions (Session)
import Gargantext.Types (Name, ID)
import Gargantext.Types as GT
...
...
@@ -246,25 +249,30 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
pure $ fragmentPT $ "Config " <> show nodeType
-----------
-- Functions using SubTree
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session} _ = do
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams}
subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
mergeNode {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
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
pure $ subTreeView {dispatch, id, nodeType, session, subTreeParams}
subTreeOut :: R.State (Maybe SubTreeOut) <- R.useState' Nothing
linkNode {dispatch, id, nodeType, session, subTreeParams, subTreeOut}
-----------
cpt {action : Share, dispatch, id, name } _ = do
isOpen <- R.useState' true
pure $ H.div {} [ textInputBox { boxAction: Share.shareAction
, boxName: "Share"
, dispatch
, id
, text: "username"
, isOpen
} ]
, boxName: "Share"
, dispatch
, id
, text: "username"
, isOpen
}
]
cpt props@{action: SearchBox, id, session, dispatch, nodePopup} _ =
actionSearch session (Just id) dispatch nodePopup
...
...
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
View file @
4b367cb2
...
...
@@ -37,7 +37,7 @@ data SubTreeParams = SubTreeParams { showtypes :: Array NodeType
derive instance eqSubTreeParams :: Eq SubTreeParams
derive instance genericSubTreeParams :: Generic SubTreeParams _
instance showSubTreeParams :: Show SubTreeParams where
instance showSubTreeParams
:: Show SubTreeParams where
show = genericShow
------------------------------------------------------------------------
...
...
@@ -261,9 +261,8 @@ moveParameters = { subTreeParams : SubTreeParams
, Folder
]
, valitypes: [ FolderPrivate
, FolderShared
, Team
, FolderPublic
, Team
-- , FolderPublic
, Folder
]
}
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools/SubTree.purs
View file @
4b367cb2
...
...
@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node.Tools.SubTree where
import DOM.Simple.Console (log2)
import Data.Array as A
import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Eq (genericEq)
import Effect.Uncurried (mkEffectFn1)
...
...
@@ -11,7 +12,7 @@ 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)
import Gargantext.Prelude (discard, map, pure, show, unit, ($), (&&), (/=), (<>), class Eq)
import Gargantext.Prelude (discard, map, pure, show, unit, ($), (&&), (/=), (<>), class Eq
, const
)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), get)
import Gargantext.Types as GT
...
...
@@ -19,9 +20,13 @@ import Reactix as R
import Reactix.DOM.HTML as H
data SubTreeOut = SubTreeOut { in :: GT.ID
, out :: GT.ID
}
------------------------------------------------------------------------
type SubTreeParamsProps =
( subTreeParams :: SubTreeParams
, subTreeOut :: R.State (Maybe SubTreeOut)
| Props
)
...
...
@@ -32,23 +37,25 @@ subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeView" cpt
where
cpt params@{ dispatch
, id
, nodeType
, session
, subTreeParams
} _ =
, id
, nodeType
, session
, subTreeParams
, subTreeOut
} _ =
do
let SubTreeParams {showtypes} = subTreeParams
useLoader session (loadSubTree showtypes) $
\tree ->
subTreeViewLoaded { dispatch
, id
, nodeType
, session
, tree
, subTreeParams
}
, id
, nodeType
, session
, tree
, subTreeParams
, subTreeOut
}
loadSubTree :: Array GT.NodeType -> Session -> Aff FTree
loadSubTree nodetypes session = getSubTree session treeId nodetypes
...
...
@@ -92,6 +99,7 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
) ary
, subTreeParams
, dispatch
, subTreeOut
} _ = do
pure $ {- H.div {} [ H.h5 { className: GT.fldr nodeType true} []
, -} H.div { className: "node" }
...
...
@@ -111,14 +119,10 @@ subTreeTreeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.subTreeTreeViewCpt" cpt
validNodeType = (A.elem nodeType valitypes) && (id /= sourceId)
clickable = if validNodeType then "clickable" else ""
onClick _ = mkEffectFn1
$ \_ -> case validNodeType of
false -> launchAff $ dispatch NoAction
true -> do
log2 "[subTreeTreeViewCpt] from" sourceId
log2 "[subTreeTreeViewCpt] to" id
launchAff $ dispatch (MoveNode id sourceId)
sbto@( subTreeOutParams /\ setSubTreeOut) = subTreeOut
onClick _ = mkEffectFn1 $ \_ -> case validNodeType of
false -> setSubTreeOut (const Nothing)
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