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
8543cfe2
Commit
8543cfe2
authored
Apr 08, 2021
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Folder view: workaround for back folder (hacky)
parent
4c0d1876
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
19 deletions
+34
-19
FolderView.js
src/Gargantext/Components/FolderView.js
+7
-0
FolderView.purs
src/Gargantext/Components/FolderView.purs
+25
-17
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+1
-1
Home.purs
src/Gargantext/Components/Nodes/Home.purs
+1
-1
No files found.
src/Gargantext/Components/FolderView.js
0 → 100644
View file @
8543cfe2
'use strict'
;
exports
.
back
=
function
()
{
return
function
()
{
history
.
back
();
}
}
\ No newline at end of file
src/Gargantext/Components/FolderView.purs
View file @
8543cfe2
...
...
@@ -2,10 +2,11 @@ module Gargantext.Components.FolderView where
import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe)
import Effect (Effect)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (
compare, pure, ($), (<$>), (<>), Ordering
)
import Gargantext.Prelude (
Ordering, Unit, compare, pure, ($), (<$>), (<>)
)
import Gargantext.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..), SessionId, fldr)
...
...
@@ -13,42 +14,46 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix.DOM.HTML as H
foreign import back :: Effect Unit
here :: R2.Here
here = R2.here "Gargantext.Components.FolderView"
type Props =
( nodeId :: Int
, session :: Session
, backFolder :: Boolean
)
data FolderStyle = FolderUp | FolderChild
folderView
Load
:: R2.Leaf Props
folderView
Load props = R.createElement folderViewLoad
Cpt props []
folderView :: R2.Leaf Props
folderView
props = R.createElement folderView
Cpt props []
folderView
Load
Cpt :: R.Component Props
folderView
LoadCpt = here.component "folderViewLoad
Cpt" cpt where
cpt {nodeId, session} _ = do
useLoader {nodeId, session} loadFolders $
\folders -> folderView
{folders, nodeId, session
}
folderViewCpt :: R.Component Props
folderView
Cpt = here.component "folderView
Cpt" cpt where
cpt {nodeId, session
, backFolder
} _ = do
useLoader {nodeId, session
, backFolder
} loadFolders $
\folders -> folderView
Main {folders, nodeId, session, backFolder
}
type FolderViewProps =
(
nodeId :: Int
, folders:: FTree
, session :: Session
, backFolder :: Boolean
)
folderView :: Record FolderViewProps -> R.Element
folderView
props = R.createElement folderView
Cpt props []
folderView
Main
:: Record FolderViewProps -> R.Element
folderView
Main props = R.createElement folderViewMain
Cpt props []
folderViewCpt :: R.Component FolderViewProps
folderView
Cpt = here.component "folderView
Cpt" cpt where
cpt {nodeId, session, folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do
folderView
Main
Cpt :: R.Component FolderViewProps
folderView
MainCpt = here.component "folderViewMain
Cpt" cpt where
cpt {nodeId, session,
backFolder,
folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do
let sid = sessionId session
let foldersS = A.sortBy sortFolders folders
let children = makeFolderElements foldersS sid
let parent = makeParentFolder parentId sid
let parent = makeParentFolder parentId sid
backFolder
pure $ H.div {className: "folders"} $ parent <> children
...
...
@@ -57,12 +62,15 @@ folderViewCpt = here.component "folderViewCpt" cpt where
makeFolderElementsMap :: NTree LNode -> R.Element
makeFolderElementsMap (NTree (LNode node) _) = folder {style: FolderChild, text: node.name, nodeId: node.id, nodeType: node.nodeType, sid: sid} []
makeParentFolder :: Maybe Int -> SessionId -> Array R.Element
makeParentFolder (Just parentId) sid =
makeParentFolder :: Maybe Int -> SessionId ->
Boolean ->
Array R.Element
makeParentFolder (Just parentId) sid
_
=
-- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType
-- without performing another API call. Also parentId is never being returned by this API even when it clearly exists
[ folder {style: FolderUp, text: "..", nodeId: parentId, nodeType: FolderPrivate, sid: sid} [] ]
makeParentFolder Nothing _ = []
makeParentFolder Nothing _ true = [ H.button {className: "btn btn-primary", on: { click: back } } [ H.i { className: "fa fa-folder-open" } []
, H.br {}
, H.text ".."] ]
makeParentFolder Nothing _ _ = []
sortFolders :: FTree -> FTree -> Ordering
sortFolders a b = compare (fTreeID a) (fTreeID b)
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
8543cfe2
...
...
@@ -90,7 +90,7 @@ corpusLayoutSelectionCpt = here.component "corpusLayoutSelection" cpt where
pure $ renderContent viewType nodeId session key
renderContent Folders nodeId session key = FV.folderView
Load { nodeId, session
}
renderContent Folders nodeId session key = FV.folderView
{ nodeId, session, backFolder: true
}
renderContent Code nodeId session key = corpusLayoutWithKey { key, nodeId, session }
...
...
src/Gargantext/Components/Nodes/Home.purs
View file @
8543cfe2
...
...
@@ -146,7 +146,7 @@ tutorialCpt = here.component "tutorial" cpt where
pure $ H.div { className: "mx-auto container" }
[ H.div {className: "d-flex justify-content-center"}
[FV.folderView
Load {session, nodeId
}]
[FV.folderView
{session, nodeId, backFolder: false
}]
, H.h1 {} [H.text "Welcome!"]
, H.h2 {} [H.text "For easy start, just watch the tutorials"]
, summary
...
...
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