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
6cdcb538
Commit
6cdcb538
authored
Apr 30, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TREE] selected current node is now underlined and bold.
parent
e390844a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
19 deletions
+31
-19
Tree.purs
src/Gargantext/Components/Tree.purs
+28
-16
Corpus.purs
src/Gargantext/Pages/Corpus.purs
+1
-1
Specs.purs
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
+2
-2
No files found.
src/Gargantext/Components/Tree.purs
View file @
6cdcb538
...
@@ -22,10 +22,10 @@ import Effect.Console (log)
...
@@ -22,10 +22,10 @@ import Effect.Console (log)
import Prelude (identity)
import Prelude (identity)
import React (ReactClass, ReactElement)
import React (ReactClass, ReactElement)
import React as React
import React as React
import React.DOM (a, button, div, h5, i, input, li, span, text, ul)
import React.DOM (a, button, div, h5, i, input, li, span, text, ul
, b, u
)
import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, placeholder, style, defaultValue, _data)
import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, placeholder, style, defaultValue, _data)
import React.DOM.Props as DOM
import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction, defaultRender, modifyState_, simpleSpec)
import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction, defaultRender, modifyState_, simpleSpec
, modifyState
)
import Gargantext.Config (toUrl, End(..), NodeType(..))
import Gargantext.Config (toUrl, End(..), NodeType(..))
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
...
@@ -61,16 +61,19 @@ data Action = ShowPopOver ID
...
@@ -61,16 +61,19 @@ data Action = ShowPopOver ID
| ToggleCreateNode ID
| ToggleCreateNode ID
| ShowRenameBox ID
| ShowRenameBox ID
| CancelRename ID
| CancelRename ID
| CurrentNode ID
type State = { state :: FTree }
type State = { state :: FTree
, currentNode :: Maybe Int
}
-- TODO remove
-- TODO remove
initialState :: State
initialState :: State
initialState = { state: NTree (LNode {id : 3, name : "hello", nodeType : Node, open : true, popOver : false, renameNodeValue : "", createNode : false, nodeValue : "InitialNode", showRenameBox : false}) [] }
initialState = { state: NTree (LNode {id : 3, name : "hello", nodeType : Node, open : true, popOver : false, renameNodeValue : "", createNode : false, nodeValue : "InitialNode", showRenameBox : false}) []
, currentNode : Nothing
}
mapFTree :: (FTree -> FTree) -> State -> State
mapFTree :: (FTree -> FTree) -> State -> State
mapFTree f {state
} = {state: f stat
e}
mapFTree f {state
, currentNode} = {state: f state, currentNode: currentNod
e}
-- TODO: make it a local function
-- TODO: make it a local function
performAction :: forall props. PerformAction State props Action
performAction :: forall props. PerformAction State props Action
...
@@ -108,6 +111,10 @@ performAction (Create nid) _ _ =
...
@@ -108,6 +111,10 @@ performAction (Create nid) _ _ =
performAction (SetNodeValue v nid) _ _ =
performAction (SetNodeValue v nid) _ _ =
modifyState_ $ mapFTree $ setNodeValue nid v
modifyState_ $ mapFTree $ setNodeValue nid v
performAction (CurrentNode nid) _ _ =
modifyState_ $ \{state: s} -> {state: s, currentNode : Just nid}
toggleIf :: Boolean -> Boolean -> Boolean
toggleIf :: Boolean -> Boolean -> Boolean
toggleIf true = not
toggleIf true = not
toggleIf false = const false
toggleIf false = const false
...
@@ -225,15 +232,15 @@ loadedTreeview :: Spec State LoadedTreeViewProps Action
...
@@ -225,15 +232,15 @@ loadedTreeview :: Spec State LoadedTreeViewProps Action
loadedTreeview = simpleSpec performAction render
loadedTreeview = simpleSpec performAction render
where
where
render :: Render State LoadedTreeViewProps Action
render :: Render State LoadedTreeViewProps Action
render dispatch _ {state} _ =
render dispatch _ {state
, currentNode
} _ =
[ div [className "tree"]
[ div [className "tree"]
[ toHtml dispatch state
[ toHtml dispatch state
currentNode
]
]
]
]
treeViewClass :: ReactClass (Loader.InnerProps Int FTree (children :: React.Children))
treeViewClass :: ReactClass (Loader.InnerProps Int FTree (children :: React.Children))
treeViewClass = createClass "TreeView" loadedTreeview (\{loaded: t} -> {state: t})
treeViewClass = createClass "TreeView" loadedTreeview (\{loaded: t} -> {state: t
, currentNode: Nothing
})
treeLoaderClass :: Loader.LoaderClass Int FTree
treeLoaderClass :: Loader.LoaderClass Int FTree
treeLoaderClass = Loader.createLoaderClass "TreeLoader" loadNode
treeLoaderClass = Loader.createLoaderClass "TreeLoader" loadNode
...
@@ -351,25 +358,30 @@ getCreateNodeValue :: FTree -> String
...
@@ -351,25 +358,30 @@ getCreateNodeValue :: FTree -> String
getCreateNodeValue (NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, nodeValue, showRenameBox}) ary) = nodeValue
getCreateNodeValue (NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, nodeValue, showRenameBox}) ary) = nodeValue
toHtml :: (Action -> Effect Unit) -> FTree -> ReactElement
toHtml :: (Action -> Effect Unit) -> FTree ->
Maybe Int ->
ReactElement
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, createNode,nodeValue, showRenameBox }) []) =
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, createNode,nodeValue, showRenameBox }) [])
n
=
ul []
ul []
[
[
li [] $
li [] $
[ a [className "glyphicon glyphicon-cog", _id "rename-leaf",onClick $ (\_-> d $ (ShowPopOver id))] []
[ a [className "glyphicon glyphicon-cog", _id "rename-leaf",onClick $ (\_-> d $ (ShowPopOver id))] []
, a [ href (toUrl Front nodeType (Just id)), style {"margin-left":"22px"}]
, a [ href (toUrl Front nodeType (Just id)), style {"margin-left":"22px"}
[ text (name <> " ") ]
, onClick $ (\e -> d $ CurrentNode id)
]
[ if n == (Just id) then u [] [b [] [text (name <> " ")]] else text (name <> " ") ]
, if (popOver == true) then (renameTreeView d s id) else (renameTreeViewDummy d s)
, if (popOver == true) then (renameTreeView d s id) else (renameTreeViewDummy d s)
, if (createNode == true) then (createNodeView d s id) else (renameTreeViewDummy d s)
, if (createNode == true) then (createNodeView d s id) else (renameTreeViewDummy d s)
]
]
]
]
--- need to add renameTreeview value to this function
--- need to add renameTreeview value to this function
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,createNode, nodeValue, showRenameBox}) ary) =
toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,createNode, nodeValue, showRenameBox}) ary)
n
=
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 nodeType (Just id)), style {"margin-left":"22px"}]
, a [ href (toUrl Front nodeType (Just id)), style {"margin-left":"22px"}
[ text name ]
, onClick $ (\e -> d $ CurrentNode id)
]
--[ text name ]
[ if n == (Just id) then u [] [b [] [text name]] else text name ]
, a [className "glyphicon glyphicon-cog", _id "rename",onClick $ (\_-> d $ (ShowPopOver id))]
, a [className "glyphicon glyphicon-cog", _id "rename",onClick $ (\_-> d $ (ShowPopOver id))]
[
[
]
]
...
@@ -378,7 +390,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,cre
...
@@ -378,7 +390,7 @@ toHtml d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue,cre
] <>
] <>
if open then
if open then
map (
toHtml d
) ary
map (
\s -> toHtml d s n
) ary
else []
else []
)
)
]
]
...
...
src/Gargantext/Pages/Corpus.purs
View file @
6cdcb538
...
@@ -58,7 +58,7 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
...
@@ -58,7 +58,7 @@ corpusHeaderSpec = simpleSpec defaultPerformAction render
getCorpus :: Int -> Aff CorpusData
getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do
getCorpus corpusId = do
corpusNode <- get $ toUrl Back Corpus $ Just corpusId
corpusNode
<- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
Just (NodePoly { id: defaultListId }) ->
...
...
src/Gargantext/Pages/Corpus/Tabs/Specs.purs
View file @
6cdcb538
...
@@ -61,9 +61,9 @@ statefulTabs =
...
@@ -61,9 +61,9 @@ statefulTabs =
docs = noState ( cmapProps (\{path: corpusId} -> {corpusId : corpusId, tabType: TabCorpus TabDocs}) histoSpec
docs = noState ( cmapProps (\{path: corpusId} -> {corpusId : corpusId, tabType: TabCorpus TabDocs}) histoSpec
<>
<>
(cmapProps (\{path: nodeId} -> { nodeId : nodeId
(cmapProps (\{path: nodeId} -> { nodeId : nodeId
, chart : div [][]
-- ECharts.chart globalPublis
, chart : div [][]
, tabType: TabCorpus TabDocs
, tabType: TabCorpus TabDocs
, totalRecords: 473
6
}) $ noState DT.docViewSpec
, totalRecords: 473
7
}) $ noState DT.docViewSpec
)
)
)
)
...
...
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