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
2e681144
Commit
2e681144
authored
Mar 31, 2021
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Folder view fixes
parent
fa676aa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+34
-18
No files found.
src/Gargantext/Components/Nodes/Corpus.purs
View file @
2e681144
module Gargantext.Components.Nodes.Corpus where
module Gargantext.Components.Nodes.Corpus where
import Gargantext.Prelude
import Gargantext.Prelude
( Unit, bind, discard, pure, show, unit
( Unit, bind, discard, pure, show, unit
, compare
, ($), (+), (-), (<), (<$>), (<<<), (<>), (==), (>), class Show, class Eq)
, ($), (+), (-), (<), (<$>), (<<<), (<>), (==), (>), class Show, class Eq
, Ordering
)
import Data.Argonaut (class DecodeJson, decodeJson, encodeJson)
import Data.Argonaut (class DecodeJson, decodeJson, encodeJson)
import Data.Argonaut.Parser (jsonParser)
import Data.Argonaut.Parser (jsonParser)
import Data.Array as A
import Data.Array as A
...
@@ -34,8 +34,8 @@ import Gargantext.Data.Array as GDA
...
@@ -34,8 +34,8 @@ import Gargantext.Data.Array as GDA
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (SessionRoute(NodeAPI, Children, TreeFirstLevel), AppRoute(Home), appPath, nodeTypeAppRoute)
import Gargantext.Routes (SessionRoute(NodeAPI, Children, TreeFirstLevel), AppRoute(Home), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..), AffTableResult, SessionId)
import Gargantext.Types (NodeType(..), AffTableResult, SessionId
, fldr
)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..)
, fTreeID
)
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Gargantext.Utils.Toestand as T2
...
@@ -68,15 +68,32 @@ corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
...
@@ -68,15 +68,32 @@ corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
where
where
cpt { nodeId, key, session } _ = do
cpt { nodeId, key, session } _ = do
viewType <- T.useBox Folders
viewType <- T.useBox Folders
viewType' <- T.read viewType
pure $ H.div{} [
pure $ H.div{} [
H.div{} [viewTypeSelector {state: viewType} ]
H.div{} [viewTypeSelector {state: viewType} ]
, H.div{} [
renderContent viewType' nodeId session key
]
, H.div{} [
corpusLayoutSelection {state: viewType, key, session, nodeId}
]
]
]
renderContent Folders nodeId session key = folderViewLoad { nodeId, session }
type SelectionProps =
renderContent Code nodeId session key = corpusLayoutWithKey { key, nodeId, session }
( nodeId :: Int
, key :: String
, session :: Session
, state :: T.Box ViewType
)
corpusLayoutSelection :: R2.Leaf SelectionProps
corpusLayoutSelection props = R.createElement corpusLayoutSelectionCpt props []
corpusLayoutSelectionCpt :: R.Component SelectionProps
corpusLayoutSelectionCpt = here.component "corpusLayoutSelection" cpt where
cpt { nodeId, session, key, state} _ = do
state' <- T.useLive T.unequal state
viewType <- T.read state
pure $ renderContent viewType nodeId session key
renderContent Folders nodeId session key = folderViewLoad { nodeId, session }
renderContent Code nodeId session key = corpusLayoutWithKey { key, nodeId, session }
corpusLayoutWithKey :: R2.Leaf KeyProps
corpusLayoutWithKey :: R2.Leaf KeyProps
...
@@ -178,8 +195,9 @@ folderView props = R.createElement folderViewCpt props []
...
@@ -178,8 +195,9 @@ folderView props = R.createElement folderViewCpt props []
folderViewCpt :: R.Component FolderViewProps
folderViewCpt :: R.Component FolderViewProps
folderViewCpt = here.component "folderViewCpt" cpt where
folderViewCpt = here.component "folderViewCpt" cpt where
cpt {nodeId, session, folders: (NTree (LNode {parent_id: parentId}) (folders
S
))} _ = do
cpt {nodeId, session, folders: (NTree (LNode {parent_id: parentId}) (folders))} _ = do
let sid = sessionId session
let sid = sessionId session
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
...
@@ -197,6 +215,9 @@ folderViewCpt = here.component "folderViewCpt" cpt where
...
@@ -197,6 +215,9 @@ folderViewCpt = here.component "folderViewCpt" cpt where
[ folder {style: FolderUp, text: "..", nodeId: parentId, nodeType: FolderPrivate, sid: sid} [] ]
[ folder {style: FolderUp, text: "..", nodeId: parentId, nodeType: FolderPrivate, sid: sid} [] ]
makeParentFolder Nothing _ = []
makeParentFolder Nothing _ = []
sortFolders :: FTree -> FTree -> Ordering
sortFolders a b = compare (fTreeID a) (fTreeID b)
type FolderProps =
type FolderProps =
(
(
...
@@ -213,19 +234,14 @@ folder = R.createElement folderCpt
...
@@ -213,19 +234,14 @@ folder = R.createElement folderCpt
folderCpt :: R.Component FolderProps
folderCpt :: R.Component FolderProps
folderCpt = here.component "folderCpt" cpt where
folderCpt = here.component "folderCpt" cpt where
cpt {style, text, nodeId, sid, nodeType} _ = do
cpt {style, text, nodeId, sid, nodeType} _ = do
pure $ H.a {className: "btn btn-primary", href: "/#/" <> getFolderPath nodeType sid nodeId} [ H.i { className:
"fa " <> (icon style nodeType)
} []
pure $ H.a {className: "btn btn-primary", href: "/#/" <> getFolderPath nodeType sid nodeId} [ H.i { className:
icon style nodeType
} []
, H.br {}
, H.br {}
, H.text text]
, H.text text]
icon :: FolderStyle -> NodeType -> String
icon :: FolderStyle -> NodeType -> String
icon FolderUp _ = "fa-folder-open"
icon FolderUp _ = "fa fa-folder-open"
icon _ Dashboard = "fa-signal"
icon _ nodeType = fldr nodeType false
icon _ Texts = "fa-newspaper-o"
icon _ NodeList = "fa-list"
icon _ Graph = "fa-hubzilla"
icon _ NodeFile = "fa-file"
icon FolderChild _ = "fa-folder"
getFolderPath :: NodeType -> SessionId -> Int -> String
getFolderPath :: NodeType -> SessionId -> Int -> String
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
...
...
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