Commit b3b820f8 authored by Abinaya Sudhir's avatar Abinaya Sudhir

Document view added with navigation

parent 33c237fc
module DocumentView where
import Prelude hiding (div)
import React.DOM (div, h4, text)
import React.DOM.Props (className)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
type State = String
initialState :: State
initialState = ""
data Action = NoOp
performAction :: PerformAction _ State _ Action
performAction NoOp _ _ = pure unit
docview :: Spec _ State _ Action
docview = simpleSpec performAction render
where
render :: Render State _ Action
render dispatch _ state _ =
[ div [className "container"]
[ div [className "row"]
[ div [className "col-md-4"] []
, div [className "col-md-8"]
[ h4 [] [text "Ultrasonic sensors in urban traffic driving-aid systems"]
]
]
]
]
...@@ -17,10 +17,11 @@ import Prelude (class Applicative, class Bind, Unit, bind, id, map, negate, pure ...@@ -17,10 +17,11 @@ import Prelude (class Applicative, class Bind, Unit, bind, id, map, negate, pure
import React (ReactElement) import React (ReactElement)
import React.DOM (a, div, img, li, span, text, ul, input, button, footer, p, hr, form) import React.DOM (a, div, img, li, span, text, ul, input, button, footer, p, hr, form)
import React.DOM.Props (_data, _id, _type, aria, className, href, name, placeholder, role, src, style, tabIndex, target, title) import React.DOM.Props (_data, _id, _type, aria, className, href, name, placeholder, role, src, style, tabIndex, target, title)
import React.DOM.Props as RP
import SearchForm as S import SearchForm as S
import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState) import Thermite (PerformAction, Render, Spec, _render, defaultRender, focus, modifyState, simpleSpec, withState)
import UserPage as UP import UserPage as UP
import React.DOM.Props as RP import DocumentView as D
type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e) type E e = (dom :: DOM, ajax :: AJAX, console :: CONSOLE | e)
...@@ -32,6 +33,7 @@ type AppState = ...@@ -32,6 +33,7 @@ type AppState =
, docViewState :: DV.State , docViewState :: DV.State
, searchState :: S.State , searchState :: S.State
, userPage :: UP.State , userPage :: UP.State
, documentView :: D.State
} }
initAppState :: AppState initAppState :: AppState
...@@ -43,6 +45,7 @@ initAppState = ...@@ -43,6 +45,7 @@ initAppState =
, docViewState : DV.tdata , docViewState : DV.tdata
, searchState : S.initialState , searchState : S.initialState
, userPage : UP.initialState , userPage : UP.initialState
, documentView : D.initialState
} }
data Action data Action
...@@ -54,6 +57,7 @@ data Action ...@@ -54,6 +57,7 @@ data Action
| DocViewA DV.Action | DocViewA DV.Action
| SearchA S.Action | SearchA S.Action
| UserPageA UP.Action | UserPageA UP.Action
| DocumentViewA D.Action
performAction :: forall eff props. PerformAction ( dom :: DOM performAction :: forall eff props. PerformAction ( dom :: DOM
...@@ -133,6 +137,17 @@ _userPageAction = prism UserPageA \action -> ...@@ -133,6 +137,17 @@ _userPageAction = prism UserPageA \action ->
_-> Left action _-> Left action
_documentviewState :: Lens' AppState D.State
_documentviewState = lens (\s -> s.documentView) (\s ss -> s{documentView = ss})
_documentviewAction :: Prism' Action D.Action
_documentviewAction = prism DocumentViewA \action ->
case action of
DocumentViewA caction -> Right caction
_-> Left action
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 =
...@@ -152,6 +167,7 @@ pagesComponent s = ...@@ -152,6 +167,7 @@ pagesComponent s =
selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus selectSpec AddCorpus = layout0 $ focus _addCorpusState _addCorpusAction AC.layoutAddcorpus
selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview selectSpec DocView = layout0 $ focus _docViewState _docViewAction DV.layoutDocview
selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser selectSpec UserPage = layout0 $ focus _userPageState _userPageAction UP.layoutUser
selectSpec (DocumentView i) = layout0 $ focus _documentviewState _documentviewAction D.docview
-- To be removed -- To be removed
selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec selectSpec SearchView = layout0 $ focus _searchState _searchAction S.searchSpec
...@@ -407,3 +423,8 @@ dispatchAction dispatcher _ UserPage = do ...@@ -407,3 +423,8 @@ dispatchAction dispatcher _ UserPage = do
_ <- dispatcher $ SetRoute $ UserPage _ <- dispatcher $ SetRoute $ UserPage
_ <- dispatcher $ UserPageA $ UP.NoOp _ <- dispatcher $ UserPageA $ UP.NoOp
pure unit pure unit
dispatchAction dispatcher _ (DocumentView i) = do
_ <- dispatcher $ SetRoute $ DocumentView i
_ <- dispatcher $ UserPageA $ UP.NoOp
pure unit
...@@ -22,6 +22,7 @@ data Routes ...@@ -22,6 +22,7 @@ data Routes
| DocView | DocView
| SearchView | SearchView
| UserPage | UserPage
| DocumentView Int
instance showRoutes :: Show Routes where instance showRoutes :: Show Routes where
...@@ -31,6 +32,7 @@ instance showRoutes :: Show Routes where ...@@ -31,6 +32,7 @@ instance showRoutes :: Show Routes where
show DocView = "DocView" show DocView = "DocView"
show SearchView = "SearchView" show SearchView = "SearchView"
show UserPage = "UserPage" show UserPage = "UserPage"
show (DocumentView i) = "DocumentView"
int :: Match Int int :: Match Int
int = floor <$> num int = floor <$> num
...@@ -39,12 +41,14 @@ int = floor <$> num ...@@ -39,12 +41,14 @@ int = floor <$> num
routing :: Match Routes routing :: Match Routes
routing = routing =
loginRoute loginRoute
<|> documentView
<|> userPageRoute <|> userPageRoute
<|> searchRoute <|> searchRoute
<|> docviewRoute <|> docviewRoute
<|> addcorpusRoute <|> addcorpusRoute
<|> home <|> home
where where
documentView = DocumentView <$> (route "documentView" *> int)
userPageRoute = UserPage <$ route "userPage" userPageRoute = UserPage <$ route "userPage"
searchRoute = SearchView <$ route "search" searchRoute = SearchView <$ route "search"
docviewRoute = DocView <$ route "docView" docviewRoute = DocView <$ route "docView"
......
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