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

[REFACT] Tool: form edit

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