Commit acee709f authored by Alexandre Delanoë's avatar Alexandre Delanoë

[COSMETICS] reading code.

parent 481dc3ac
...@@ -52,7 +52,11 @@ data Action ...@@ -52,7 +52,11 @@ data Action
| SetPassword String | SetPassword String
performAction :: forall eff props. PerformAction (console :: CONSOLE, ajax :: AJAX,dom::DOM | eff) State props Action performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do performAction NoOp _ _ = void do
modifyState id modifyState id
......
...@@ -56,7 +56,9 @@ data Action ...@@ -56,7 +56,9 @@ data Action
| UserPageA UP.Action | UserPageA UP.Action
performAction :: forall eff props. PerformAction (dom :: DOM |eff) AppState props Action performAction :: forall eff props. PerformAction ( dom :: DOM
| eff
) AppState props Action
performAction (SetRoute route) _ _ = void do performAction (SetRoute route) _ _ = void do
modifyState $ _ {currentRoute = pure route} modifyState $ _ {currentRoute = pure route}
...@@ -64,9 +66,8 @@ performAction _ _ _ = void do ...@@ -64,9 +66,8 @@ performAction _ _ _ = void do
modifyState id modifyState id
---- Lens and Prism ---- Lens and Prism
_landingState:: Lens' AppState L.State _landingState :: Lens' AppState L.State
_landingState = lens (\s -> s.landingState) (\s ss -> s{landingState = ss}) _landingState = lens (\s -> s.landingState) (\s ss -> s{landingState = ss})
...@@ -77,8 +78,7 @@ _landingAction = prism LandingA \action -> ...@@ -77,8 +78,7 @@ _landingAction = prism LandingA \action ->
_-> Left action _-> Left action
_loginState :: Lens' AppState LN.State
_loginState:: Lens' AppState LN.State
_loginState = lens (\s -> s.loginState) (\s ss -> s{loginState = ss}) _loginState = lens (\s -> s.loginState) (\s ss -> s{loginState = ss})
...@@ -89,7 +89,7 @@ _loginAction = prism LoginA \action -> ...@@ -89,7 +89,7 @@ _loginAction = prism LoginA \action ->
_-> Left action _-> Left action
_addCorpusState:: Lens' AppState AC.State _addCorpusState :: Lens' AppState AC.State
_addCorpusState = lens (\s -> s.addCorpusState) (\s ss -> s{addCorpusState = ss}) _addCorpusState = lens (\s -> s.addCorpusState) (\s ss -> s{addCorpusState = ss})
...@@ -100,7 +100,6 @@ _addCorpusAction = prism AddCorpusA \action -> ...@@ -100,7 +100,6 @@ _addCorpusAction = prism AddCorpusA \action ->
_-> Left action _-> Left action
_docViewState:: Lens' AppState DV.State _docViewState:: Lens' AppState DV.State
_docViewState = lens (\s -> s.docViewState) (\s ss -> s{docViewState = ss}) _docViewState = lens (\s -> s.docViewState) (\s ss -> s{docViewState = ss})
...@@ -112,7 +111,7 @@ _docViewAction = prism DocViewA \action -> ...@@ -112,7 +111,7 @@ _docViewAction = prism DocViewA \action ->
_-> Left action _-> Left action
_searchState:: Lens' AppState S.State _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})
...@@ -123,7 +122,7 @@ _searchAction = prism SearchA \action -> ...@@ -123,7 +122,7 @@ _searchAction = prism SearchA \action ->
_-> Left action _-> Left action
_userPageState:: Lens' AppState UP.State _userPageState :: Lens' AppState UP.State
_userPageState = lens (\s -> s.userPage) (\s ss -> s{userPage = ss}) _userPageState = lens (\s -> s.userPage) (\s ss -> s{userPage = ss})
...@@ -335,11 +334,14 @@ layoutSpec = ...@@ -335,11 +334,14 @@ layoutSpec =
container = over _render \render d p s c -> container = over _render \render d p s c ->
(render d p s c) (render d p s c)
dispatchAction :: forall t115 t445 t447. Bind t445 => Applicative t445 => (Action -> t445 t447) -> t115 -> Routes -> t445 Unit dispatchAction :: forall t115 t445 t447.
Bind t445 => Applicative t445 =>
(Action -> t445 t447) -> t115 -> Routes -> t445 Unit
dispatchAction dispatcher _ Home = do dispatchAction dispatcher _ Home = do
_ <- dispatcher $ SetRoute $ Home _ <- dispatcher $ SetRoute $ Home
_ <- dispatcher $ LandingA $ L.NoOp _ <- dispatcher $ LandingA $ L.NoOp
pure unit pure unit
dispatchAction dispatcher _ Login = do dispatchAction dispatcher _ Login = do
_ <- dispatcher $ SetRoute $ Login _ <- dispatcher $ SetRoute $ Login
_ <- dispatcher $ LoginA $ LN.NoOp _ <- dispatcher $ LoginA $ LN.NoOp
......
...@@ -53,7 +53,17 @@ routing = ...@@ -53,7 +53,17 @@ routing =
home = Home <$ lit "" home = Home <$ lit ""
route str = lit "" *> lit str route str = lit "" *> lit str
routeHandler :: forall e. (Maybe Routes -> Routes -> Eff ( dom :: DOM, console :: CONSOLE | e) Unit) -> Maybe Routes -> Routes -> Eff (dom :: DOM, console :: CONSOLE | e) Unit
routeHandler :: forall e. ( Maybe Routes -> Routes -> Eff
( dom :: DOM
, console :: CONSOLE
| e
) Unit
) -> Maybe Routes -> Routes -> Eff
( dom :: DOM
, console :: CONSOLE
| e
) Unit
routeHandler dispatchAction old new = do routeHandler dispatchAction old new = do
liftEff $ log $ "change route : " <> show new liftEff $ log $ "change route : " <> show new
w <- window w <- window
......
...@@ -48,10 +48,12 @@ performAction GO _ _ = void do ...@@ -48,10 +48,12 @@ performAction GO _ _ = void do
unsafeEventValue :: forall event. event -> String unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value unsafeEventValue e = (unsafeCoerce e).target.value
-- TODO: case loggedIn of True -> Just Tree ; False -> Nothing
-- TODO: put the search form in the center of the page searchSpec :: forall props eff . Spec ( console :: CONSOLE
-- TODO put Gargantext logo as search button , ajax :: AJAX
searchSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action , dom :: DOM
| eff
) State props Action
searchSpec = simpleSpec performAction render searchSpec = simpleSpec performAction render
where where
render :: Render State props Action render :: Render State props Action
......
...@@ -13,21 +13,26 @@ import DocView as DV ...@@ -13,21 +13,26 @@ import DocView as DV
type State = String type State = String
initialState :: State initialState :: State
initialState ="" initialState = ""
data Action data Action = NoOp
= NoOp
performAction :: forall eff props. PerformAction (console :: CONSOLE, ajax :: AJAX,dom::DOM | eff) State props Action performAction :: forall eff props. PerformAction ( console :: CONSOLE
, ajax :: AJAX
, dom :: DOM
| eff
) State props Action
performAction NoOp _ _ = void do performAction NoOp _ _ = void do
modifyState id modifyState id
userPageSpec :: forall props eff . Spec ( console :: CONSOLE
userPageSpec :: forall props eff . Spec (console::CONSOLE, ajax::AJAX, dom::DOM | eff) State props Action , ajax :: AJAX
, dom :: DOM
| eff
) State props Action
userPageSpec = simpleSpec performAction render userPageSpec = simpleSpec performAction render
where where
render :: Render State props Action render :: Render State props Action
......
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