Commit 19f72f96 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[node] action: fix node name from type when adding new node

parent 60b44ab5
...@@ -72,8 +72,11 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p [] ...@@ -72,8 +72,11 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
let let
SettingsBox {edit} = settingsBox nt SettingsBox {edit} = settingsBox nt
setNodeType' nt = do
setNodeName $ const $ GT.prettyNodeType nt
setNodeType $ const nt
(maybeChoose /\ nt') = if length nodeTypes > 1 (maybeChoose /\ nt') = if length nodeTypes > 1
then ([ formChoiceSafe nodeTypes Error setNodeType ] /\ nt) then ([ formChoiceSafe nodeTypes Error setNodeType' ] /\ nt)
else ([H.div {} [H.text $ "Creating a node of type " else ([H.div {} [H.text $ "Creating a node of type "
<> show defaultNt <> show defaultNt
<> " with name:" <> " with name:"
......
...@@ -3,16 +3,18 @@ module Gargantext.Components.Forest.Tree.Node.Action.Update where ...@@ -3,16 +3,18 @@ module Gargantext.Components.Forest.Tree.Node.Action.Update where
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Update.Types import Gargantext.Components.Forest.Tree.Node.Action.Update.Types
import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe, submitButton, panel) import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe, submitButton, panel)
import Gargantext.Types (NodeType(..), ID) import Gargantext.Types (NodeType(..), ID)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Prelude (Unit, bind, ($), pure)
import Gargantext.Sessions (Session, post) import Gargantext.Sessions (Session, post)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Reactix as R
import Reactix.DOM.HTML as H
updateRequest :: UpdateNodeParams -> Session -> ID -> Aff GT.AsyncTaskWithType updateRequest :: UpdateNodeParams -> Session -> ID -> Aff GT.AsyncTaskWithType
...@@ -28,29 +30,41 @@ update :: NodeType ...@@ -28,29 +30,41 @@ update :: NodeType
-> R.Hooks R.Element -> R.Hooks R.Element
update NodeList dispatch = do update NodeList dispatch = do
meth @( methodList /\ setMethod ) <- R.useState' Basic meth @( methodList /\ setMethod ) <- R.useState' Basic
let setMethod' = setMethod <<< const
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [Basic, Advanced, WithModel] Basic setMethod formChoiceSafe [Basic, Advanced, WithModel] Basic setMethod'
] ]
(submitButton (UpdateNode $ UpdateNodeParamsList {methodList}) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsList {methodList}) dispatch)
update Graph dispatch = do update Graph dispatch = do
meth @( methodGraph /\ setMethod ) <- R.useState' Order1 meth @( methodGraph /\ setMethod ) <- R.useState' Order1
let setMethod' = setMethod <<< const
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [Order1, Order2] Order1 setMethod formChoiceSafe [Order1, Order2] Order1 setMethod'
] ]
(submitButton (UpdateNode $ UpdateNodeParamsGraph {methodGraph}) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsGraph {methodGraph}) dispatch)
update Texts dispatch = do update Texts dispatch = do
meth @( methodTexts /\ setMethod ) <- R.useState' NewNgrams meth @( methodTexts /\ setMethod ) <- R.useState' NewNgrams
let setMethod' = setMethod <<< const
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [NewNgrams, NewTexts, Both] NewNgrams setMethod formChoiceSafe [NewNgrams, NewTexts, Both] NewNgrams setMethod'
] ]
(submitButton (UpdateNode $ UpdateNodeParamsTexts {methodTexts}) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsTexts {methodTexts}) dispatch)
update Dashboard dispatch = do update Dashboard dispatch = do
meth @( methodBoard /\ setMethod ) <- R.useState' All meth @( methodBoard /\ setMethod ) <- R.useState' All
let setMethod' = setMethod <<< const
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [All, Sources, Authors, Institutes, Ngrams] All setMethod formChoiceSafe [All, Sources, Authors, Institutes, Ngrams] All setMethod'
] ]
(submitButton (UpdateNode $ UpdateNodeParamsBoard {methodBoard}) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsBoard {methodBoard}) dispatch)
......
...@@ -80,6 +80,9 @@ uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt ...@@ -80,6 +80,9 @@ uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt
fileType@(_ /\ setFileType) <- R.useState' CSV fileType@(_ /\ setFileType) <- R.useState' CSV
lang@( _chosenLang /\ setLang) <- R.useState' EN lang@( _chosenLang /\ setLang) <- R.useState' EN
let setFileType' = setFileType <<< const
let setLang' = setLang <<< const
let bodies = let bodies =
[ R2.row [ R2.row
[ H.div { className:"col-12 flex-space-around"} [ H.div { className:"col-12 flex-space-around"}
...@@ -99,12 +102,12 @@ uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt ...@@ -99,12 +102,12 @@ uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt
, WOS , WOS
, PresseRIS , PresseRIS
, Arbitrary , Arbitrary
] CSV setFileType ] CSV setFileType'
] ]
] ]
, R2.row , R2.row
[ H.div {className:"col-6 flex-space-around"} [ H.div {className:"col-6 flex-space-around"}
[ formChoiceSafe [EN, FR, No_extraction, Universal] EN setLang ] [ formChoiceSafe [EN, FR, No_extraction, Universal] EN setLang' ]
] ]
] ]
......
...@@ -144,7 +144,8 @@ formChoiceSafe :: forall a b c ...@@ -144,7 +144,8 @@ formChoiceSafe :: forall a b c
=> Show a => Show a
=> Array a => Array a
-> a -> a
-> ((b -> a) -> Effect c) -> (a -> Effect c)
-- -> ((b -> a) -> Effect c)
-> R.Element -> R.Element
formChoiceSafe [] _ _ = H.div {} [] formChoiceSafe [] _ _ = H.div {} []
...@@ -160,16 +161,13 @@ formChoice :: forall a b c d ...@@ -160,16 +161,13 @@ formChoice :: forall a b c d
=> Show d => Show d
=> Array d => Array d
-> b -> b
-> ((c -> b) -> Effect a) -> (b -> Effect a)
-- -> ((c -> b) -> Effect a)
-> R.Element -> R.Element
formChoice nodeTypes defaultNodeType setNodeType = formChoice nodeTypes defaultNodeType setNodeType =
H.div { className: "form-group"} H.div { className: "form-group"}
[ R2.select { className: "form-control" [ R2.select { className: "form-control"
, on: { change: setNodeType , on: { change: \e -> setNodeType $ fromMaybe defaultNodeType $ read $ R.unsafeEventValue e }
<<< const
<<< fromMaybe defaultNodeType
<<< read
<<< R.unsafeEventValue }
} }
(map (\opt -> H.option {} [ H.text $ show opt ]) nodeTypes) (map (\opt -> H.option {} [ H.text $ show opt ]) nodeTypes)
] ]
...@@ -179,7 +177,8 @@ formChoice nodeTypes defaultNodeType setNodeType = ...@@ -179,7 +177,8 @@ formChoice nodeTypes defaultNodeType setNodeType =
formButton :: forall a b c formButton :: forall a b c
. Show a . Show a
=> a => a
-> ((b -> a) -> Effect c) -> (a -> Effect c)
-- -> ((b -> a) -> Effect c)
-> R.Element -> R.Element
formButton nodeType setNodeType = formButton nodeType setNodeType =
H.div {} [ H.text $ "Confirm the selection of: " <> show nodeType H.div {} [ H.text $ "Confirm the selection of: " <> show nodeType
...@@ -190,7 +189,7 @@ formButton nodeType setNodeType = ...@@ -190,7 +189,7 @@ formButton nodeType setNodeType =
, type : "button" , type : "button"
, title: "Form Button" , title: "Form Button"
, style : { width: "100%" } , style : { width: "100%" }
, on: { click: \_ -> setNodeType ( const nodeType ) } , on: { click: \_ -> setNodeType nodeType }
} [H.text $ "Confirmation"] } [H.text $ "Confirmation"]
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
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