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
6bc1e588
Commit
6bc1e588
authored
Mar 22, 2024
by
Fabien Manière
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding the current displayed/opened node in the opennodes store
parent
81263be4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+27
-3
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
6bc1e588
...
...
@@ -4,11 +4,14 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Array as Array
import Data.Maybe (Maybe(..), isJust)
import Data.Int (fromString)
import Data.Maybe (fromMaybe, Maybe(..), isJust)
import Data.String (Pattern(..), split)
import Data.Traversable (intercalate, traverse, traverse_)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Effect.Console as Console
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Store as Store
import Gargantext.Components.Bootstrap as B
...
...
@@ -33,10 +36,11 @@ import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, get, mkNodeId)
import Gargantext.Sessions.Types (useOpenNodesMemberBox, openNodesInsert, openNodesDelete)
import Gargantext.Sessions.Types (
OpenNodes,
useOpenNodesMemberBox, openNodesInsert, openNodesDelete)
import Gargantext.Types (Handed, ID, isPublic, publicize)
import Gargantext.Types as GT
import Gargantext.Utils ((?))
import Gargantext.Utils as GU
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
...
...
@@ -163,10 +167,24 @@ treeCpt = here.component "tree" cpt where
, tree: NTree (LNode { id, name, nodeType }) children } _ = do
boxes@{ forestOpen } <- Store.use
url <- R.unsafeHooksEffect GU.href
let nodeIdFromUrl = fromMaybe 0 $ fromString $ getLastUrlElement url
let currentNodeIdFromUrl = mkNodeId session nodeIdFromUrl
-- R.unsafeHooksEffect $ Console.log $ "id: " <> show id
-- R.unsafeHooksEffect $ Console.log $ "nodeIdFromUrl: " <> show nodeIdFromUrl
-- R.unsafeHooksEffect $ Console.log $ "forestOpen avant modification: " <> show forestOpen
R.unsafeHooksEffect $ T.modify_ (openNodesInsert (currentNodeIdFromUrl)) forestOpen
-- R.unsafeHooksEffect $ T.modify_ (openNodesInsert (mkNodeId session 2)) forestOpen
-- folderOpen <- useOpenNodesMemberBox currentNodeIdFromUrl forestOpen
-- let currentNodeId = if id == nodeIdFromUrl then currentNodeIdFromUrl else nodeId
isBoxVisible <- T.useBox false
folderOpen <- useOpenNodesMemberBox nodeId forestOpen
folderOpen' <- T.useLive T.unequal folderOpen
pure $
H.div
...
...
@@ -218,6 +236,10 @@ treeCpt = here.component "tree" cpt where
pub (LNode n@{ nodeType: t }) = LNode (n { nodeType = publicize t })
getLastUrlElement :: String -> String
getLastUrlElement str = fromMaybe "" $ A.last $ split (Pattern "/") str
blankTree :: R2.Leaf ()
blankTree = R2.leaf blankTreeCpt
...
...
@@ -334,8 +356,10 @@ addContact params { boxes: { errors }, session, tree: (NTree (LNode {id}) _) } =
addNode' name nodeType p@{ boxes: { errors, forestOpen }, session, tree: (NTree (LNode { id }) _) } = do
eId <- addNode session id $ AddNodeValue { name, nodeType }
-- here.log2 "id added: " $ show id
handleRESTError (R2.herePrefix here "[addNode']") errors eId $ \_id -> liftEffect $ do
liftEffect $ T.modify_ (openNodesInsert (mkNodeId session id)) forestOpen
liftEffect $ Console.log $ "id added: " <> show id
refreshTree p
uploadFile' nodeType fileType fileFormat lang mName contents p@{ boxes: { errors, tasks }, session, tree: (NTree (LNode { id }) _) } selection = do
...
...
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