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
c33bf2ad
Commit
c33bf2ad
authored
Oct 05, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Tree Folder with folder design.
parent
ab986e98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
Tree.purs
src/Gargantext/Components/Tree.purs
+17
-8
No files found.
src/Gargantext/Components/Tree.purs
View file @
c33bf2ad
...
@@ -21,7 +21,7 @@ import React.DOM (a, div, i, li, text, ul)
...
@@ -21,7 +21,7 @@ import React.DOM (a, div, i, li, text, ul)
import React.DOM.Props (Props, className, href, onClick)
import React.DOM.Props (Props, className, href, onClick)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Gargantext.Config (NodeType(..), toUrl, readNodeType, End(..), ApiVersion, defaultRoot)
import Gargantext.Config (NodeType(..),
readNodeType,
toUrl, readNodeType, End(..), ApiVersion, defaultRoot)
type Name = String
type Name = String
type Open = Boolean
type Open = Boolean
...
@@ -37,7 +37,7 @@ data Action = ToggleFolder ID --| Initialize
...
@@ -37,7 +37,7 @@ data Action = ToggleFolder ID --| Initialize
type State = FTree
type State = FTree
initialState :: State
initialState :: State
initialState = NTree (LNode {id : 1, name : "", nodeType :
""
, open : true}) []
initialState = NTree (LNode {id : 1, name : "", nodeType :
NodeUser
, open : true}) []
performAction :: PerformAction State {} Action
performAction :: PerformAction State {} Action
performAction (ToggleFolder i) _ _ = void $ modifyState $ toggleNode i
performAction (ToggleFolder i) _ _ = void $ modifyState $ toggleNode i
...
@@ -59,7 +59,7 @@ toggleNode sid (NTree (LNode {id, name, nodeType, open}) ary) =
...
@@ -59,7 +59,7 @@ toggleNode sid (NTree (LNode {id, name, nodeType, open}) ary) =
-- Realistic Tree for the UI
-- Realistic Tree for the UI
exampleTree :: NTree LNode
exampleTree :: NTree LNode
exampleTree = NTree (LNode {id : 1, name : "", nodeType :
""
, open : false}) []
exampleTree = NTree (LNode {id : 1, name : "", nodeType :
NodeUser
, open : false}) []
-- exampleTree :: NTree LNode
-- exampleTree :: NTree LNode
-- exampleTree =
-- exampleTree =
...
@@ -110,12 +110,21 @@ treeview = simpleSpec performAction render
...
@@ -110,12 +110,21 @@ treeview = simpleSpec performAction render
toHtml :: (Action -> Effect Unit) -> FTree -> ReactElement
toHtml :: (Action -> Effect Unit) -> FTree -> ReactElement
toHtml d (NTree (LNode {id, name, nodeType, open}) []) =
toHtml d (NTree (LNode {id, name, nodeType : Folder, open}) []) =
ul [ ]
[ li [] $
( [ a [onClick $ (\e-> d $ ToggleFolder id)] [i [fldr open] []]
, a [ href (toUrl Front Folder id )]
[ text $ " " <> name <> " " ]
] <> nodeOptionsCorp false
)
]
toHtml d (NTree (LNode {id, name, nodeType : nodeType, open}) []) =
ul []
ul []
[
[
li []
li []
[
[
a [ href (toUrl Front
(readNodeType nodeType)
id)]
a [ href (toUrl Front
nodeType
id)]
( [ text (name <> " ")
( [ text (name <> " ")
] <> nodeOptionsView false
] <> nodeOptionsView false
)
)
...
@@ -125,7 +134,7 @@ toHtml d (NTree (LNode {id, name, nodeType, open}) ary) =
...
@@ -125,7 +134,7 @@ toHtml d (NTree (LNode {id, name, nodeType, open}) ary) =
ul [ ]
ul [ ]
[ li [] $
[ li [] $
( [ a [onClick $ (\e-> d $ ToggleFolder id)] [i [fldr open] []]
( [ a [onClick $ (\e-> d $ ToggleFolder id)] [i [fldr open] []]
, a [ href (toUrl Front
(readNodeType nodeType)
id )]
, a [ href (toUrl Front
nodeType
id )]
[ text $ " " <> name <> " " ]
[ text $ " " <> name <> " " ]
] <> nodeOptionsCorp false <>
] <> nodeOptionsCorp false <>
if open then
if open then
...
@@ -138,7 +147,7 @@ fldr :: Boolean -> Props
...
@@ -138,7 +147,7 @@ fldr :: Boolean -> Props
fldr open = if open then className "fas fa-folder-open" else className "fas fa-folder"
fldr open = if open then className "fas fa-folder-open" else className "fas fa-folder"
newtype LNode = LNode {id :: Int, name :: String, nodeType ::
String
, open :: Boolean}
newtype LNode = LNode {id :: Int, name :: String, nodeType ::
NodeType
, open :: Boolean}
derive instance newtypeLNode :: Newtype LNode _
derive instance newtypeLNode :: Newtype LNode _
...
@@ -147,7 +156,7 @@ instance decodeJsonLNode :: DecodeJson LNode where
...
@@ -147,7 +156,7 @@ instance decodeJsonLNode :: DecodeJson LNode where
obj <- decodeJson json
obj <- decodeJson json
id_ <- obj .? "id"
id_ <- obj .? "id"
name <- obj .? "name"
name <- obj .? "name"
nodeType <- obj .? "type"
nodeType <-
readNodeType <$>
obj .? "type"
pure $ LNode {id : id_, name, nodeType, open : true}
pure $ LNode {id : id_, name, nodeType, open : true}
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
...
...
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