Commit 789cef0d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[MERGE] user-form

parents 72aeb6ae 20864e01
...@@ -291,7 +291,7 @@ pagesComponent s = ...@@ -291,7 +291,7 @@ pagesComponent s =
selectSpec Home = layout0 $ focus _landingState _landingAction (L.layoutLanding EN) selectSpec Home = layout0 $ focus _landingState _landingAction (L.layoutLanding EN)
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 U.layoutUser selectSpec (UserPage i) = layout0 $ focus _userPageState _userPageAction U.layoutUser
selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState _docAnnotationViewAction D.docview selectSpec (DocAnnotation i) = layout0 $ focus _docAnnotationViewState _docAnnotationViewAction D.docview
selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1 selectSpec Tabview = layout0 $ focus _tabviewState _tabviewAction TV.tab1
-- To be removed -- To be removed
...@@ -593,9 +593,10 @@ dispatchAction dispatcher _ SearchView = do ...@@ -593,9 +593,10 @@ dispatchAction dispatcher _ SearchView = do
_ <- dispatcher $ SearchA $ S.NoOp _ <- dispatcher $ SearchA $ S.NoOp
pure unit pure unit
dispatchAction dispatcher _ UserPage = do dispatchAction dispatcher _ (UserPage id) = do
_ <- dispatcher $ SetRoute $ UserPage _ <- dispatcher $ SetRoute $ UserPage id
_ <- dispatcher $ UserPageA $ U.NoOp _ <- dispatcher $ UserPageA $ U.NoOp
_ <- dispatcher $ UserPageA $ U.FetchUser id
pure unit pure unit
dispatchAction dispatcher _ (DocAnnotation i) = do dispatchAction dispatcher _ (DocAnnotation i) = do
......
...@@ -7,19 +7,18 @@ import Data.Maybe (Maybe(..)) ...@@ -7,19 +7,18 @@ import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..)) import Data.Tuple (Tuple(..))
import Prelude (($), (<<<)) import Prelude (($), (<<<))
import React (ReactElement) import React (ReactElement)
import React.DOM (button, div, h4, h3, li, span, text, ul, img) import React.DOM (div, h3, h1, li, span, text, ul, img)
import React.DOM.Props (_id, className, src) import React.DOM.Props (_id, className, src)
import React.DOM.Props as RP
import Thermite (Render) import Thermite (Render)
render :: forall props. Render State props Action render :: forall props. Render State props Action
render dispatch _ state _ = render dispatch _ state _ =
[ button [RP.onClick \_ -> dispatch $ FetchUser 473593] [ text "Fetch User"], [
div [className "col-md-12"] div [className "col-md-12"]
$ case state.user of $ case state.user of
(Just (User user)) -> display user.name [userInfos user.hyperdata] (Just (User user)) -> display user.name [userInfos user.hyperdata]
Nothing -> display "No user" [] Nothing -> display "User not found" []
] ]
display :: forall props. String -> Array ReactElement -> Array ReactElement display :: forall props. String -> Array ReactElement -> Array ReactElement
...@@ -37,7 +36,7 @@ display title elems = ...@@ -37,7 +36,7 @@ display title elems =
[ img [src "/images/Gargantextuel-212x300.jpg"] [] ] [ img [src "/images/Gargantextuel-212x300.jpg"] [] ]
, div [className "col-md-1"] [] , div [className "col-md-1"] []
, div [className "col-md-8"] elems , div [className "col-md-8"] elems
] ]
] ]
] ]
] ]
...@@ -55,7 +54,7 @@ userInfos (HyperData user) = ...@@ -55,7 +54,7 @@ userInfos (HyperData user) =
, listElement <<< infoRender <<< Tuple "Appelation: " $ checkMaybe user.fonction , listElement <<< infoRender <<< Tuple "Appelation: " $ checkMaybe user.fonction
, listElement <<< infoRender $ Tuple "Lieu: " $ checkMaybe user.lieu , listElement <<< infoRender $ Tuple "Lieu: " $ checkMaybe user.lieu
] ]
where where
checkMaybe (Nothing) = "" checkMaybe (Nothing) = ""
checkMaybe (Just a) = a checkMaybe (Just a) = a
...@@ -67,4 +66,3 @@ userInfos (HyperData user) = ...@@ -67,4 +66,3 @@ userInfos (HyperData user) =
[ span [] [text title] [ span [] [text title]
, span [className "badge badge-default badge-pill"] [text content] , span [className "badge badge-default badge-pill"] [text content]
] ]
...@@ -21,7 +21,7 @@ data Routes ...@@ -21,7 +21,7 @@ data Routes
| AddCorpus | AddCorpus
| DocView | DocView
| SearchView | SearchView
| UserPage | UserPage Int
| DocAnnotation Int | DocAnnotation Int
| Tabview | Tabview
| CorpusAnalysis | CorpusAnalysis
...@@ -31,36 +31,36 @@ data Routes ...@@ -31,36 +31,36 @@ data Routes
instance showRoutes :: Show Routes where instance showRoutes :: Show Routes where
show Login = "Login" show Login = "Login"
show AddCorpus = "AddCorpus" show AddCorpus = "AddCorpus"
show DocView = "DocView" show DocView = "DocView"
show SearchView = "SearchView" show SearchView = "SearchView"
show UserPage = "UserPage" show (UserPage i) = "UserPage"
show (DocAnnotation i)= "DocumentView" show (DocAnnotation i)= "DocumentView"
show Tabview = "Tabview" show Tabview = "Tabview"
show CorpusAnalysis = "corpus" show CorpusAnalysis = "corpus"
show PGraphExplorer = "graphExplorer" show PGraphExplorer = "graphExplorer"
show NGramsTable = "NGramsTable" show NGramsTable = "NGramsTable"
show Dashboard = "Dashboard" show Dashboard = "Dashboard"
show Home = "Home" show Home = "Home"
int :: Match Int int :: Match Int
int = floor <$> num int = floor <$> num
routing :: Match Routes routing :: Match Routes
routing = routing =
Login <$ route "login" Login <$ route "login"
<|> Tabview <$ route "tabview" <|> Tabview <$ route "tabview"
<|> DocAnnotation <$> (route "documentView" *> int) <|> DocAnnotation <$> (route "documentView" *> int)
<|> UserPage <$ route "userPage" <|> UserPage <$> (route "user" *> int)
<|> SearchView <$ route "search" <|> SearchView <$ route "search"
<|> DocView <$ route "docView" <|> DocView <$ route "docView"
<|> AddCorpus <$ route "addCorpus" <|> AddCorpus <$ route "addCorpus"
<|> CorpusAnalysis <$ route "corpus" <|> CorpusAnalysis <$ route "corpus"
<|> PGraphExplorer <$ route "graphExplorer" <|> PGraphExplorer <$ route "graphExplorer"
<|> NGramsTable <$ route "ngrams" <|> NGramsTable <$ route "ngrams"
<|> Dashboard <$ route "dashboard" <|> Dashboard <$ route "dashboard"
<|> Home <$ lit "" <|> Home <$ lit ""
where where
route str = lit "" *> lit str route str = lit "" *> lit str
......
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