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