Commit 4b5da332 authored by Sudhir Kumar's avatar Sudhir Kumar

open side panel on node click

parent e840626a
module Gargantext.Pages.Corpus.Graph where module Gargantext.Pages.Corpus.Graph where
import Effect.Unsafe
import Gargantext.Prelude import Gargantext.Prelude
import Affjax (defaultRequest, request) import Affjax (defaultRequest, request)
...@@ -25,16 +26,15 @@ import Math (cos, sin) ...@@ -25,16 +26,15 @@ import Math (cos, sin)
import Partial.Unsafe (unsafePartial) import Partial.Unsafe (unsafePartial)
import React (ReactElement) import React (ReactElement)
import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul') import React.DOM (a, br', button, div, form', input, li, li', menu, option, p, select, span, text, ul, ul')
import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick,placeholder, style, title, value) import React.DOM.Props (_id, _type, checked, className, href, name, onChange, onClick, placeholder, style, title, value)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec) import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
import Effect.Unsafe
data Action data Action
= LoadGraph Int = LoadGraph Int
| SelectNode SelectedNode | SelectNode SelectedNode
| ShowSidePanel | ShowSidePanel Boolean
| ShowControls | ShowControls
newtype SelectedNode = SelectedNode {id :: String, label :: String} newtype SelectedNode = SelectedNode {id :: String, label :: String}
...@@ -78,8 +78,8 @@ performAction (LoadGraph fp) _ _ = void do ...@@ -78,8 +78,8 @@ performAction (LoadGraph fp) _ _ = void do
performAction (SelectNode node) _ _ = void do performAction (SelectNode node) _ _ = void do
modifyState $ \(State s) -> State s {selectedNode = pure node} modifyState $ \(State s) -> State s {selectedNode = pure node}
performAction (ShowSidePanel) _ (State state) = void do performAction (ShowSidePanel b) _ (State state) = void do
modifyState $ \(State s) -> State s {showSidePanel = not (state.showSidePanel) } modifyState $ \(State s) -> State s {showSidePanel = b }
performAction (ShowControls) _ (State state) = void do performAction (ShowControls) _ (State state) = void do
...@@ -284,8 +284,8 @@ specOld = simpleSpec performAction render' ...@@ -284,8 +284,8 @@ specOld = simpleSpec performAction render'
[text "Show Controls"] [text "Show Controls"]
, button [className "btn btn-primary" , button [className "btn btn-primary"
, style {position:"relative",top:"-25px",left: "1380px"} , style {position:"relative",top:"-25px",left: "1380px"}
,onClick \_ -> d ShowSidePanel ,onClick \_ -> d $ ShowSidePanel $ not st.showSidePanel
] [text "showSidePanel"] ] [text "Show SidePanel"]
] ]
, if (st.showControls) then , if (st.showControls) then
div [className "col-md-12", style {marginBottom : "21px"}] div [className "col-md-12", style {marginBottom : "21px"}]
...@@ -373,6 +373,7 @@ specOld = simpleSpec performAction render' ...@@ -373,6 +373,7 @@ specOld = simpleSpec performAction render'
, onClickNode : \e -> unsafePerformEffect $ do , onClickNode : \e -> unsafePerformEffect $ do
_ <- log " hello 2" _ <- log " hello 2"
--logs $ unsafeCoerce e --logs $ unsafeCoerce e
_ <- d $ ShowSidePanel true
_ <- d $ SelectNode $ SelectedNode {id : (unsafeCoerce e).data.node.id, label : (unsafeCoerce e).data.node.label} _ <- d $ SelectNode $ SelectedNode {id : (unsafeCoerce e).data.node.id, label : (unsafeCoerce e).data.node.label}
pure unit pure unit
} }
......
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