Commit 972a2ab9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-highlight-currently-selected-node-in-tree' of...

Merge branch 'dev-highlight-currently-selected-node-in-tree' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents bde26977 31a48770
......@@ -167,62 +167,67 @@ toHtml :: Record ToHtmlProps -> R.Element
toHtml p = R.createElement toHtmlCpt p []
toHtmlCpt :: R.Component ToHtmlProps
toHtmlCpt = R.hooksComponentWithModule thisModule "nodeView" cpt
where
cpt p@{ asyncTasks
, frontends
, handed
, mCurrentRoute
, openNodes
, reload: reload@(_ /\ setReload)
, session
-- , tasks: tasks@{ onTaskAdd
-- , onTaskFinish
-- , tasks: tasks'
-- }
, tree: tree@(NTree (LNode { id
, name
, nodeType
}
) ary
)
} _ = do
let commonProps = RecordE.pick p :: Record CommonProps
let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
let nodeId = mkNodeId session id
let folderIsOpen = Set.member nodeId (fst openNodes)
let setFn = if folderIsOpen then Set.delete else Set.insert
let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId)
let folderOpen = Tuple folderIsOpen toggleFolderIsOpen
let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeMainSpan { asyncTasks
, dispatch: pAction
, folderOpen
, frontends
, handed
, id
, isLeaf: A.null ary
, mCurrentRoute
, name
, nodeType
, session
-- , tasks
} ]
<> childNodes ( Record.merge commonProps
{ asyncTasks
, children: if isPublic nodeType
then map (\t -> map (\(LNode n@{ nodeType:nt } )
-> (LNode (n { nodeType= publicize nt }))
) t) ary
else ary
, folderOpen
, handed
}
)
toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
where
cpt p@{ asyncTasks
, frontends
, handed
, mCurrentRoute
, openNodes
, reload: reload@(_ /\ setReload)
, session
-- , tasks: tasks@{ onTaskAdd
-- , onTaskFinish
-- , tasks: tasks'
-- }
, tree: tree@(NTree (LNode { id
, name
, nodeType
}
) ary
)
} _ = do
let commonProps = RecordE.pick p :: Record CommonProps
let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
let nodeId = mkNodeId session id
let folderIsOpen = Set.member nodeId (fst openNodes)
let setFn = if folderIsOpen then Set.delete else Set.insert
let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId)
let folderOpen = Tuple folderIsOpen toggleFolderIsOpen
let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeMainSpan
{ asyncTasks
, dispatch: pAction
, folderOpen
, frontends
, handed
, id
, isLeaf: A.null ary
, mCurrentRoute
, name
, nodeType
, session
-- , tasks
} ]
<> childNodes ( Record.merge commonProps
{ asyncTasks
, children: if isPublic nodeType
then map (\t -> map (\(LNode n@{ nodeType:nt } )
-> (LNode (n { nodeType= publicize nt }))
) t) ary
else ary
, folderOpen
, handed
}
)
where
commonProps = RecordE.pick p :: Record CommonProps
pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
type ChildNodesProps =
......
......@@ -6,6 +6,7 @@ import Data.Set (Set)
import Data.Set as Set
import Data.String as S
import Data.String.CodeUnits as DSCU
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff, launchAff, launchAff_)
......@@ -294,7 +295,7 @@ nodeLinkCpt = R.hooksComponentWithModule thisModule "nodeLink" cpt
popoverRef <- R.useRef null
pure $
H.div { on: { click: \_ -> setFolderOpen $ not } }
H.div { on: { click: onClick } }
[ H.a { data: { for: tooltipId
, tip: true
}
......@@ -313,6 +314,12 @@ nodeLinkCpt = R.hooksComponentWithModule thisModule "nodeLink" cpt
]
where
-- NOTE Don't toggle tree if it is not selected
-- This prevents some irritating behaviour
onClick _ = if isSelected then
setFolderOpen not
else
pure unit
tooltipId = "node-link-" <> show id
-- END node link
......
......@@ -30,6 +30,7 @@ import Gargantext.Types (NodeType(..), AffTableResult)
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus"
type Props =
......
......@@ -10,27 +10,27 @@ import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType,
import Gargantext.Types as GT
data AppRoute
= Home
| Login
= Annuaire SessionId Int
| ContactPage SessionId Int Int
| Corpus SessionId Int
| CorpusDocument SessionId Int Int Int
| Dashboard SessionId Int
| Document SessionId Int Int
| Folder SessionId Int
| FolderPrivate SessionId Int
| FolderPublic SessionId Int
| FolderShared SessionId Int
| Team SessionId Int
| Corpus SessionId Int
| Document SessionId Int Int
| CorpusDocument SessionId Int Int Int
| PGraphExplorer SessionId Int
| Dashboard SessionId Int
| Texts SessionId Int
| Lists SessionId Int
| Annuaire SessionId Int
| UserPage SessionId Int
| ContactPage SessionId Int Int
| RouteFrameWrite SessionId Int
| Home
| Lists SessionId Int
| Login
| PGraphExplorer SessionId Int
| RouteFile SessionId Int
| RouteFrameCalc SessionId Int
| RouteFrameCode SessionId Int
| RouteFile SessionId Int
| RouteFrameWrite SessionId Int
| Team SessionId Int
| Texts SessionId Int
| UserPage SessionId Int
derive instance eqAppRoute :: Eq AppRoute
......@@ -108,14 +108,17 @@ appPath (RouteFile s i) = "file/" <> show s <> "/" <> show i
nodeTypeAppRoute :: NodeType -> SessionId -> Int -> Maybe AppRoute
nodeTypeAppRoute GT.Annuaire s i = Just $ Annuaire s i
nodeTypeAppRoute GT.NodeContact s i = Just $ Annuaire s i
nodeTypeAppRoute GT.Corpus s i = Just $ Corpus s i
nodeTypeAppRoute GT.Dashboard s i = Just $ Dashboard s i
nodeTypeAppRoute GT.Graph s i = Just $ PGraphExplorer s i
nodeTypeAppRoute GT.NodeList s i = Just $ Lists s i
nodeTypeAppRoute GT.Folder s i = Just $ Folder s i
nodeTypeAppRoute GT.FolderPrivate s i = Just $ FolderPrivate s i
nodeTypeAppRoute GT.FolderPublic s i = Just $ FolderPublic s i
nodeTypeAppRoute GT.FolderShared s i = Just $ FolderShared s i
nodeTypeAppRoute GT.Graph s i = Just $ PGraphExplorer s i
nodeTypeAppRoute GT.NodeContact s i = Just $ Annuaire s i
nodeTypeAppRoute GT.NodeFile s i = Just $ RouteFile s i
nodeTypeAppRoute GT.NodeList s i = Just $ Lists s i
nodeTypeAppRoute GT.NodeUser s i = Just $ UserPage s i
nodeTypeAppRoute GT.Team s i = Just $ Team s i
nodeTypeAppRoute GT.Texts s i = Just $ Texts s i
nodeTypeAppRoute _ _ _ = Nothing
......@@ -136,29 +136,32 @@ instance encodeJsonTabPostQuery :: EncodeJson TabPostQuery where
~> "query" := post.query
~> jsonEmptyObject
data NodeType = NodeUser
| Folder | FolderPrivate | FolderShared | FolderPublic
| Annuaire
| NodeContact
data NodeType = Annuaire
| Corpus
| Team
| Url_Document
| Dashboard
| Error
| Folder
| FolderPrivate
| FolderPublic
| FolderShared
| Graph
| Phylo
| Individu
| Node
| Nodes
| Tree
| NodeContact
| NodeList
| NodeUser
| Nodes
| Phylo
| Team
| Texts
| Tree
| Url_Document
-- TODO Optional Nodes
| NodeFrameWrite
| NodeFile
| NodeFrameCalc
| NodeFrameNotebook
| NodeFrameWrite
| NodePublic NodeType
| NodeFile
derive instance eqNodeType :: Eq NodeType
......
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