Commit b6b19010 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] Tool: form edit

parent 406521d3
......@@ -8,7 +8,7 @@ import Effect.Aff (Aff)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node (SettingsBox(..), settingsBox)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton)
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, formEdit)
import Gargantext.Prelude (Unit, bind, const, map, pure, show, ($), (<>), (>), (<<<), read)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post)
......@@ -81,21 +81,10 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
]
where
SettingsBox {edit} = settingsBox nt
maybeEdit = [ if edit then
H.div {className: "form-group"}
[ H.input { type : "text"
, placeholder : "Node name"
, defaultValue: "Write Name here"
, className : "form-control"
, onInput : mkEffectFn1
$ setNodeName
<<< const
<<< R2.unsafeEventValue
}
]
else
H.div {} []
]
maybeEdit = [ if edit
then formEdit "Node Name" setNodeName
else H.div {} []
]
maybeChoose = [ if length nodeTypes > 1 then
R.fragment [
......
......@@ -2,6 +2,7 @@ module Gargantext.Components.Forest.Tree.Node.Tools where
import Data.String as S
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node.Action
......@@ -88,3 +89,35 @@ fragmentPT :: String -> R.Element
fragmentPT text = H.div {style: {margin: "10px"}} [H.text text]
-- | Edit input
-- form ::
-- formEdit :: forall a. String -> R.State a -> R.Element
type DefaultText = String
formEdit :: forall previous next
. DefaultText
-> ((previous -> String)
-> Effect next)
-> R.Element
formEdit defaultValue setter =
H.div {className: "form-group"}
[ H.input { type : "text"
, placeholder : defaultValue
, defaultValue: "Write" <> defaultValue
, className : "form-control"
, onInput : mkEffectFn1
$ setter
<<< const
<<< R2.unsafeEventValue
}
]
-- | Form
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