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
154
Issues
154
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
7a496fda
Commit
7a496fda
authored
Nov 27, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FOREST][WIP] folder memory to be open or closed
parent
f182c3f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+7
-6
Action.purs
src/Gargantext/Components/Forest/Tree/Node/Action.purs
+7
-3
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+2
-1
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
7a496fda
module Gargantext.Components.Forest.Tree where
module Gargantext.Components.Forest.Tree where
import Prelude ((||))
import DOM.Simple.Console (log2)
import DOM.Simple.Console (log2)
import Data.Maybe (Maybe)
import Data.Maybe (Maybe
(..)
)
-- import Data.Newtype (class Newtype)
-- import Data.Newtype (class Newtype)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
...
@@ -66,19 +67,19 @@ toHtml :: R.State Reload
...
@@ -66,19 +67,19 @@ toHtml :: R.State Reload
-> Frontends
-> Frontends
-> Maybe AppRoute
-> Maybe AppRoute
-> R.Element
-> R.Element
toHtml reload treeState@({tree: (NTree (LNode {id, name, nodeType}) ary)} /\ _) session frontends mCurrentRoute = R.createElement el {} []
toHtml reload treeState@({tree: (NTree (LNode {id, name, nodeType
, open
}) ary)} /\ _) session frontends mCurrentRoute = R.createElement el {} []
where
where
el = R.hooksComponent "NodeView" cpt
el = R.hooksComponent "NodeView" cpt
pAction = performAction session reload treeState
pAction = performAction session reload treeState
cpt props _ = do
cpt props _ = do
folderOpen
<- R.useState' tru
e
folderOpen
@(o /\ _) <- R.useState' fals
e
let open' = o || open
let withId (NTree (LNode {id: id'}) _) = id'
let withId (NTree (LNode {id: id'
, open:open'
}) _) = id'
pure $ H.ul {}
pure $ H.ul {}
[ H.li {}
[ H.li {}
( [ nodeMainSpan pAction {id, name, nodeType, mCurrentRoute} folderOpen session frontends ]
( [ nodeMainSpan pAction {id, name, nodeType, mCurrentRoute
, open:open'
} folderOpen session frontends ]
<> childNodes session frontends reload folderOpen mCurrentRoute ary
<> childNodes session frontends reload folderOpen mCurrentRoute ary
)
)
]
]
...
...
src/Gargantext/Components/Forest/Tree/Node/Action.purs
View file @
7a496fda
...
@@ -11,6 +11,7 @@ import Gargantext.Routes (SessionRoute(..))
...
@@ -11,6 +11,7 @@ import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Types (NodeType(..))
import Gargantext.Types (NodeType(..))
import Prelude hiding (div)
import Prelude hiding (div)
import Reactix as R
data Action = Submit String
data Action = Submit String
| DeleteNode
| DeleteNode
...
@@ -91,9 +92,10 @@ instance ntreeFunctor :: Functor NTree where
...
@@ -91,9 +92,10 @@ instance ntreeFunctor :: Functor NTree where
map f (NTree x ary) = NTree (f x) (map (map f) ary)
map f (NTree x ary) = NTree (f x) (map (map f) ary)
newtype LNode = LNode { id :: ID
newtype LNode = LNode { id
:: ID
, name :: Name
, name
:: Name
, nodeType :: NodeType
, nodeType :: NodeType
, open :: Maybe (R.State Boolean)
}
}
derive instance newtypeLNode :: Newtype LNode _
derive instance newtypeLNode :: Newtype LNode _
...
@@ -106,7 +108,9 @@ instance decodeJsonLNode :: DecodeJson LNode where
...
@@ -106,7 +108,9 @@ instance decodeJsonLNode :: DecodeJson LNode where
nodeType <- obj .: "type"
nodeType <- obj .: "type"
pure $ LNode { id : id_
pure $ LNode { id : id_
, name
, name
, nodeType}
, nodeType
, open: Nothing
}
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
decodeJson json = do
decodeJson json = do
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
7a496fda
...
@@ -42,6 +42,7 @@ type NodeMainSpanProps =
...
@@ -42,6 +42,7 @@ type NodeMainSpanProps =
, name :: Name
, name :: Name
, nodeType :: NodeType
, nodeType :: NodeType
, mCurrentRoute :: Maybe AppRoute
, mCurrentRoute :: Maybe AppRoute
, open :: R.State Boolean
)
)
nodeMainSpan :: (Action -> Aff Unit)
nodeMainSpan :: (Action -> Aff Unit)
...
@@ -53,7 +54,7 @@ nodeMainSpan :: (Action -> Aff Unit)
...
@@ -53,7 +54,7 @@ nodeMainSpan :: (Action -> Aff Unit)
nodeMainSpan d p folderOpen session frontends = R.createElement el p []
nodeMainSpan d p folderOpen session frontends = R.createElement el p []
where
where
el = R.hooksComponent "NodeMainSpan" cpt
el = R.hooksComponent "NodeMainSpan" cpt
cpt {id, name, nodeType, mCurrentRoute} _ = do
cpt {id, name, nodeType, mCurrentRoute
, open
} _ = do
-- only 1 popup at a time is allowed to be opened
-- only 1 popup at a time is allowed to be opened
popupOpen <- R.useState' (Nothing :: Maybe NodePopup)
popupOpen <- R.useState' (Nothing :: Maybe NodePopup)
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
...
...
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