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
b5a6a3ff
Commit
b5a6a3ff
authored
Apr 19, 2022
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Folder View] Go to home when top level folder is reached
parent
8362d77f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
FolderView.purs
src/Gargantext/Components/FolderView.purs
+16
-9
No files found.
src/Gargantext/Components/FolderView.purs
View file @
b5a6a3ff
module Gargantext.Components.FolderView where
import Data.Array as A
import Data.Eq ((==))
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Nullable (null)
import Data.Traversable (traverse_)
...
...
@@ -26,11 +27,11 @@ import Gargantext.Components.GraphQL.Endpoints (getTreeFirstLevel)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, TreeNode)
import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.LinkHandler (
Methods,
useLinkHandler)
import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>))
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard,
otherwise,
pure, unit, void, ($), (<$>), (<>))
import Gargantext.Routes (AppRoute(Home), nodeTypeAppRoute)
import Gargantext.Sessions (Session, sessionId)
import Gargantext.Sessions (Session
(..)
, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT
import Gargantext.Utils.Popover as Popover
...
...
@@ -91,9 +92,8 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, reload
, session
, setPopoverRef } _ = do
linkHandlers <- useLinkHandler
let foldersS = A.sortBy sortFolders children
let parent = makeParentFolder
linkHandlers
parentNode session
let parent = makeParentFolder parentNode session
let childrenEl = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
pure $ H.div {className: "fv folders"} $ parent <> childrenEl
...
...
@@ -110,10 +110,10 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, style: FolderChild
, text: node.name } []
makeParentFolder ::
Record Methods ->
Maybe TreeNode -> Session -> Array R.Element
makeParentFolder
_
(Just parent) session =
makeParentFolder :: Maybe TreeNode -> Session -> Array R.Element
makeParentFolder (Just parent) session =
[ folderSimple {style: FolderUp, text: "..", nodeId: parent.id, nodeType: parent.node_type, session: session} [] ]
makeParentFolder
_
Nothing _ = []
makeParentFolder Nothing _ = []
sortFolders :: TreeNode-> TreeNode -> Ordering
...
...
@@ -136,11 +136,18 @@ folderSimpleCpt = here.component "folderSimpleCpt" cpt where
cpt {style, text, nodeId, session, nodeType} _ = do
{ goToRoute } <- useLinkHandler
let sid = sessionId session
let rootId = treeId session
pure $ H.button { className: "btn btn-primary"
, on: {click: \_ -> goToRoute $
getFolderPath nodeType sid nodeI
d} }
, on: {click: \_ -> goToRoute $
route nodeId rootId nodeType si
d} }
[ H.i { className: icon style nodeType } []
, H.br {}
, H.text text ]
where
treeId (Session {treeId: tId}) = tId
route nId rootId nType sid
| rootId == nodeId = Home
| otherwise = getFolderPath nType sid nId
icon :: FolderStyle -> GT.NodeType -> String
icon FolderUp _ = "fa fa-folder-open"
...
...
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