Commit 13f92554 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-prettyNodeType-form' of...

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