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
152
Issues
152
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
819c2803
Commit
819c2803
authored
Jun 06, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: draft changes for choosing backend connection on top of tree
parent
f5c6e917
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
Tree.purs
src/Gargantext/Components/Tree.purs
+15
-14
No files found.
src/Gargantext/Components/Tree.purs
View file @
819c2803
...
...
@@ -27,7 +27,7 @@ import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, pl
import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction, defaultRender, modifyState_, simpleSpec, modifyState)
import Gargantext.Config (toUrl, End(..), NodeType(..))
import Gargantext.Config (
EndConfig, endConfig,
toUrl, End(..), NodeType(..))
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
import Gargantext.Components.Loader as Loader
...
...
@@ -64,16 +64,19 @@ data Action = ShowPopOver ID
| CurrentNode ID
type State = { state :: FTree
type State = { state :: FTree
, currentNode :: Maybe Int
, endConfig :: EndConfig
}
-- TODO remove
initialState :: State
initialState = { state: NTree (LNode {id : 3, name : "hello", nodeType : Node, open : true, popOver : false, renameNodeValue : "", createNode : false, nodeValue : "InitialNode", showRenameBox : false}) [] , currentNode : Nothing}
initialState = { state: NTree (LNode {id : 3, name : "hello", nodeType : Node, open : true, popOver : false, renameNodeValue : "", createNode : false, nodeValue : "InitialNode", showRenameBox : false}) []
, currentNode : Nothing
, endConfig: endConfig}
mapFTree :: (FTree -> FTree) -> State -> State
mapFTree f {state, currentNode
} = {state: f state, currentNode: currentNode
}
mapFTree f {state, currentNode
, endConfig} = {state: f state, currentNode: currentNode, endConfig: endConfig
}
-- TODO: make it a local function
performAction :: forall props. PerformAction State props Action
...
...
@@ -112,7 +115,7 @@ performAction (SetNodeValue v nid) _ _ =
modifyState_ $ mapFTree $ setNodeValue nid v
performAction (CurrentNode nid) _ _ =
modifyState_ $ \{state: s
} -> {state: s, currentNode : Just nid
}
modifyState_ $ \{state: s
, endConfig: ec} -> {state: s, currentNode : Just nid, endConfig: ec
}
toggleIf :: Boolean -> Boolean -> Boolean
...
...
@@ -232,15 +235,13 @@ loadedTreeview :: Spec State LoadedTreeViewProps Action
loadedTreeview = simpleSpec performAction render
where
render :: Render State LoadedTreeViewProps Action
render dispatch _ {state, currentNode} _ =
render dispatch _ {state, currentNode
, endConfig
} _ =
[ div [className "tree"]
[ toHtml dispatch state currentNode
]
[ toHtml dispatch state currentNode endConfig ]
]
treeViewClass :: ReactClass (Loader.InnerProps Int FTree (children :: React.Children))
treeViewClass = createClass "TreeView" loadedTreeview (\{loaded: t} -> {state: t, currentNode: Nothing})
treeViewClass = createClass "TreeView" loadedTreeview (\{loaded: t} -> {state: t, currentNode: Nothing
, endConfig: endConfig
})
treeLoaderClass :: Loader.LoaderClass Int FTree
treeLoaderClass = Loader.createLoaderClass "TreeLoader" loadNode
...
...
@@ -358,8 +359,8 @@ getCreateNodeValue :: FTree -> String
getCreateNodeValue (NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, nodeValue, showRenameBox}) ary) = nodeValue
toHtml :: (Action -> Effect Unit) -> FTree -> Maybe Int -> ReactElement
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, createNode,nodeValue, showRenameBox }) []) n =
toHtml :: (Action -> Effect Unit) -> FTree -> Maybe Int ->
EndConfig ->
ReactElement
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, createNode,nodeValue, showRenameBox }) []) n
ec
=
ul []
[
li [] $
...
...
@@ -373,7 +374,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, cr
]
]
--- need to add renameTreeview value to this function
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,createNode, nodeValue, showRenameBox}) ary) n=
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,createNode, nodeValue, showRenameBox}) ary) n
ec
=
ul []
[ li [] $
( [ a [onClick $ (\e-> d $ ToggleFolder id)] [i [fldr open] []]
...
...
@@ -390,7 +391,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,cre
] <>
if open then
map (\s -> toHtml d s n) ary
map (\s -> toHtml d s n
ec
) ary
else []
)
]
...
...
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