Commit 914fc19b authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] Forest Tree Node Box -> actionSearch

parent 793d4013
...@@ -298,8 +298,7 @@ nodeActionsNodeListCpt = R.hooksComponent "G.C.F.T.N.B.nodeActionsNodeList" cpt ...@@ -298,8 +298,7 @@ nodeActionsNodeListCpt = R.hooksComponent "G.C.F.T.N.B.nodeActionsNodeList" cpt
] ]
type NodeListUpdateButtonProps = type NodeListUpdateButtonProps =
( ( listId :: GT.ListId
listId :: GT.ListId
, nodeId :: ID , nodeId :: ID
, nodeType :: GT.TabSubType GT.CTabNgramType , nodeType :: GT.TabSubType GT.CTabNgramType
, session :: Session , session :: Session
...@@ -315,8 +314,9 @@ nodeListUpdateButtonCpt = R.hooksComponent "G.C.F.T.N.B.nodeListUpdateButton" cp ...@@ -315,8 +314,9 @@ nodeListUpdateButtonCpt = R.hooksComponent "G.C.F.T.N.B.nodeListUpdateButton" cp
cpt { listId, nodeId, nodeType, session, triggerRefresh } _ = do cpt { listId, nodeId, nodeType, session, triggerRefresh } _ = do
enabled <- R.useState' true enabled <- R.useState' true
pure $ H.div { className: "update-button " <> if (fst enabled) then "enabled" else "disabled text-muted" } [ pure $ H.div { className: "update-button "
H.span { className: "fa fa-refresh" <> if (fst enabled) then "enabled" else "disabled text-muted"
} [ H.span { className: "fa fa-refresh"
, on: { click: onClick enabled } } [] , on: { click: onClick enabled } } []
] ]
where where
...@@ -360,8 +360,7 @@ type NodePopupProps = ...@@ -360,8 +360,7 @@ type NodePopupProps =
) )
type NodePopupS = type NodePopupS =
( ( action :: Maybe NodeAction
action :: Maybe NodeAction
, id :: ID , id :: ID
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
...@@ -476,7 +475,6 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt ...@@ -476,7 +475,6 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, session : p.session , session : p.session
} }
type ActionState = type ActionState =
( action :: Maybe NodeAction ( action :: Maybe NodeAction
, id :: ID , id :: ID
...@@ -484,7 +482,6 @@ type ActionState = ...@@ -484,7 +482,6 @@ type ActionState =
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
) )
type ButtonClickProps = type ButtonClickProps =
( action :: NodeAction ( action :: NodeAction
, state :: R.State (Record ActionState) , state :: R.State (Record ActionState)
...@@ -551,17 +548,34 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt ...@@ -551,17 +548,34 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
cpt {action: CopyFromCorpus, dispatch, id, nodeType, session} _ = do cpt {action: CopyFromCorpus, dispatch, id, nodeType, session} _ = do
pure $ copyFromCorpusView {dispatch, id, nodeType, session} pure $ copyFromCorpusView {dispatch, id, nodeType, session}
cpt {action: Link _} _ = pure $ fragmentPT "Soon, you will be able to link the corpus with your Annuaire (and reciprocally)." cpt {action: Link _} _ = pure $ fragmentPT $ "Soon, you will be able "
<> "to link the corpus with your Annuaire"
<> " (and reciprocally)."
cpt props@{action: SearchBox, search, session, dispatch, nodePopup} _ =
actionSearch search session dispatch nodePopup
cpt props@{action: SearchBox, search, session} _ = do cpt _ _ = do
pure $ H.div {} []
-- | Action : Search
actionSearch :: R.State Search
-> Session
-> (Action -> Aff Unit)
-> Maybe NodePopup
-> R.Hooks R.Element
actionSearch search session dispatch nodePopup =
pure $ R.fragment [ H.p {"style": {"margin" :"10px"}} pure $ R.fragment [ H.p {"style": {"margin" :"10px"}}
[ H.text $ "Search and create a private corpus with the search query as corpus name." ] [ H.text $ "Search and create a private "
, searchBar {langs: allLangs, onSearch: searchOn props, search, session} <> "corpus with the search query as corpus name." ]
, searchBar {langs: allLangs, onSearch: searchOn dispatch nodePopup, search, session}
] ]
where where
searchOn :: Record PanelActionProps -> GT.AsyncTaskWithType -> Effect Unit searchOn :: (Action -> Aff Unit)
searchOn {dispatch, nodePopup: p} task = do -> Maybe NodePopup
-> GT.AsyncTaskWithType
-> Effect Unit
searchOn dispatch p task = do
_ <- launchAff $ dispatch (SearchQuery task) _ <- launchAff $ dispatch (SearchQuery task)
-- close popup -- close popup
-- TODO -- TODO
...@@ -569,28 +583,8 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt ...@@ -569,28 +583,8 @@ panelActionCpt = R.hooksComponent "G.C.F.T.N.B.panelAction" cpt
pure unit pure unit
{-
cpt {action: Refresh, nodeType: GT.Graph, id, session} _ = do
pure $ H.div {className: "panel-footer"}
[ H.a { type: "button"
, className: "btn glyphicon glyphicon-trash"
, id: "delete"
, title: "Delete"
, on: {click: \_ -> post session (GR.GraphAPI id $ GT.asyncTaskTypePath GT.GraphT) {}
-- TODO pure $ GT.AsyncTaskWithType { task, typ: GT.GraphT }
}
}
[H.text " Yes, delete!"]
]
--}
cpt _ _ = do
pure $ H.div {} []
-- | Action : Delete -- | Action : Delete
actionDelete :: NodeType -> Dispatch -> R.Hooks R.Element actionDelete :: NodeType -> (Action -> Aff Unit) -> R.Hooks R.Element
actionDelete NodeUser _ = do actionDelete NodeUser _ = do
pure $ R.fragment [ pure $ R.fragment [
H.div {style: {margin: "10px"}} H.div {style: {margin: "10px"}}
...@@ -603,7 +597,12 @@ actionDelete NodeUser _ = do ...@@ -603,7 +597,12 @@ actionDelete NodeUser _ = do
actionDelete _ dispatch = do actionDelete _ dispatch = do
pure $ R.fragment [ pure $ R.fragment [
H.div {style: {margin: "10px"}} (map (\t -> H.p {} [H.text t]) ["Are your sure you want to delete it ?", "If yes, click again below."]) H.div {style: {margin: "10px"}}
(map (\t -> H.p {} [H.text t])
[ "Are your sure you want to delete it ?"
, "If yes, click again below."
]
)
, reallyDelete dispatch , reallyDelete dispatch
] ]
where where
...@@ -710,11 +709,11 @@ docOf GT.FolderShared = ["Soon, you will be able to build teams folders to shar ...@@ -710,11 +709,11 @@ docOf GT.FolderShared = ["Soon, you will be able to build teams folders to shar
docOf nodeType = ["More information on " <> show nodeType] docOf nodeType = ["More information on " <> show nodeType]
fragmentPT :: String -> R.Element
fragmentPT text = H.div {style: {margin: "10px"}} [H.text text] fragmentPT text = H.div {style: {margin: "10px"}} [H.text text]
-------------------- --------------------
-- | Iframes -- | Iframes
searchIframes :: Record NodePopupProps searchIframes :: Record NodePopupProps
-> R.State Search -> R.State Search
-> R.Ref (Nullable DOM.Element) -> R.Ref (Nullable DOM.Element)
...@@ -766,4 +765,3 @@ iframeWith url (search /\ setSearch) iframeRef = ...@@ -766,4 +765,3 @@ iframeWith url (search /\ setSearch) iframeRef =
Tuple (NQP.keyFromString "query") (Just (NQP.valueFromString term)) Tuple (NQP.keyFromString "query") (Just (NQP.valueFromString term))
] ]
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