Commit 565c8b01 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] lightning the code

parent 28993230
...@@ -27,7 +27,6 @@ import Gargantext.Database.Prelude (Cmd) ...@@ -27,7 +27,6 @@ import Gargantext.Database.Prelude (Cmd)
import Gargantext.Database.Query.Table.Node import Gargantext.Database.Query.Table.Node
import Gargantext.Database.Query.Table.Node.Error import Gargantext.Database.Query.Table.Node.Error
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata) import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import Gargantext.Viz.Graph (defaultHyperdataGraph)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Prelude.Utils (sha) import Gargantext.Prelude.Utils (sha)
import Gargantext.Database.Prelude import Gargantext.Database.Prelude
...@@ -50,63 +49,14 @@ mkNodeWithParent NodeUser Nothing uId name = ...@@ -50,63 +49,14 @@ mkNodeWithParent NodeUser Nothing uId name =
mkNodeWithParent _ Nothing _ _ = nodeError HasParent mkNodeWithParent _ Nothing _ _ = nodeError HasParent
------------------------------------------------------------------------ ------------------------------------------------------------------------
mkNodeWithParent NodeFolder (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
where
hd = defaultHyperdataFolder
mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
where
hd = defaultHyperdataFolder
mkNodeWithParent NodeFolderShared (Just i) uId _ =
insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
where
hd = defaultHyperdataFolder
mkNodeWithParent NodeFolderPublic (Just i) uId _ =
insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
where
hd = defaultHyperdataFolder
mkNodeWithParent NodeTeam (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
where
hd = defaultHyperdataFolder
------------------------------------------------------------------------
mkNodeWithParent NodeCorpus (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
where
hd = defaultHyperdataCorpus
mkNodeWithParent NodeAnnuaire (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
where
hd = defaultHyperdataAnnuaire
mkNodeWithParent NodeList (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
where
hd = defaultHyperdataAnnuaire
mkNodeWithParent NodeGraph (Just i) uId name =
insertNodesWithParentR (Just i) [node NodeGraph name hd Nothing uId]
where
hd = defaultHyperdataGraph
mkNodeWithParent NodeFrameWrite i u n = mkNodeWithParent NodeFrameWrite i u n =
mkNodeWithParent_ConfigureHyperdata NodeFrameWrite i u n mkNodeWithParent_ConfigureHyperdata NodeFrameWrite i u n
mkNodeWithParent NodeFrameCalc i u n = mkNodeWithParent NodeFrameCalc i u n =
mkNodeWithParent_ConfigureHyperdata NodeFrameCalc i u n mkNodeWithParent_ConfigureHyperdata NodeFrameCalc i u n
{- mkNodeWithParent nt (Just pId) uId name = insertNode nt (Just name) Nothing pId uId
mkNodeWithParent n (Just i) uId name = -- mkNodeWithParent _ _ _ _ = errorMsg "[G.D.A.Node.mkNodeWithParent] nees parent"
insertNodesWithParentR (Just i) [node NodeDashboard name (hasDefaultData n) Nothing uId]
-}
mkNodeWithParent _ _ _ _ = nodeError NotImplYet
-- | Sugar to create a node, get his NodeId and update his Hyperdata after -- | Sugar to create a node, get his NodeId and update his Hyperdata after
......
...@@ -63,6 +63,11 @@ instance Show NodeError ...@@ -63,6 +63,11 @@ instance Show NodeError
class HasNodeError e where class HasNodeError e where
_NodeError :: Prism' e NodeError _NodeError :: Prism' e NodeError
errorMsg :: ( MonadError e m
, HasNodeError e)
=> Text -> m a
errorMsg = msg
msg :: ( MonadError e m msg :: ( MonadError e m
, HasNodeError e) , HasNodeError e)
=> Text -> m a => Text -> m a
......
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