Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
5f23a9dc
Commit
5f23a9dc
authored
Jul 17, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] SidePanel Tabs States use (WIP)
parent
c81b315a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
46 deletions
+55
-46
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+17
-17
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+1
-1
Sidebar.purs
src/Gargantext/Components/GraphExplorer/Sidebar.purs
+25
-20
ToggleButton.purs
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
+5
-5
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+5
-1
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+2
-2
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
5f23a9dc
...
@@ -89,8 +89,8 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -89,8 +89,8 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
cpt props@{frontends, graph, graphId, graphVersion, mCurrentRoute, mMetaData, session, sessions, showLogin, treeReload } _ = do
cpt props@{frontends, graph, graphId, graphVersion, mCurrentRoute, mMetaData, session, sessions, showLogin, treeReload } _ = do
dataRef <- R.useRef graph
dataRef <- R.useRef graph
graphRef <- R.useRef null
graphRef <- R.useRef null
graphVersionRef <- R.useRef (fst graphVersion)
graphVersionRef
<- R.useRef (fst graphVersion)
controls <- Controls.useGraphControls graph
controls
<- Controls.useGraphControls graph
multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled
multiSelectEnabledRef <- R.useRef $ fst controls.multiSelectEnabled
R.useEffect' $ do
R.useEffect' $ do
...
@@ -105,12 +105,12 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -105,12 +105,12 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
R.setRef dataRef graph
R.setRef dataRef graph
R.setRef graphVersionRef (fst graphVersion)
R.setRef graphVersionRef (fst graphVersion)
-- Reinitialize bunch of state as well.
-- Reinitialize bunch of state as well.
snd controls.removedNodeIds $ const SigmaxT.emptyNodeIds
snd controls.removedNodeIds
$ const SigmaxT.emptyNodeIds
snd controls.selectedNodeIds $ const SigmaxT.emptyNodeIds
snd controls.selectedNodeIds $ const SigmaxT.emptyNodeIds
snd controls.showEdges $ const SigmaxT.EShow
snd controls.showEdges
$ const SigmaxT.EShow
snd controls.forceAtlasState $ const SigmaxT.InitialRunning
snd controls.forceAtlasState $ const SigmaxT.InitialRunning
snd controls.graphStage $ const Graph.Init
snd controls.graphStage
$ const Graph.Init
snd controls.showSidePanel $ const GET.InitialClosed
snd controls.showSidePanel
$ const GET.InitialClosed
pure $
pure $
RH.div
RH.div
...
@@ -141,10 +141,10 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -141,10 +141,10 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
, graph
, graph
, graphId
, graphId
, graphVersion
, graphVersion
, removedNodeIds: controls.removedNodeIds
, removedNodeIds
: controls.removedNodeIds
, session
, session
, selectedNodeIds: controls.selectedNodeIds
, selectedNodeIds: controls.selectedNodeIds
, showSidePanel
: fst
controls.showSidePanel
, showSidePanel
:
controls.showSidePanel
, treeReload
, treeReload
}
}
]
]
...
@@ -171,7 +171,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
...
@@ -171,7 +171,7 @@ explorerCpt = R.hooksComponent "G.C.GraphExplorer.explorer" cpt
mSidebar :: Maybe GET.MetaData
mSidebar :: Maybe GET.MetaData
-> Record MSidebarProps
-> Record MSidebarProps
-> R.Element
-> R.Element
mSidebar
Nothing
_ = RH.div {} []
mSidebar
Nothing
_ = RH.div {} []
mSidebar (Just metaData) props =
mSidebar (Just metaData) props =
Sidebar.sidebar (Record.merge props { metaData })
Sidebar.sidebar (Record.merge props { metaData })
...
@@ -186,15 +186,15 @@ type TreeProps =
...
@@ -186,15 +186,15 @@ type TreeProps =
)
)
type MSidebarProps =
type MSidebarProps =
( frontends :: Frontends
( frontends
:: Frontends
, graph :: SigmaxT.SGraph
, graph
:: SigmaxT.SGraph
, graphId :: GraphId
, graphId
:: GraphId
, graphVersion :: R.State Int
, graphVersion
:: R.State Int
, removedNodeIds :: R.State SigmaxT.NodeIds
, removedNodeIds
:: R.State SigmaxT.NodeIds
, showSidePanel
::
GET.SidePanelState
, showSidePanel
:: R.State
GET.SidePanelState
, selectedNodeIds :: R.State SigmaxT.NodeIds
, selectedNodeIds :: R.State SigmaxT.NodeIds
, session :: Session
, session
:: Session
, treeReload :: R.State Int
, treeReload
:: R.State Int
)
)
type GraphProps = (
type GraphProps = (
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
5f23a9dc
...
@@ -94,7 +94,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
...
@@ -94,7 +94,7 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
-- Automatic opening of sidebar when a node is selected (but only first time).
-- Automatic opening of sidebar when a node is selected (but only first time).
R.useEffect' $ do
R.useEffect' $ do
if fst props.showSidePanel == GET.InitialClosed && (not Set.isEmpty $ fst props.selectedNodeIds) then
if fst props.showSidePanel == GET.InitialClosed && (not Set.isEmpty $ fst props.selectedNodeIds) then
snd props.showSidePanel $ \_ -> GET.Opened
snd props.showSidePanel $ \_ -> GET.Opened
GET.SideTab2
else
else
pure unit
pure unit
...
...
src/Gargantext/Components/GraphExplorer/Sidebar.purs
View file @
5f23a9dc
...
@@ -39,7 +39,7 @@ type Props =
...
@@ -39,7 +39,7 @@ type Props =
, removedNodeIds :: R.State SigmaxT.NodeIds
, removedNodeIds :: R.State SigmaxT.NodeIds
, selectedNodeIds :: R.State SigmaxT.NodeIds
, selectedNodeIds :: R.State SigmaxT.NodeIds
, session :: Session
, session :: Session
, showSidePanel :: GET.SidePanelState
, showSidePanel ::
R.State
GET.SidePanelState
, treeReload :: R.State Int
, treeReload :: R.State Int
)
)
...
@@ -49,43 +49,47 @@ sidebar props = R.createElement sidebarCpt props []
...
@@ -49,43 +49,47 @@ sidebar props = R.createElement sidebarCpt props []
sidebarCpt :: R.Component Props
sidebarCpt :: R.Component Props
sidebarCpt = R.hooksComponent "Sidebar" cpt
sidebarCpt = R.hooksComponent "Sidebar" cpt
where
where
cpt {showSidePanel:
GET.Closed
} _children = do
cpt {showSidePanel:
(GET.Closed /\ _)
} _children = do
pure $ RH.div {} []
pure $ RH.div {} []
cpt {showSidePanel:
GET.InitialClosed
} _children = do
cpt {showSidePanel:
(GET.InitialClosed /\ _)
} _children = do
pure $ RH.div {} []
pure $ RH.div {} []
cpt props@{metaData} _children = do
cpt props@{metaData, showSidePanel} _children = do
let (sidePanel /\ setSidePanel) = showSidePanel
let nodesMap = SigmaxT.nodesGraphMap props.graph
let nodesMap = SigmaxT.nodesGraphMap props.graph
pure $
pure $
RH.div { id: "sp-container" }
RH.div { id: "sp-container" }
[ RH.div {}
[ RH.div {}
[ R2.row
[ R2.row
[ R2.col12
[ R2.col
12
[ RH.ul { id: "myTab", className: "nav nav-tabs", role: "tablist"}
[ RH.ul { id: "myTab", className: "nav nav-tabs", role: "tablist"}
[ RH.div { className: "tab-content" }
[ RH.div { className: "tab-content" }
[ RH.div { className: "", role: "tabpanel" }
[ RH.div { className: "", role: "tabpanel" }
(Seq.toUnfoldable $ (Seq.map (badge props.selectedNodeIds) (badges props.graph props.selectedNodeIds)))
( Seq.toUnfoldable
$ ( Seq.map (badge props.selectedNodeIds)
(badges props.graph props.selectedNodeIds)
)
)
]
]
, RH.div { className: "tab-content" }
, RH.div { className: "tab-content" }
[
[ removeButton "Remove candidate" CandidateTerm props nodesMap
removeButton "Remove candidate" CandidateTerm props nodesMap
, removeButton "Remove stop" StopTerm props nodesMap
, removeButton "Remove stop" StopTerm props nodesMap
]
]
, RH.li { className: "nav-item" }
, RH.li { className: "nav-item" }
[ RH.a { id: "home-tab"
[ RH.a { id: "home-tab"
, className: "nav-link active"
, className: "nav-link active"
, data: {toggle: "tab"}
, data: {toggle: "tab"}
, href: "#legend"
, href: "#legend"
, role: "tab"
, role: "tab"
, aria: {controls: "legend", selected: "true"}
, aria: {controls: "legend", selected: "true"}
}
}
[ RH.text "Legend" ]
[ RH.text "Legend" ]
, let (GET.MetaData {legend}) = metaData
, let (GET.MetaData {legend}) = metaData
in Legend.legend { items: Seq.fromFoldable legend}
in Legend.legend { items: Seq.fromFoldable legend}
]
]
, RH.li { className: "nav-item" }
, RH.li { className: "nav-item" }
[ RH.a { id: "home-tab"
[ RH.a { id: "home-tab"
, className: "nav-link
active
"
, className: "nav-link"
, data: {toggle: "tab"}
, data: {toggle: "tab"}
, href: "#nodes"
, href: "#nodes"
, role: "tab"
, role: "tab"
...
@@ -131,7 +135,8 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
...
@@ -131,7 +135,8 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
[ RH.text text ]
[ RH.text text ]
onClickRemove rType props nodesMap e = do
onClickRemove rType props nodesMap e = do
let nodes = mapMaybe (\id -> Map.lookup id nodesMap) $ Set.toUnfoldable $ fst props.selectedNodeIds
let nodes = mapMaybe (\id -> Map.lookup id nodesMap)
$ Set.toUnfoldable $ fst props.selectedNodeIds
deleteNodes { graphId: props.graphId
deleteNodes { graphId: props.graphId
, metaData: props.metaData
, metaData: props.metaData
, nodes
, nodes
...
@@ -145,8 +150,8 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
...
@@ -145,8 +150,8 @@ sidebarCpt = R.hooksComponent "Sidebar" cpt
badge :: R.State SigmaxT.NodeIds -> Record SigmaxT.Node -> R.Element
badge :: R.State SigmaxT.NodeIds -> Record SigmaxT.Node -> R.Element
badge (_ /\ setNodeIds) {id, label} =
badge (_ /\ setNodeIds) {id, label} =
RH.a { className: "badge badge-light"
RH.a { className: "badge badge-light"
, on: { click: onClick }
, on: { click: onClick }
} [ RH.text label ]
} [ RH.text label ]
where
where
onClick e = do
onClick e = do
setNodeIds $ const $ Set.singleton id
setNodeIds $ const $ Set.singleton id
...
...
src/Gargantext/Components/GraphExplorer/ToggleButton.purs
View file @
5f23a9dc
...
@@ -144,12 +144,12 @@ sidebarToggleButton (state /\ setState) = R.createElement el {} []
...
@@ -144,12 +144,12 @@ sidebarToggleButton (state /\ setState) = R.createElement el {} []
]
]
onMessage = "Hide Sidebar"
onMessage = "Hide Sidebar"
offMessage = "Show Sidebar"
offMessage = "Show Sidebar"
text on _off
GET.Opened
= on
text on _off
(GET.Opened _)
= on
text _on off GET.InitialClosed = off
text _on off GET.InitialClosed = off
text _on off GET.Closed = off
text _on off GET.Closed
= off
onClick = \_ -> do
onClick = \_ -> do
setState $ \s -> case s of
setState $ \s -> case s of
GET.InitialClosed -> GET.Opened
GET.InitialClosed -> GET.Opened
GET.SideTab1
GET.Closed
-> GET.Opened
GET.Closed
-> GET.Opened GET.SideTab1
GET.Opened
-> GET.Closed
(GET.Opened _)
-> GET.Closed
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
5f23a9dc
...
@@ -189,6 +189,10 @@ intColor :: Int -> String
...
@@ -189,6 +189,10 @@ intColor :: Int -> String
intColor i = unsafePartial $ fromJust $ defaultPalette !! (i `mod` length defaultPalette)
intColor i = unsafePartial $ fromJust $ defaultPalette !! (i `mod` length defaultPalette)
data SidePanelState = InitialClosed | Opened | Closed
data SidePanelState = InitialClosed | Opened SideTab | Closed
data SideTab = SideTab1 | SideTab2 | SideTab3
derive instance eqSideTab :: Eq SideTab
derive instance eqSidePanelState :: Eq SidePanelState
derive instance eqSidePanelState :: Eq SidePanelState
src/Gargantext/Utils/Reactix.purs
View file @
5f23a9dc
...
@@ -252,8 +252,8 @@ blur el = el ... "blur" $ []
...
@@ -252,8 +252,8 @@ blur el = el ... "blur" $ []
row :: Array R.Element -> R.Element
row :: Array R.Element -> R.Element
row children = H.div { className: "row" } children
row children = H.div { className: "row" } children
col
12 ::
Array R.Element -> R.Element
col
:: Int ->
Array R.Element -> R.Element
col
12 children = H.div { className: "col-md-12"
} children
col
n children = H.div { className : "col-md" <> show n
} children
innerText :: DOM.Element -> String
innerText :: DOM.Element -> String
innerText e = e .. "innerText"
innerText e = e .. "innerText"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment