Commit 971366ab authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] reading before action

parent e98216c2
...@@ -40,8 +40,8 @@ type CommonProps = ...@@ -40,8 +40,8 @@ type CommonProps =
) )
------------------------------------------------------------------------ ------------------------------------------------------------------------
type Props = ( root :: ID type Props = ( root :: ID
, asyncTasks :: R.State GAT.Storage , asyncTasks :: R.State GAT.Storage
| CommonProps | CommonProps
) )
...@@ -129,8 +129,7 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p [] ...@@ -129,8 +129,7 @@ loadedTreeView p = R.createElement loadedTreeViewCpt p []
------------------------------------------------------------------------ ------------------------------------------------------------------------
type ToHtmlProps = type ToHtmlProps =
( ( asyncTasks :: R.State GAT.Storage
asyncTasks :: R.State GAT.Storage
, tasks :: Record Tasks , tasks :: Record Tasks
, tree :: FTree , tree :: FTree
| CommonProps | CommonProps
...@@ -191,14 +190,14 @@ toHtml p@{ asyncTasks ...@@ -191,14 +190,14 @@ toHtml p@{ asyncTasks
type ChildNodesProps = type ChildNodesProps =
( asyncTasks :: R.State GAT.Storage ( asyncTasks :: R.State GAT.Storage
, children :: Array FTree , children :: Array FTree
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
| CommonProps | CommonProps
) )
childNodes :: Record ChildNodesProps -> Array R.Element childNodes :: Record ChildNodesProps -> Array R.Element
childNodes { children: [] } = [] childNodes { children: [] } = []
childNodes { folderOpen: (false /\ _) } = [] childNodes { folderOpen: (false /\ _) } = []
childNodes props@{ asyncTasks, children, reload } = childNodes props@{ asyncTasks, children, reload } =
map (\ctree@(NTree (LNode {id}) _) -> map (\ctree@(NTree (LNode {id}) _) ->
toHtml (Record.merge commonProps { asyncTasks toHtml (Record.merge commonProps { asyncTasks
...@@ -230,12 +229,10 @@ performAction DeleteNode p@{ openNodes: (_ /\ setOpenNodes) ...@@ -230,12 +229,10 @@ performAction DeleteNode p@{ openNodes: (_ /\ setOpenNodes)
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
do do
void $ deleteNode session id void $ deleteNode session id
liftEffect do liftEffect $ setOpenNodes (Set.delete (mkNodeId session id))
setOpenNodes (Set.delete (mkNodeId session id))
performAction RefreshTree p performAction RefreshTree p
------- -------
performAction (DoSearch task) { reload: (_ /\ setReload) performAction (DoSearch task) { reload: (_ /\ setReload)
, session , session
...@@ -260,9 +257,9 @@ performAction (UpdateNode task) { reload: (_ /\ setReload) ...@@ -260,9 +257,9 @@ performAction (UpdateNode task) { reload: (_ /\ setReload)
------- -------
performAction (RenameNode name) p@{ reload: (_ /\ setReload) performAction (RenameNode name) p@{ reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
do do
void $ rename session id $ RenameValue {text:name} void $ rename session id $ RenameValue {text:name}
performAction RefreshTree p performAction RefreshTree p
...@@ -285,8 +282,7 @@ performAction (AddNode name nodeType) p@{ openNodes: (_ /\ setOpenNodes) ...@@ -285,8 +282,7 @@ performAction (AddNode name nodeType) p@{ openNodes: (_ /\ setOpenNodes)
} = } =
do do
task <- addNode session id $ AddNodeValue {name, nodeType} task <- addNode session id $ AddNodeValue {name, nodeType}
liftEffect do liftEffect $ setOpenNodes (Set.insert (mkNodeId session id))
setOpenNodes (Set.insert (mkNodeId session id))
performAction RefreshTree p performAction RefreshTree p
------- -------
......
...@@ -94,7 +94,10 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el ...@@ -94,7 +94,10 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
, barType: Pie , barType: Pie
, corpusId: id , corpusId: id
, onFinish: const $ onTaskFinish t , onFinish: const $ onTaskFinish t
, session }) tasks) , session
}
) tasks
)
] ]
where where
SettingsBox {show: showBox} = settingsBox nodeType SettingsBox {show: showBox} = settingsBox nodeType
...@@ -143,7 +146,7 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el ...@@ -143,7 +146,7 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
$ Just $ Just
$ DroppedFile { contents: (UploadFileContents contents) $ DroppedFile { contents: (UploadFileContents contents)
, fileType: Just CSV , fileType: Just CSV
, lang: Just EN , lang : Just EN
} }
onDragOverHandler (_ /\ setIsDragOver) e = do onDragOverHandler (_ /\ setIsDragOver) e = do
-- prevent redirection when file is dropped -- prevent redirection when file is dropped
...@@ -227,12 +230,13 @@ nodeActionsCpt = R.hooksComponent "G.C.F.T.N.B.nodeActions" cpt ...@@ -227,12 +230,13 @@ nodeActionsCpt = R.hooksComponent "G.C.F.T.N.B.nodeActions" cpt
, nodeId: corpusId , nodeId: corpusId
, nodeType: GT.TabNgramType GT.CTabTerms , nodeType: GT.TabNgramType GT.CTabTerms
, session , session
, triggerRefresh: triggerRefresh refreshTree } , triggerRefresh: triggerRefresh refreshTree
}
cpt _ _ = do cpt _ _ = do
pure $ H.div {} [] pure $ H.div {} []
graphVersions session graphId = GraphAPI.graphVersions { graphId, session } graphVersions session graphId = GraphAPI.graphVersions { graphId, session }
triggerRefresh refreshTree = refreshTree triggerRefresh refreshTree = refreshTree
-- END nodeActions -- END nodeActions
...@@ -363,9 +367,15 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt ...@@ -363,9 +367,15 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
H.div {className: "panel-body flex-space-between"} H.div {className: "panel-body flex-space-between"}
[ H.p { "style": {"margin":"10px"}} [] [ H.p { "style": {"margin":"10px"}} []
, H.div { className: "flex-center"} , H.div { className: "flex-center"}
[buttonClick {action: doc, state: nodePopupState}] [ buttonClick { action: doc
, state: nodePopupState
}
]
, H.div {className: "flex-center"} , H.div {className: "flex-center"}
$ map (\t -> buttonClick {action: t, state: nodePopupState}) buttons $ map (\t -> buttonClick { action: t
, state : nodePopupState
}
) buttons
] ]
where where
SettingsBox {edit, doc, buttons} = settingsBox nodeType SettingsBox {edit, doc, buttons} = settingsBox nodeType
......
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