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
...
@@ -2,10 +2,11 @@ module Gargantext.Components.FolderView where
import Data.Array as A
import Data.Array as A
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Maybe (Maybe(..), fromMaybe)
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..), fTreeID)
import Gargantext.Hooks.Loader (useLoader)
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.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (NodeType(..), SessionId, fldr)
import Gargantext.Types (NodeType(..), SessionId, fldr)
...
@@ -13,42 +14,46 @@ import Gargantext.Utils.Reactix as R2
...
@@ -13,42 +14,46 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
foreign import back :: Effect Unit
here :: R2.Here
here :: R2.Here
here = R2.here "Gargantext.Components.FolderView"
here = R2.here "Gargantext.Components.FolderView"
type Props =
type Props =
( nodeId :: Int
( nodeId :: Int
, session :: Session
, session :: Session
, backFolder :: Boolean
)
)
data FolderStyle = FolderUp | FolderChild
data FolderStyle = FolderUp | FolderChild
folderView
Load
:: R2.Leaf Props
folderView :: R2.Leaf Props
folderView
Load props = R.createElement folderViewLoad
Cpt props []
folderView
props = R.createElement folderView
Cpt props []
folderView
Load
Cpt :: R.Component Props
folderViewCpt :: R.Component Props
folderView
LoadCpt = here.component "folderViewLoad
Cpt" cpt where
folderView
Cpt = here.component "folderView
Cpt" cpt where
cpt {nodeId, session} _ = do
cpt {nodeId, session
, backFolder
} _ = do
useLoader {nodeId, session} loadFolders $
useLoader {nodeId, session
, backFolder
} loadFolders $
\folders -> folderView
{folders, nodeId, session
}
\folders -> folderView
Main {folders, nodeId, session, backFolder
}
type FolderViewProps =
type FolderViewProps =
(
(
nodeId :: Int
nodeId :: Int
, folders:: FTree
, folders:: FTree
, session :: Session
, session :: Session
, backFolder :: Boolean
)
)
folderView :: Record FolderViewProps -> R.Element
folderView
Main
:: Record FolderViewProps -> R.Element
folderView
props = R.createElement folderView
Cpt props []
folderView
Main props = R.createElement folderViewMain
Cpt props []
folderViewCpt :: R.Component FolderViewProps
folderView
Main
Cpt :: R.Component FolderViewProps
folderView
Cpt = here.component "folderView
Cpt" cpt where
folderView
MainCpt = here.component "folderViewMain
Cpt" cpt where
cpt {nodeId, session, folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do
cpt {nodeId, session,
backFolder,
folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do
let sid = sessionId session
let sid = sessionId session
let foldersS = A.sortBy sortFolders folders
let foldersS = A.sortBy sortFolders folders
let children = makeFolderElements foldersS sid
let children = makeFolderElements foldersS sid
let parent = makeParentFolder parentId sid
let parent = makeParentFolder parentId sid
backFolder
pure $ H.div {className: "folders"} $ parent <> children
pure $ H.div {className: "folders"} $ parent <> children
...
@@ -57,12 +62,15 @@ folderViewCpt = here.component "folderViewCpt" cpt where
...
@@ -57,12 +62,15 @@ folderViewCpt = here.component "folderViewCpt" cpt where
makeFolderElementsMap :: NTree LNode -> R.Element
makeFolderElementsMap :: NTree LNode -> R.Element
makeFolderElementsMap (NTree (LNode node) _) = folder {style: FolderChild, text: node.name, nodeId: node.id, nodeType: node.nodeType, sid: sid} []
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 :: Maybe Int -> SessionId ->
Boolean ->
Array R.Element
makeParentFolder (Just parentId) sid =
makeParentFolder (Just parentId) sid
_
=
-- FIXME: The NodeType here should not be hardcoded to FolderPrivate but we currently can't get the actual NodeType
-- 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
-- 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} [] ]
[ 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 :: FTree -> FTree -> Ordering
sortFolders a b = compare (fTreeID a) (fTreeID b)
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
...
@@ -90,7 +90,7 @@ corpusLayoutSelectionCpt = here.component "corpusLayoutSelection" cpt where
pure $ renderContent viewType nodeId session key
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 }
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
...
@@ -146,7 +146,7 @@ tutorialCpt = here.component "tutorial" cpt where
pure $ H.div { className: "mx-auto container" }
pure $ H.div { className: "mx-auto container" }
[ H.div {className: "d-flex justify-content-center"}
[ 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.h1 {} [H.text "Welcome!"]
, H.h2 {} [H.text "For easy start, just watch the tutorials"]
, H.h2 {} [H.text "For easy start, just watch the tutorials"]
, summary
, 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