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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
2c61318a
Unverified
Commit
2c61318a
authored
Nov 28, 2018
by
Nicolas Pouillard
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Tree] Remove the tree state from the layout state, use a loader for the initial tree
parent
4450820a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
40 deletions
+34
-40
Tree.purs
src/Gargantext/Components/Tree.purs
+25
-6
Layout.purs
src/Gargantext/Pages/Layout.purs
+0
-2
Actions.purs
src/Gargantext/Pages/Layout/Actions.purs
+1
-18
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+8
-7
States.purs
src/Gargantext/Pages/Layout/States.purs
+0
-7
No files found.
src/Gargantext/Components/Tree.purs
View file @
2c61318a
...
...
@@ -19,7 +19,8 @@ import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console (log)
import Prelude (identity)
import React (ReactElement)
import React (ReactClass, ReactElement)
import React as React
import React.DOM (a, button, div, h5, i, input, li, span, text, ul)
import React.DOM.Props (_id, _type, className, href, title, onClick, onInput, placeholder, style, defaultValue, _data)
import React.DOM.Props as DOM
...
...
@@ -27,12 +28,15 @@ import Thermite (PerformAction, Render, Spec, createClass, defaultPerformAction,
import Gargantext.Config (toUrl, End(..), NodeType(..), defaultRoot)
import Gargantext.Config.REST (get, put, post, delete, deleteWithBody)
import Gargantext.Components.Loader as Loader
type Name = String
type Open = Boolean
type URL = String
type ID = Int
type Props = { root :: ID }
data NTree a = NTree a (Array (NTree a))
type FTree = NTree LNode
...
...
@@ -41,7 +45,6 @@ data Action = ShowPopOver ID
| ToggleFolder ID
| RenameNode String ID
| Submit ID String
--| Initialize
| DeleteNode ID
| Create ID
| SetNodeValue String ID
...
...
@@ -203,12 +206,12 @@ nodeOptionsRename d activated id = case activated of
]
false -> []
type LoadedTreeViewProps = Loader.InnerProps Int FTree ()
treeview :: Spec State {} Action
treeview = simpleSpec performAction render
loadedTreeview :: Spec State LoadedTreeViewProps Action
loadedTreeview = simpleSpec performAction render
where
render :: Render State
{}
Action
render :: Render State
LoadedTreeViewProps
Action
render dispatch _ {state} _ =
[ div [className "tree"]
[ toHtml dispatch state
...
...
@@ -216,7 +219,23 @@ treeview = simpleSpec performAction render
]
]
treeViewClass :: ReactClass (Loader.InnerProps Int FTree (children :: React.Children))
treeViewClass = createClass "TreeView" loadedTreeview (\{loaded: t} -> {state: t})
treeLoaderClass :: Loader.LoaderClass Int FTree
treeLoaderClass = Loader.createLoaderClass "TreeLoader" loadNode
treeLoader :: Loader.Props' Int FTree -> ReactElement
treeLoader props = React.createElement treeLoaderClass props []
treeview :: Spec {} Props Void
treeview = simpleSpec defaultPerformAction render
where
render :: Render {} Props Void
render _ {root} _ _ =
[ treeLoader { path: root
, component: treeViewClass
} ]
renameTreeView :: (Action -> Effect Unit) -> FTree -> Int -> ReactElement
renameTreeView d s@(NTree (LNode {id, name, nodeType, open, popOver, renameNodeValue, showRenameBox }) ary) nid =
...
...
src/Gargantext/Pages/Layout.purs
View file @
2c61318a
...
...
@@ -20,12 +20,10 @@ dispatchAction :: forall ignored m.
(Action -> m Unit) -> ignored -> Routes -> m Unit
dispatchAction dispatcher _ Home = do
dispatcher Initialize
dispatcher $ SetRoute Home
-- dispatcher $ LandingA TODO
dispatchAction dispatcher _ Login = do
dispatcher Initialize
dispatcher $ SetRoute Login
-- dispatcher $ LoginA TODO
...
...
src/Gargantext/Pages/Layout/Actions.purs
View file @
2c61318a
...
...
@@ -25,10 +25,8 @@ import Gargantext.Router (Routes)
------------------------------------------------------------------------
data Action
= Initialize
| LoginA LN.Action
= LoginA LN.Action
| SetRoute Routes
| TreeViewA Tree.Action
| SearchA S.Action
| Search String
| AddCorpusA AC.Action
...
...
@@ -68,20 +66,11 @@ performAction Go _ _ = void do
--modifyState id
---------------------------------------------------------
performAction Initialize _ state = do
_ <- logs "loading Initial nodes"
case state.initialized of
false -> do
d <- lift $ Tree.loadNode defaultRoot
modifyState_ $ _ { initialized = true, ntreeState = {state: d} }
_ -> pure unit
performAction (LoginA _) _ _ = pure unit
performAction (AddCorpusA _) _ _ = pure unit
performAction (SearchA _) _ _ = pure unit
performAction (UserPageA _) _ _ = pure unit
performAction (DocumentViewA _) _ _ = pure unit
performAction (TreeViewA _) _ _ = pure unit
performAction (GraphExplorerA _) _ _ = pure unit
performAction (AnnuaireAction _) _ _ = pure unit
...
...
@@ -123,12 +112,6 @@ _documentViewAction = prism DocumentViewA \action ->
DocumentViewA caction -> Right caction
_-> Left action
_treeAction :: Prism' Action Tree.Action
_treeAction = prism TreeViewA \action ->
case action of
TreeViewA caction -> Right caction
_-> Left action
_graphExplorerAction :: Prism' Action GE.Action
_graphExplorerAction = prism GraphExplorerA \action ->
case action of
...
...
src/Gargantext/Pages/Layout/Specs.purs
View file @
2c61318a
...
...
@@ -11,6 +11,7 @@ import Thermite (Render, Spec, _render, defaultPerformAction, defaultRender, foc
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.Config (defaultRoot)
import Gargantext.Components.Data.Lang (Lang(..))
import Gargantext.Components.Login as LN
import Gargantext.Components.Tree as Tree
...
...
@@ -23,10 +24,10 @@ import Gargantext.Pages.Corpus.Dashboard as Dsh
import Gargantext.Pages.Corpus.Graph as GE
import Gargantext.Pages.Corpus.Tabs.Ngrams.NgramsTable as NG
import Gargantext.Pages.Home as L
import Gargantext.Pages.Layout.Actions (Action(..), _addCorpusAction, _documentViewAction, _graphExplorerAction, _loginAction, _searchAction, _
treeAction, _
userPageAction, performAction)
import Gargantext.Pages.Layout.Actions (Action(..), _addCorpusAction, _documentViewAction, _graphExplorerAction, _loginAction, _searchAction, _userPageAction, performAction)
import Gargantext.Pages.Layout.Specs.AddCorpus as AC
import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _documentViewState, _graphExplorerState, _loginState, _searchState, _
treeState, _
userPageState)
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _documentViewState, _graphExplorerState, _loginState, _searchState, _userPageState)
import Gargantext.Router (Routes(..))
layoutSpec :: Spec AppState {} Action
...
...
@@ -85,7 +86,7 @@ layout0 layout =
cont $ fold
[ withState \st ->
if ((\(LN.State s) -> s.loginC) st.loginState == true)
then ls as
then ls
$ cmapProps (const {root: defaultRoot})
as
else outerLayout1
, rs bs
]
...
...
@@ -95,7 +96,7 @@ layout0 layout =
rs = over _render \render d p s c -> [ div [ className "col-md-10"] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ]
as =
focus _treeState _treeAction
Tree.treeview
as =
noState
Tree.treeview
bs = innerLayout $ layout
...
...
@@ -108,7 +109,7 @@ layout0 layout =
]
]
-- TODO avoid code duplication with layout0
layout1 :: Spec AppState {} Action
-> Spec AppState {} Action
layout1 layout =
...
...
@@ -124,7 +125,7 @@ layout1 layout =
cont $ fold
[ withState \st ->
if ((\(LN.State s) -> s.loginC) st.loginState == true)
then ls as
then ls
$ cmapProps (const {root: defaultRoot})
as
else outerLayout1
, rs bs
]
...
...
@@ -137,7 +138,7 @@ layout1 layout =
rs = over _render \render d p s c -> [ div [if (s.showTree) then className "col-md-10" else className "col-md-12"] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ]
as =
focus _treeState _treeAction
Tree.treeview
as =
noState
Tree.treeview
bs = innerLayout $ layout
...
...
src/Gargantext/Pages/Layout/States.purs
View file @
2c61318a
...
...
@@ -21,12 +21,10 @@ type AppState =
, searchState :: S.State
, userPageState :: C.State
, documentState :: D.State
, ntreeState :: Tree.State
, search :: String
, showLogin :: Boolean
, showCorpus :: Boolean
, graphExplorerState :: GE.State
, initialized :: Boolean
, showTree :: Boolean
}
...
...
@@ -38,12 +36,10 @@ initAppState =
, searchState : S.initialState
, userPageState : C.initialState
, documentState : D.initialState {}
, ntreeState : {state: Tree.exampleTree}
, search : ""
, showLogin : false
, showCorpus : false
, graphExplorerState : GE.initialState
, initialized : false
, showTree : false
}
...
...
@@ -63,8 +59,5 @@ _userPageState = lens (\s -> s.userPageState) (\s ss -> s{userPageState = ss})
_documentViewState :: Lens' AppState D.State
_documentViewState = lens (\s -> s.documentState) (\s ss -> s{documentState = ss})
_treeState :: Lens' AppState Tree.State
_treeState = lens (\s -> s.ntreeState) (\s ss -> s {ntreeState = ss})
_graphExplorerState :: Lens' AppState GE.State
_graphExplorerState = lens (\s -> s.graphExplorerState) (\s ss -> s{graphExplorerState = ss})
Nicolas Pouillard
@np
mentioned in issue
#28 (closed)
·
Nov 29, 2018
mentioned in issue
#28 (closed)
mentioned in issue #28
Toggle commit list
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