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
500cfd95
Commit
500cfd95
authored
Jun 06, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: create new corpus button
parent
f5c6e917
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
25 deletions
+97
-25
Tree.purs
src/Gargantext/Components/Tree.purs
+95
-23
Config.purs
src/Gargantext/Config.purs
+2
-2
No files found.
src/Gargantext/Components/Tree.purs
View file @
500cfd95
...
@@ -14,7 +14,8 @@ import Data.Argonaut.Core (Json)
...
@@ -14,7 +14,8 @@ import Data.Argonaut.Core (Json)
import Data.Either (Either(..))
import Data.Either (Either(..))
import Data.HTTP.Method (Method(..))
import Data.HTTP.Method (Method(..))
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype, over)
import DOM.Simple.Console
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
...
@@ -27,7 +28,7 @@ import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, pl
...
@@ -27,7 +28,7 @@ import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, pl
import React.DOM.Props as DOM
import React.DOM.Props as DOM
import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction, defaultRender, modifyState_, simpleSpec, modifyState)
import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction, defaultRender, modifyState_, simpleSpec, modifyState)
import Gargantext.Config (toUrl, End(..), NodeType(..))
import Gargantext.Config (toUrl, End(..), NodeType(..)
, urlPlease
)
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
import Gargantext.Components.Loader as Loader
import Gargantext.Components.Loader as Loader
...
@@ -51,12 +52,13 @@ filterNTree p (NTree x ary) =
...
@@ -51,12 +52,13 @@ filterNTree p (NTree x ary) =
type FTree = NTree LNode
type FTree = NTree LNode
data Action =
ShowPopOver
ID
data Action =
ShowPopOver
ID
| ToggleFolder ID
| ToggleFolder ID
| RenameNode String ID
| RenameNode String ID
| Submit ID String
| Submit ID String
| DeleteNode ID
| DeleteNode ID
| Create ID
| Create ID
| CreateSubmit ID String
| SetNodeValue String ID
| SetNodeValue String ID
| ToggleCreateNode ID
| ToggleCreateNode ID
| ShowRenameBox ID
| ShowRenameBox ID
...
@@ -64,13 +66,24 @@ data Action = ShowPopOver ID
...
@@ -64,13 +66,24 @@ data Action = ShowPopOver ID
| CurrentNode ID
| CurrentNode ID
type State = { state :: FTree
type State = { state :: FTree
, currentNode :: Maybe Int
, currentNode :: Maybe Int
}
}
-- TODO remove
-- TODO remove
initialNode = { id : 3
, name : "hello"
, nodeType : Node
, open : true
, popOver : false
, renameNodeValue : ""
, createNode : false
, nodeValue : "InitialNode"
, showRenameBox : false}
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}) [] , currentNode : Nothing}
initialState = { state: NTree (LNode initialNode) []
, currentNode : Nothing}
mapFTree :: (FTree -> FTree) -> State -> State
mapFTree :: (FTree -> FTree) -> State -> State
mapFTree f {state, currentNode} = {state: f state, currentNode: currentNode}
mapFTree f {state, currentNode} = {state: f state, currentNode: currentNode}
...
@@ -90,7 +103,8 @@ performAction (ShowRenameBox id) _ _ =
...
@@ -90,7 +103,8 @@ performAction (ShowRenameBox id) _ _ =
performAction (CancelRename id) _ _ =
performAction (CancelRename id) _ _ =
modifyState_ $ mapFTree $ map $ showPopOverNode id
modifyState_ $ mapFTree $ map $ showPopOverNode id
performAction (ToggleCreateNode id) _ _ =
performAction (ToggleCreateNode id) _ _ = do
modifyState_ $ mapFTree $ map $ hidePopOverNode id
modifyState_ $ mapFTree $ showCreateNode id
modifyState_ $ mapFTree $ showCreateNode id
performAction (DeleteNode nid) _ _ = do
performAction (DeleteNode nid) _ _ = do
...
@@ -105,7 +119,11 @@ performAction (Submit rid name) _ _ = do
...
@@ -105,7 +119,11 @@ performAction (Submit rid name) _ _ = do
performAction (RenameNode r nid) _ _ =
performAction (RenameNode r nid) _ _ =
modifyState_ $ mapFTree $ rename nid r
modifyState_ $ mapFTree $ rename nid r
performAction (Create nid) _ _ =
performAction (CreateSubmit nid name) _ _ = do
void $ lift $ createNode $ CreateValue {name}
modifyState_ $ mapFTree $ map $ hidePopOverNode nid
performAction (Create nid) _ _ = do
modifyState_ $ mapFTree $ showCreateNode nid
modifyState_ $ mapFTree $ showCreateNode nid
performAction (SetNodeValue v nid) _ _ =
performAction (SetNodeValue v nid) _ _ =
...
@@ -129,6 +147,10 @@ popOverNode sid (LNode node) =
...
@@ -129,6 +147,10 @@ popOverNode sid (LNode node) =
LNode $ node { popOver = toggleIf (sid == node.id) node.popOver
LNode $ node { popOver = toggleIf (sid == node.id) node.popOver
, showRenameBox = false }
, showRenameBox = false }
hidePopOverNode :: Int -> LNode -> LNode
hidePopOverNode sid (LNode node) =
LNode $ node { popOver = false }
showPopOverNode :: Int -> LNode -> LNode
showPopOverNode :: Int -> LNode -> LNode
showPopOverNode sid (LNode node) =
showPopOverNode sid (LNode node) =
LNode $ node {showRenameBox = toggleIf (sid == node.id) node.showRenameBox}
LNode $ node {showRenameBox = toggleIf (sid == node.id) node.showRenameBox}
...
@@ -300,27 +322,62 @@ renameTreeView d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeV
...
@@ -300,27 +322,62 @@ renameTreeView d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeV
]
]
else
else
div [ _id "beforeClick", className "col-md-12"]
div [ _id "beforeClick", className "col-md-12"]
[ div [className "row"]
[ div [className "row"]
[ div [className "col-md-6"] [text name]
[ div [className "col-md-6"]
, a [ style {color:"black"},className "glyphitem glyphicon glyphicon-pencil col-md-2", _id "rename1", title "Rename", onClick $ (\_-> d $ (ShowRenameBox id))] [ ]
[text name]
]
, a [ style {color:"black"}
]
, className "glyphitem glyphicon glyphicon-pencil col-md-2"
, _id "rename1"
, title "Rename"
, onClick $ (\_-> d $ (ShowRenameBox id))]
[]
]
]
]
]
,div [className "panel-body", style {display:"flex", justifyContent : "center", backgroundColor: "white", border: "none"}]
, div [ className "panel-body"
[ div [className "col-md-4"] [a [ style {color:"black", paddingTop: "6px", paddingBottom: "6px"},className "glyphitem glyphicon glyphicon-download-alt", _id "rename1", title "Download [WIP]"] [ ]]
, style {display:"flex", justifyContent : "center", backgroundColor: "white", border: "none"}]
, div [className "col-md-4"] [a [ style {color:"black", paddingTop: "6px", paddingBottom: "6px"},className "glyphitem glyphicon glyphicon-duplicate", _id "rename1", title "Duplicate [WIP]"] [ ]]
[ div [className "col-md-4"]
, div [className "col-md-4"] [ a [style {color:"black", paddingTop: "6px", paddingBottom: "6px"}, className "glyphitem glyphicon glyphicon-trash", _id "rename2",title "Delete", onClick $ (\_-> d $ (DeleteNode id))] [ ]]
[a [ style iconAStyle
, className (glyphicon "plus")
, _id "rename1"
, title "Create"
, onClick $ (\_ -> d $ (ToggleCreateNode id))]
[]
]
, div [className "col-md-4"]
[a [ style iconAStyle
, className (glyphicon "download-alt")
, _id "rename1"
, title "Download [WIP]"]
[]
]
, div [className "col-md-4"]
[a [ style iconAStyle
, className (glyphicon "duplicate")
, _id "rename1"
, title "Duplicate [WIP]"]
[]
]
, div [className "col-md-4"]
[ a [ style iconAStyle
, className (glyphicon "trash")
, _id "rename2"
, title "Delete"
, onClick $ (\_-> d $ (DeleteNode id))]
[]
]
]
]
]
]
]
where
]
iconAStyle = {color:"black", paddingTop: "6px", paddingBottom: "6px"}
glyphicon t = "glyphitem glyphicon glyphicon-" <> t
createNodeView :: (Action -> Effect Unit) -> FTree -> Int -> ReactElement
createNodeView :: (Action -> Effect Unit) -> FTree -> Int -> ReactElement
createNodeView d s@(NTree (LNode {id, name, nodeType, open, popOver,
renameN
odeValue }) ary) nid =
createNodeView d s@(NTree (LNode {id, name, nodeType, open, popOver,
n
odeValue }) ary) nid =
div [className ""]
div [className ""]
[ div [className "panel panel-default"]
[ div [className "panel panel-default"]
[
[
...
@@ -340,7 +397,7 @@ createNodeView d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeV
...
@@ -340,7 +397,7 @@ createNodeView d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeV
, div [className "panel-footer"]
, div [className "panel-footer"]
[ button [className "btn btn-success"
[ button [className "btn btn-success"
, _type "button"
, _type "button"
, onClick \_ -> d $ (Create
nid
)
, onClick \_ -> d $ (Create
Submit nid nodeValue
)
] [text "Create"]
] [text "Create"]
]
]
]
]
...
@@ -437,6 +494,21 @@ instance encodeJsonRenameValue :: EncodeJson RenameValue where
...
@@ -437,6 +494,21 @@ instance encodeJsonRenameValue :: EncodeJson RenameValue where
= "r_name" := name
= "r_name" := name
~> jsonEmptyObject
~> jsonEmptyObject
newtype CreateValue = CreateValue
{
name :: String
}
instance encodeJsonCreateValue :: EncodeJson CreateValue where
encodeJson (CreateValue {name})
= "query" := name
~> "corpus_id" := 0
~> "files_id" := ([] :: Array String)
~> jsonEmptyObject
createNode :: CreateValue -> Aff (Array Int)
createNode = post $ urlPlease Back $ "new"
renameNode :: Int -> RenameValue -> Aff (Array Int)
renameNode :: Int -> RenameValue -> Aff (Array Int)
renameNode renameNodeId = put $ toUrl Back Node (Just renameNodeId) <> "/rename"
renameNode renameNodeId = put $ toUrl Back Node (Just renameNodeId) <> "/rename"
...
...
src/Gargantext/Config.purs
View file @
500cfd95
...
@@ -226,9 +226,9 @@ instance toUrlPath :: ToUrl Path where
...
@@ -226,9 +226,9 @@ instance toUrlPath :: ToUrl Path where
data NodeType = NodeUser
data NodeType = NodeUser
| Annuaire
| Annuaire
| NodeContact
| NodeContact
| Corpus
| Corpus
| Url_Document
| Url_Document
| CorpusV3
| CorpusV3
| Dashboard
| Dashboard
| Error
| Error
...
...
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