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
72378485
Commit
72378485
authored
Jul 09, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] unpublish public node is ok now
parent
5d754a86
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
10 deletions
+31
-10
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+10
-5
Delete.purs
...Gargantext/Components/Forest/Tree/Node/Action/Delete.purs
+10
-2
Settings.purs
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
+2
-2
FTree.purs
src/Gargantext/Components/Forest/Tree/Node/Tools/FTree.purs
+9
-1
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
72378485
...
...
@@ -18,7 +18,7 @@ import Gargantext.Components.Forest.Tree.Node (nodeMainSpan)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode)
import Gargantext.Components.Forest.Tree.Node.Action.Delete (deleteNode
, unpublishNode
)
import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Merge (mergeNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Link (linkNodeReq)
...
...
@@ -193,8 +193,9 @@ toHtml p@{ asyncTasks
<> childNodes ( Record.merge commonProps
{ asyncTasks
, children: if isPublic nodeType
then map (\t -> map (\(LNode {id:id',name:name',nodeType:nt})
-> (LNode {id:id',name:name',nodeType: publicize nt})) t) ary
then map (\t -> map (\(LNode n@{ nodeType:nt } )
-> (LNode (n { nodeType= publicize nt }))
) t) ary
else ary
, folderOpen
}
...
...
@@ -238,10 +239,14 @@ performAction :: Action
performAction (DeleteNode nt) p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload)
, session
, tree: (NTree (LNode {id}) _)
, tree: (NTree (LNode {id
, parent_id
}) _)
} =
do
void $ deleteNode session nt id
case nt of
GT.NodePublic GT.FolderPublic -> void $ deleteNode session nt id
GT.NodePublic _ -> void $ unpublishNode session parent_id id
_ -> void $ deleteNode session nt id
liftEffect $ setOpenNodes (Set.delete (mkNodeId session id))
performAction RefreshTree p
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Delete.purs
View file @
72378485
...
...
@@ -15,11 +15,19 @@ import Reactix.DOM.HTML as H
-- TODO Delete with asyncTaskWithType
deleteNode :: Session -> NodeType -> GT.ID -> Aff GT.ID
deleteNode session nt nodeId =
deleteNode session nt nodeId = delete session $ NodeAPI GT.Node (Just nodeId) ""
{-
case nt of
NodePublic FolderPublic -> delete session $ NodeAPI GT.Node (Just nodeId) ""
NodePublic _ -> put_ session $ NodeAPI GT.Node (Just nodeId) "unpublish"
NodePublic _ -> put_
session $ NodeAPI GT.Node (Just nodeId) "unpublish"
_ -> delete session $ NodeAPI GT.Node (Just nodeId) ""
-}
type ParentID = GT.ID
unpublishNode :: Session -> Maybe ParentID -> GT.ID -> Aff GT.ID
unpublishNode s p n = put_ s $ NodeAPI GT.Node p ("unpublish/" <> show n)
-- | Action : Delete
actionDelete :: NodeType -> (Action -> Aff Unit) -> R.Hooks R.Element
...
...
src/Gargantext/Components/Forest/Tree/Node/Settings.purs
View file @
72378485
...
...
@@ -221,8 +221,8 @@ settingsBox (NodePublic FolderPublic) =
SettingsBox { show : true
, edit : true
, doc : Documentation FolderPublic
, buttons : [
Delete
,
Add [FolderPublic]
, buttons : [
Add [FolderPublic]
,
Delete
]
}
...
...
src/Gargantext/Components/Forest/Tree/Node/Tools/FTree.purs
View file @
72378485
module Gargantext.Components.Forest.Tree.Node.Tools.FTree where
import Data.Maybe (Maybe(..))
import Data.Argonaut (class DecodeJson, decodeJson, (.:))
import Data.Newtype (class Newtype)
import Gargantext.Types as GT
...
...
@@ -21,6 +22,7 @@ instance ntreeFunctor :: Functor NTree where
newtype LNode = LNode { id :: ID
, name :: Name
, nodeType :: GT.NodeType
, parent_id :: Maybe ID
}
derive instance newtypeLNode :: Newtype LNode _
...
...
@@ -34,6 +36,7 @@ instance decodeJsonLNode :: DecodeJson LNode where
pure $ LNode { id : id_
, name
, nodeType
, parent_id : Nothing
}
instance decodeJsonFTree :: DecodeJson (NTree LNode) where
...
...
@@ -43,5 +46,10 @@ instance decodeJsonFTree :: DecodeJson (NTree LNode) where
nodes <- obj .: "children"
node' <- decodeJson node
nodes' <- decodeJson nodes
pure $ NTree node' nodes'
let (LNode {id}) = node'
pure $ NTree node' (map (addParent id) nodes')
addParent :: ID -> NTree LNode -> NTree LNode
addParent id (NTree (LNode p@{id:id'}) ary)=
NTree (LNode (p {parent_id=Just id}))
(map (addParent id') ary)
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