Commit 0b6ad414 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FACTO] renaming states records name.

parent e4b362e6
...@@ -8,26 +8,24 @@ import Control.Monad.Eff.Console (CONSOLE, log) ...@@ -8,26 +8,24 @@ import Control.Monad.Eff.Console (CONSOLE, log)
import DOM (DOM) import DOM (DOM)
import Data.Array (length) import Data.Array (length)
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism) import Data.Lens (Prism', prism)
import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.Doc.Body as CA
import Gargantext.Pages.Corpus.Doc.Document as DV
import Gargantext.Components.Login as LN import Gargantext.Components.Login as LN
import Gargantext.Components.Modals.Modal (modalShow) import Gargantext.Components.Modals.Modal (modalShow)
import Gargantext.Components.Tree as Tree import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard as Dsh
import Gargantext.Pages.Corpus as AC import Gargantext.Pages.Corpus as AC
import Gargantext.Router (Routes(..)) import Gargantext.Pages.Corpus.Doc.Annotation as D
import Gargantext.Pages.Corpus.User.Users as U import Gargantext.Pages.Corpus.Doc.Body as CA
import Gargantext.Pages.Corpus.Doc.Document as DV
import Gargantext.Pages.Corpus.Doc.Facets as TV
import Gargantext.Pages.Corpus.Doc.Facets.Dashboard as Dsh
import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE import Gargantext.Pages.Corpus.Doc.Facets.Graph as GE
import Gargantext.Pages.Home as L
import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG import Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsTable as NG
import Gargantext.Pages.Search as S import Gargantext.Pages.Corpus.User.Users as U
import Gargantext.Pages.Corpus.Doc.Facets as TV import Gargantext.Pages.Home as L
import Gargantext.Pages.Layout.States (AppState) import Gargantext.Pages.Layout.States (AppState)
import Gargantext.Pages.Corpus.Doc.Document as DV import Gargantext.Pages.Search as S
import Gargantext.Router (Routes)
import Network.HTTP.Affjax (AJAX) import Network.HTTP.Affjax (AJAX)
import Thermite (PerformAction, modifyState) import Thermite (PerformAction, modifyState)
...@@ -97,7 +95,7 @@ performAction Initialize _ state = void do ...@@ -97,7 +95,7 @@ performAction Initialize _ state = void do
modifyState id modifyState id
Right docs -> do Right docs -> do
modifyState $ _ { initialized = true modifyState $ _ { initialized = true
, ntreeView = if length d > 0 , ntreeState = if length d > 0
then Tree.exampleTree then Tree.exampleTree
--then fnTransform $ unsafePartial $ fromJust $ head d --then fnTransform $ unsafePartial $ fromJust $ head d
else Tree.initialState else Tree.initialState
......
...@@ -21,7 +21,7 @@ import Gargantext.Pages.Layout.States ( _addCorpusState ...@@ -21,7 +21,7 @@ import Gargantext.Pages.Layout.States ( _addCorpusState
, _graphExplorerState , _graphExplorerState
, _landingState , _landingState
, _loginState , _loginState
, _ngState , _ngramState
, _searchState , _searchState
, _tabviewState , _tabviewState
, _treeState , _treeState
...@@ -64,6 +64,22 @@ import React.DOM.Props (_data, _id, _type, aria, className, href, onChange, onCl ...@@ -64,6 +64,22 @@ import React.DOM.Props (_data, _id, _type, aria, className, href, onChange, onCl
import Thermite (Render, Spec, _render, defaultPerformAction, defaultRender, focus, simpleSpec, withState) import Thermite (Render, Spec, _render, defaultPerformAction, defaultRender, focus, simpleSpec, withState)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
layoutSpec :: forall eff props. Spec (E eff) AppState props Action
layoutSpec =
fold
[ routingSpec
, container $ withState pagesComponent
, withState \st ->
fold [ focus _loginState _loginAction (LN.modalSpec st.showLogin "Login" LN.renderSpec)
, focus _addCorpusState _addCorpusAction (AC.modalSpec st.showCorpus "Search Results" AC.layoutAddcorpus)
]
]
where
container :: Spec (E eff) AppState props Action -> Spec (E eff) AppState props Action
container = over _render \render d p s c ->
(render d p s c)
pagesComponent :: forall props eff. AppState -> Spec (E eff) AppState props Action pagesComponent :: forall props eff. AppState -> Spec (E eff) AppState props Action
pagesComponent s = pagesComponent s =
case s.currentRoute of case s.currentRoute of
...@@ -85,7 +101,7 @@ pagesComponent s = ...@@ -85,7 +101,7 @@ pagesComponent s =
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1 selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1
-- To be removed -- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
selectSpec NGramsTable = layout0 $ focus _ngState _NgramsA NG.ngramsTableSpec selectSpec NGramsTable = layout0 $ focus _ngramState _NgramsA NG.ngramsTableSpec
selectSpec PGraphExplorer = focus _graphExplorerState _graphExplorerAction GE.specOld selectSpec PGraphExplorer = focus _graphExplorerState _graphExplorerAction GE.specOld
selectSpec Dashboard = layout0 $ focus _dashBoardSate _dashBoardAction Dsh.layoutDashboard selectSpec Dashboard = layout0 $ focus _dashBoardSate _dashBoardAction Dsh.layoutDashboard
...@@ -334,17 +350,4 @@ layoutFooter = simpleSpec performAction render ...@@ -334,17 +350,4 @@ layoutFooter = simpleSpec performAction render
] ]
] ]
layoutSpec :: forall eff props. Spec (E eff) AppState props Action
layoutSpec =
fold
[ routingSpec
, container $ withState pagesComponent
, withState \st ->
fold [ focus _loginState _loginAction (LN.modalSpec st.showLogin "Login" LN.renderSpec)
, focus _addCorpusState _addCorpusAction (AC.modalSpec st.showCorpus "Search Results" AC.layoutAddcorpus)
]
]
where
container :: Spec (E eff) AppState props Action -> Spec (E eff) AppState props Action
container = over _render \render d p s c ->
(render d p s c)
...@@ -2,17 +2,12 @@ module Gargantext.Pages.Layout.States where ...@@ -2,17 +2,12 @@ module Gargantext.Pages.Layout.States where
import Prelude hiding (div) import Prelude hiding (div)
import Control.Monad.Cont.Trans (lift) import Control.Monad.Eff.Console (CONSOLE)
import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Console (CONSOLE, log)
import DOM (DOM) import DOM (DOM)
import Data.Array (length) import Data.Lens (Lens', lens)
import Data.Either (Either(..))
import Data.Lens (Lens', Prism', lens, prism)
import Data.Maybe (Maybe(Just)) import Data.Maybe (Maybe(Just))
import Gargantext.Components.Login as LN import Gargantext.Components.Login as LN
import Gargantext.Components.Modals.Modal (modalShow)
import Gargantext.Components.Tree as Tree import Gargantext.Components.Tree as Tree
import Gargantext.Pages.Corpus as AC import Gargantext.Pages.Corpus as AC
import Gargantext.Pages.Corpus.Doc.Annotation as D import Gargantext.Pages.Corpus.Doc.Annotation as D
...@@ -28,29 +23,28 @@ import Gargantext.Pages.Search as S ...@@ -28,29 +23,28 @@ import Gargantext.Pages.Search as S
import Gargantext.Router (Routes(..)) import Gargantext.Router (Routes(..))
import Network.HTTP.Affjax (AJAX) import Network.HTTP.Affjax (AJAX)
import Thermite (PerformAction, modifyState)
type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e) type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e)
type AppState = type AppState =
{ currentRoute :: Maybe Routes { currentRoute :: Maybe Routes
, landingState :: L.State , landingState :: L.State
, loginState :: LN.State , loginState :: LN.State
, addCorpusState :: AC.State , addCorpusState :: AC.State
, docViewState :: DV.State , docViewState :: DV.State
, searchState :: S.State , searchState :: S.State
, userPage :: U.State , userPageState :: U.State
, docAnnotationView :: D.State , docAnnotationState :: D.State
, ntreeView :: Tree.State , ntreeState :: Tree.State
, tabview :: TV.State , tabviewState :: TV.State
, search :: String , search :: String
, corpusAnalysis :: CA.State , corpusState :: CA.State
, showLogin :: Boolean , showLogin :: Boolean
, showCorpus :: Boolean , showCorpus :: Boolean
, graphExplorer :: GE.State , graphExplorerState :: GE.State
, initialized :: Boolean , initialized :: Boolean
, ngState :: NG.State , ngramState :: NG.State
, dashboard :: Dsh.State , dashboardState :: Dsh.State
} }
initAppState :: AppState initAppState :: AppState
...@@ -61,18 +55,18 @@ initAppState = ...@@ -61,18 +55,18 @@ initAppState =
, addCorpusState : AC.initialState , addCorpusState : AC.initialState
, docViewState : DV.tdata , docViewState : DV.tdata
, searchState : S.initialState , searchState : S.initialState
, userPage : U.initialState , userPageState : U.initialState
, docAnnotationView : D.initialState , docAnnotationState : D.initialState
, ntreeView : Tree.exampleTree , ntreeState : Tree.exampleTree
, tabview : TV.initialState , tabviewState : TV.initialState
, search : "" , search : ""
, corpusAnalysis : CA.initialState , corpusState : CA.initialState
, showLogin : false , showLogin : false
, showCorpus : false , showCorpus : false
, graphExplorer : GE.initialState , graphExplorerState : GE.initialState
, initialized : false , initialized : false
, ngState : NG.initialState , ngramState : NG.initialState
, dashboard : Dsh.initialState , dashboardState : Dsh.initialState
} }
--------------------------------------------------------- ---------------------------------------------------------
...@@ -92,27 +86,27 @@ _searchState :: Lens' AppState S.State ...@@ -92,27 +86,27 @@ _searchState :: Lens' AppState S.State
_searchState = lens (\s -> s.searchState) (\s ss -> s{searchState = ss}) _searchState = lens (\s -> s.searchState) (\s ss -> s{searchState = ss})
_userPageState :: Lens' AppState U.State _userPageState :: Lens' AppState U.State
_userPageState = lens (\s -> s.userPage) (\s ss -> s{userPage = ss}) _userPageState = lens (\s -> s.userPageState) (\s ss -> s{userPageState = ss})
_docAnnotationViewState :: Lens' AppState D.State _docAnnotationViewState :: Lens' AppState D.State
_docAnnotationViewState = lens (\s -> s.docAnnotationView) (\s ss -> s{docAnnotationView = ss}) _docAnnotationViewState = lens (\s -> s.docAnnotationState) (\s ss -> s{docAnnotationState = ss})
_treeState :: Lens' AppState Tree.State _treeState :: Lens' AppState Tree.State
_treeState = lens (\s -> s.ntreeView) (\s ss -> s {ntreeView = ss}) _treeState = lens (\s -> s.ntreeState) (\s ss -> s {ntreeState = ss})
_tabviewState :: Lens' AppState TV.State _tabviewState :: Lens' AppState TV.State
_tabviewState = lens (\s -> s.tabview) (\s ss -> s {tabview = ss}) _tabviewState = lens (\s -> s.tabviewState) (\s ss -> s {tabviewState = ss})
_corpusState :: Lens' AppState CA.State _corpusState :: Lens' AppState CA.State
_corpusState = lens (\s -> s.corpusAnalysis) (\s ss -> s {corpusAnalysis = ss}) _corpusState = lens (\s -> s.corpusState) (\s ss -> s {corpusState = ss})
_dashBoardSate :: Lens' AppState Dsh.State _dashBoardSate :: Lens' AppState Dsh.State
_dashBoardSate = lens (\s -> s.dashboard) (\s ss -> s {dashboard = ss}) _dashBoardSate = lens (\s -> s.dashboardState) (\s ss -> s {dashboardState = ss})
_graphExplorerState :: Lens' AppState GE.State _graphExplorerState :: Lens' AppState GE.State
_graphExplorerState = lens (\s -> s.graphExplorer) (\s ss -> s{graphExplorer = ss}) _graphExplorerState = lens (\s -> s.graphExplorerState) (\s ss -> s{graphExplorerState = ss})
_ngState :: Lens' AppState NG.State _ngramState :: Lens' AppState NG.State
_ngState = lens (\s -> s.ngState) (\s ss -> s{ngState = ss}) _ngramState = lens (\s -> s.ngramState) (\s ss -> s{ngramState = ss})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment