Commit 0e91fff8 authored by Abinaya Sudhir's avatar Abinaya Sudhir

Add Navigation for Tabview

parent 408b6f2a
......@@ -2,7 +2,7 @@ module Navigation where
import DOM
import Gargantext.Data.Lang
import Prelude
import Prelude hiding (div)
import AddCorpusview as AC
import AnnotationDocumentView as D
......@@ -24,8 +24,11 @@ import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span,
import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onClick, placeholder, role, src, style, tabIndex, target, title)
import React.DOM.Props as RP
import SearchForm as S
import Tabview as TV
import Thermite (PerformAction, Render, Spec, _render, cotransform, defaultRender, focus, modifyState, simpleSpec, withState)
import UserPage as UP
type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e)
type AppState =
......@@ -38,6 +41,7 @@ type AppState =
, userPage :: UP.State
, annotationdocumentView :: D.State
, ntreeView :: NT.State
, tabview :: TV.State
}
initAppState :: AppState
......@@ -51,6 +55,7 @@ initAppState =
, userPage : UP.initialState
, annotationdocumentView : D.initialState
, ntreeView : NT.exampleTree
, tabview : TV.initialState
}
data Action
......@@ -64,6 +69,7 @@ data Action
| UserPageA UP.Action
| AnnotationDocumentViewA D.Action
| TreeViewA NT.Action
| TabViewA TV.Action
performAction :: forall eff props. PerformAction ( dom :: DOM
......@@ -167,6 +173,17 @@ _treeAction = prism TreeViewA \action ->
_-> Left action
_tabviewState :: Lens' AppState TV.State
_tabviewState = lens (\s -> s.tabview) (\s ss -> s {tabview = ss})
_tabviewAction :: Prism' Action TV.Action
_tabviewAction = prism TabViewA \action ->
case action of
TabViewA caction -> Right caction
_-> Left action
pagesComponent :: forall props eff. AppState -> Spec (E eff) AppState props Action
pagesComponent s =
case s.currentRoute of
......@@ -186,6 +203,7 @@ pagesComponent s =
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser
selectSpec (AnnotationDocumentView i) = layout0 $ focus _annotationdocumentviewState _annotationdocumentviewAction D.docview
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tabSpec
-- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
......@@ -503,3 +521,9 @@ dispatchAction dispatcher _ (AnnotationDocumentView i) = do
_ <- dispatcher $ SetRoute $ AnnotationDocumentView i
_ <- dispatcher $ AnnotationDocumentViewA $ D.NoOp
pure unit
dispatchAction dispatcher _ Tabview = do
_ <- dispatcher $ SetRoute $ Tabview
_ <- dispatcher $ TabViewA $ TV.NoOp
pure unit
......@@ -23,6 +23,7 @@ data Routes
| SearchView
| UserPage
| AnnotationDocumentView Int
| Tabview
instance showRoutes :: Show Routes where
......@@ -33,6 +34,7 @@ instance showRoutes :: Show Routes where
show SearchView = "SearchView"
show UserPage = "UserPage"
show (AnnotationDocumentView i) = "DocumentView"
show Tabview = "Tabview"
int :: Match Int
int = floor <$> num
......@@ -41,6 +43,7 @@ int = floor <$> num
routing :: Match Routes
routing =
loginRoute
<|> tabview
<|> documentView
<|> userPageRoute
<|> searchRoute
......@@ -48,6 +51,7 @@ routing =
<|> addcorpusRoute
<|> home
where
tabview = Tabview <$ route "tabview"
documentView = AnnotationDocumentView <$> (route "documentView" *> int)
userPageRoute = UserPage <$ route "userPage"
searchRoute = SearchView <$ route "search"
......
......@@ -21,6 +21,7 @@ data Action
| AuthorviewA AV.Action
| TermsviewA TV.Action
| ChangeTab
| NoOp
data TabTitle = TabTitle String Int
......
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