Commit 2f8dcb1c authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-enter-confirmation' of...

Merge branch 'dev-enter-confirmation' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents ab329453 abcb71f3
...@@ -4,17 +4,20 @@ import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>)) ...@@ -4,17 +4,20 @@ import Data.Argonaut (class EncodeJson, jsonEmptyObject, (:=), (~>))
import Data.Array (head, length) import Data.Array (head, length)
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff, launchAff_)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.Forest.Tree.Node.Settings (SettingsBox(..), settingsBox) import Gargantext.Components.Forest.Tree.Node.Settings (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, formEdit, formChoiceSafe, panel) import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, formChoiceSafe, panel)
import Gargantext.Prelude (Unit, bind, pure, show, ($), (<>), (>)) import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post) import Gargantext.Sessions (Session, post)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Types (NodeType(..)) import Gargantext.Types (NodeType(..))
import Reactix as R
import Reactix.DOM.HTML as H
---------------------------------------------------------------------- ----------------------------------------------------------------------
addNode :: Session -> GT.ID -> AddNodeValue -> Aff (Array GT.ID) addNode :: Session -> GT.ID -> AddNodeValue -> Aff (Array GT.ID)
...@@ -76,7 +79,15 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p [] ...@@ -76,7 +79,15 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
where where
defaultNt = (fromMaybe Error $ head nodeTypes) defaultNt = (fromMaybe Error $ head nodeTypes)
maybeEdit = [ if edit maybeEdit = [ if edit
then formEdit name' setNodeName then inputWithEnter {
onEnter: \_ -> launchAff_ $ dispatch (AddNode name' nt')
, onValueChanged: \val -> setNodeName $ const val
, autoFocus: true
, className: "form-control"
, defaultValue: name'
, placeholder: name'
, type: "text"
}
else H.div {} [] else H.div {} []
] ]
......
...@@ -128,7 +128,7 @@ formEdit defaultValue setter = ...@@ -128,7 +128,7 @@ formEdit defaultValue setter =
H.div {className: "form-group"} H.div {className: "form-group"}
[ H.input { type : "text" [ H.input { type : "text"
, placeholder : defaultValue , placeholder : defaultValue
, defaultValue: "Write" <> defaultValue , defaultValue: defaultValue
, className : "form-control" , className : "form-control"
, on: { input: setter , on: { input: setter
<<< const <<< const
......
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