Commit 3f66f5fa authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT/Public] unpublished done

parent dd7ba4de
......@@ -33,7 +33,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (OpenNodes, Session, mkNodeId, get)
import Gargantext.Types (ID, Reload)
import Gargantext.Types (ID, Reload, isPublic, publicize)
import Gargantext.Types as GT
import Gargantext.Routes as GR
......@@ -192,7 +192,10 @@ toHtml p@{ asyncTasks
} ]
<> childNodes ( Record.merge commonProps
{ asyncTasks
, children: ary
, 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
else ary
, folderOpen
}
)
......@@ -232,13 +235,13 @@ type PerformActionProps =
performAction :: Action
-> Record PerformActionProps
-> Aff Unit
performAction DeleteNode p@{ openNodes: (_ /\ setOpenNodes)
performAction (DeleteNode nt) p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload)
, session
, tree: (NTree (LNode {id}) _)
} =
do
void $ deleteNode session id
void $ deleteNode session nt id
liftEffect $ setOpenNodes (Set.delete (mkNodeId session id))
performAction RefreshTree p
......
......@@ -20,7 +20,7 @@ type Props =
data Action = AddNode String GT.NodeType
| DeleteNode
| DeleteNode GT.NodeType
| RenameNode String
| UpdateNode UpdateNodeParams
| ShareTeam String
......@@ -52,7 +52,7 @@ setTreeOut a _ = a
instance showShow :: Show Action where
show (AddNode _ _ )= "AddNode"
show DeleteNode = "DeleteNode"
show (DeleteNode _ )= "DeleteNode"
show (RenameNode _ )= "RenameNode"
show (UpdateNode _ )= "UpdateNode"
show (ShareTeam _ )= "ShareTeam"
......@@ -69,7 +69,7 @@ instance showShow :: Show Action where
-----------------------------------------------------------------------
icon :: Action -> String
icon (AddNode _ _) = glyphiconNodeAction (Add [])
icon DeleteNode = glyphiconNodeAction Delete
icon (DeleteNode _) = glyphiconNodeAction Delete
icon (RenameNode _) = glyphiconNodeAction Config
icon (UpdateNode _) = glyphiconNodeAction Refresh
icon (ShareTeam _) = glyphiconNodeAction Share
......@@ -88,7 +88,7 @@ icon NoAction = "hand-o-right"
text :: Action -> String
text (AddNode _ _ )= "Add !"
text DeleteNode = "Delete !"
text (DeleteNode _ )= "Delete !"
text (RenameNode _ )= "Rename !"
text (UpdateNode _ )= "Update !"
text (ShareTeam _ )= "Share with team !"
......
......@@ -5,7 +5,7 @@ import Data.Maybe (Maybe(..))
import Gargantext.Prelude
import Effect.Aff (Aff)
import Gargantext.Types as GT
import Gargantext.Sessions (Session, delete)
import Gargantext.Sessions (Session, delete, put_)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Types (NodeType(..))
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
......@@ -14,8 +14,11 @@ import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel)
import Reactix.DOM.HTML as H
-- TODO Delete with asyncTaskWithType
deleteNode :: Session -> GT.ID -> Aff GT.ID
deleteNode session nodeId = delete session $ NodeAPI GT.Node (Just nodeId) ""
deleteNode :: Session -> NodeType -> GT.ID -> Aff GT.ID
deleteNode session nt nodeId =
case nt of
NodePublic _ -> put_ session $ NodeAPI GT.Node (Just nodeId) "unpublish"
_ -> delete session $ NodeAPI GT.Node (Just nodeId) ""
-- | Action : Delete
actionDelete :: NodeType -> (Action -> Aff Unit) -> R.Hooks R.Element
......@@ -29,7 +32,7 @@ actionDelete NodeUser _ = do
]
(H.div {} [])
actionDelete _ dispatch = do
actionDelete nt dispatch = do
pure $ panel [ H.div {style: {margin: "10px"}}
(map (\t -> H.p {} [H.text t])
[ "Are your sure you want to delete it ?"
......@@ -37,7 +40,7 @@ actionDelete _ dispatch = do
]
)
]
(submitButton DeleteNode dispatch)
(submitButton (DeleteNode nt) dispatch)
......
......@@ -192,7 +192,7 @@ settingsBox Texts =
settingsBox Graph =
SettingsBox { show : true
, edit : false
, edit : true
, doc : Documentation Graph
, buttons : [ Refresh
, Config
......@@ -202,6 +202,17 @@ settingsBox Graph =
]
}
settingsBox (NodePublic Graph) =
SettingsBox { show : true
, edit : true
, doc : Documentation Graph
, buttons : [ Download -- TODO as GEXF or JSON
, Delete
]
}
settingsBox NodeList =
SettingsBox { show : true
, edit : false
......
......@@ -154,6 +154,8 @@ data NodeType = NodeUser
-- TODO Optional Nodes
| NodeFrameWrite
| NodeFrameCalc
| NodePublic NodeType
derive instance eqNodeType :: Eq NodeType
......@@ -182,6 +184,7 @@ instance showNodeType :: Show NodeType where
show Texts = "NodeTexts"
show NodeFrameWrite = "NodeFrameWrite"
show NodeFrameCalc = "NodeFrameCalc"
show (NodePublic nt) = "NodePublic" <> show nt
instance readNodeType :: Read NodeType where
......@@ -207,6 +210,7 @@ instance readNodeType :: Read NodeType where
read "Annuaire" = Just Annuaire
read "NodeFrameWrite" = Just NodeFrameWrite
read "NodeFrameCalc" = Just NodeFrameCalc
-- TODO NodePublic read ?
read _ = Nothing
......@@ -251,10 +255,21 @@ fldr NodeFrameWrite false = "fa fa-file-text"
fldr NodeFrameCalc true = "fa fa-calculator"
fldr NodeFrameCalc false = "fa fa-calculator"
fldr (NodePublic nt) b = fldr nt b
fldr _ true = "fa fa-folder-open"
fldr _ false = "fa fa-folder-o"
publicize :: NodeType -> NodeType
publicize (NodePublic nt) = NodePublic nt
publicize nt = NodePublic nt
isPublic :: NodeType -> Boolean
isPublic (NodePublic _) = true
isPublic FolderPublic = true
isPublic _ = false
{-
------------------------------------------------------------
instance ordNodeType :: Ord NodeType where
......@@ -295,6 +310,7 @@ nodeTypePath Texts = "texts"
nodeTypePath Team = "team"
nodeTypePath NodeFrameWrite = "write"
nodeTypePath NodeFrameCalc = "calc"
nodeTypePath (NodePublic nt) = nodeTypePath nt
------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment