Prevent unfolding of nodes without children

This commit is contained in:
Joscha 2020-02-09 11:44:25 +00:00
parent 909d587c53
commit 573a835022
4 changed files with 20 additions and 8 deletions

View file

@ -7,6 +7,7 @@ module Forest.Node
-- * Node
NodeId
, Node(..)
, hasChildren
, emptyNode
, initialNode
, applyId
@ -55,6 +56,9 @@ instance ToJSON Node where
instance FromJSON Node where
parseJSON = genericParseJSON nodeOptions
hasChildren :: Node -> Bool
hasChildren = not . Map.null . nodeChildren
emptyNode :: T.Text -> Bool -> Bool -> Bool -> Bool -> Node
emptyNode text edit delete reply act = Node text edit delete reply act Map.empty