Commit c1227c93 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[tree] add support for team highlight in tree

parent 543b31c8
...@@ -166,63 +166,65 @@ type ToHtmlProps = ...@@ -166,63 +166,65 @@ type ToHtmlProps =
) )
toHtml :: Record ToHtmlProps -> R.Element toHtml :: Record ToHtmlProps -> R.Element
toHtml p@{ asyncTasks toHtml p = R.createElement toHtmlCpt p []
, frontends
, mCurrentRoute toHtmlCpt :: R.Component ToHtmlProps
, openNodes toHtmlCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
, reload: reload@(_ /\ setReload) where
, session cpt p@{ asyncTasks
, tasks: tasks@{ onTaskAdd , frontends
, onTaskFinish , mCurrentRoute
, tasks: tasks' , openNodes
} , reload: reload@(_ /\ setReload)
, tree: tree@(NTree (LNode { id , session
, name , tasks: tasks@{ onTaskAdd
, nodeType , onTaskFinish
} , tasks: tasks'
}
, tree: tree@(NTree (LNode { id
, name
, nodeType
}
) ary ) ary
)
, handed
} _ = do
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 (A.null ary)
{ id
, dispatch: pAction
, folderOpen
, frontends
, handed
, 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
}
) )
, handed where
} = commonProps = RecordE.pick p :: Record CommonProps
R.createElement el {} [] pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
where
el = R.hooksComponentWithModule thisModule "nodeView" cpt
commonProps = RecordE.pick p :: Record CommonProps
pAction a = performAction a (RecordE.pick p :: Record PerformActionProps)
cpt _ _ = do
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 (A.null ary)
{ id
, dispatch: pAction
, folderOpen
, frontends
, handed
, 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
}
)
type ChildNodesProps = type ChildNodesProps =
......
...@@ -57,7 +57,7 @@ nodeMainSpan :: IsLeaf ...@@ -57,7 +57,7 @@ nodeMainSpan :: IsLeaf
nodeMainSpan isLeaf p@{ dispatch, folderOpen, frontends, handed, session } = R.createElement el p [] nodeMainSpan isLeaf p@{ dispatch, folderOpen, frontends, handed, session } = R.createElement el p []
where where
el = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt el = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
cpt props@{id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks }} _ = do cpt props@{ id, mCurrentRoute, name, nodeType, tasks: { onTaskFinish, tasks } } _ = do
-- only 1 popup at a time is allowed to be opened -- only 1 popup at a time is allowed to be opened
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile) droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
isDragOver <- R.useState' false isDragOver <- R.useState' false
...@@ -76,10 +76,7 @@ nodeMainSpan isLeaf p@{ dispatch, folderOpen, frontends, handed, session } = R.c ...@@ -76,10 +76,7 @@ nodeMainSpan isLeaf p@{ dispatch, folderOpen, frontends, handed, session } = R.c
, nodeLink { frontends , nodeLink { frontends
, id , id
, folderOpen , folderOpen
, isSelected: mCurrentRoute , isSelected: mCurrentRoute == Routes.nodeTypeAppRoute nodeType (sessionId session) id
== Routes.nodeTypeAppRoute
nodeType
(sessionId session) id
, name: name' props , name: name' props
, nodeType , nodeType
, session , session
......
...@@ -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,26 +10,26 @@ import Gargantext.Types (ChartOpts, ChartType, CorpusMetricOpts, CTabNgramType, ...@@ -10,26 +10,26 @@ 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
| 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
| RouteFile SessionId Int | RouteFile SessionId Int
| RouteFrameCalc SessionId Int
| RouteFrameWrite SessionId Int
| Team SessionId Int
| Texts SessionId Int
| UserPage SessionId Int
derive instance eqAppRoute :: Eq AppRoute derive instance eqAppRoute :: Eq AppRoute
...@@ -104,14 +104,17 @@ appPath (RouteFile s i) = "file/" <> show s <> "/" <> show i ...@@ -104,14 +104,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,28 +136,31 @@ instance encodeJsonTabPostQuery :: EncodeJson TabPostQuery where ...@@ -136,28 +136,31 @@ 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
| 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