Commit e566f802 authored by Karen Konou's avatar Karen Konou

[Node team] invite multiple people without closing the modal

parent 6a0286f5
Pipeline #3631 failed with stage
...@@ -5,6 +5,7 @@ import Gargantext.Prelude ...@@ -5,6 +5,7 @@ import Gargantext.Prelude
import Data.Generic.Rep (class Generic) import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Data.Show.Generic (genericShow) import Data.Show.Generic (genericShow)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action)
import Gargantext.Components.Forest.Tree.Node.Action.Types as Action import Gargantext.Components.Forest.Tree.Node.Action.Types as Action
...@@ -16,11 +17,11 @@ import Gargantext.Sessions (Session, post) ...@@ -16,11 +17,11 @@ import Gargantext.Sessions (Session, post)
import Gargantext.Types (ID) import Gargantext.Types (ID)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.SimpleJSON as GUSJ import Gargantext.Utils.SimpleJSON as GUSJ
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Simple.JSON as JSON import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
...@@ -59,15 +60,16 @@ shareNodeCpt :: R.Component ShareNode ...@@ -59,15 +60,16 @@ shareNodeCpt :: R.Component ShareNode
shareNodeCpt = here.component "shareNode" cpt shareNodeCpt = here.component "shareNode" cpt
where where
cpt { dispatch, id } _ = do cpt { dispatch, id } _ = do
isOpen <- T.useBox true username' /\ username <- R2.useBox' ""
pure $ Tools.panel pure $ Tools.panel
[ Tools.textInputBox { boxAction: shareAction [ Tools.inviteInputBox { boxAction: shareAction
, boxName: "Share" , boxName: "Share"
, dispatch , dispatch
, id , id
, isOpen , text: "username"
, text: "username" } [] , username } []
] (H.div {} []) ] (H.div {} [H.text username'])
------------------------------------------------------------------------ ------------------------------------------------------------------------
publishNode :: R2.Component SubTreeParamsIn publishNode :: R2.Component SubTreeParamsIn
publishNode = R.createElement publishNodeCpt publishNode = R.createElement publishNodeCpt
......
...@@ -109,6 +109,61 @@ textInputBoxCpt = here.component "textInputBox" cpt where ...@@ -109,6 +109,61 @@ textInputBoxCpt = here.component "textInputBox" cpt where
launchAff_ $ dispatch (boxAction $ R.readRef ref) launchAff_ $ dispatch (boxAction $ R.readRef ref)
T.write_ false isOpen T.write_ false isOpen
type InviteInputBoxProps =
( id :: GT.ID
, dispatch :: Action -> Aff Unit
, text :: String
, boxName :: String
, boxAction :: String -> Action
, username :: T.Box String
)
inviteInputBox :: R2.Component InviteInputBoxProps
inviteInputBox = R.createElement inviteInputBoxCpt
inviteInputBoxCpt :: R.Component InviteInputBoxProps
inviteInputBoxCpt = here.component "textInputBox" cpt where
cpt { boxAction, boxName, dispatch, text, username } _ =
content <$> R.useRef text
where
content renameNodeNameRef =
H.div
{ className: "d-flex align-items-center" }
[
textInput renameNodeNameRef
,
B.wad_ [ "d-inline-block", "w-3" ]
,
submitBtn renameNodeNameRef
]
textInput renameNodeNameRef =
H.div
{}
[
inputWithEnter
{ autoFocus: true
, className: "form-control"
, defaultValue: text
, onBlur: R.setRef renameNodeNameRef
, onEnter: submit renameNodeNameRef
, onValueChanged: R.setRef renameNodeNameRef
, placeholder: (boxName <> " Node")
, type: "text"
}
]
submitBtn renameNodeNameRef =
B.iconButton
{ callback: submit renameNodeNameRef
, title: "Submit"
, name: "plus"
, elevation: Level1
}
submit ref _ = do
T.write_ ("Invited " <> R.readRef ref <> " to the team") username
launchAff_ $ dispatch (boxAction $ R.readRef ref)
type DefaultText = String type DefaultText = String
formEdit :: forall prev next formEdit :: forall prev next
......
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