Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
88290311
Commit
88290311
authored
Jun 06, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[COMPONENT] TextInputBox Action generic
parent
3aa8ee18
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
40 deletions
+51
-40
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+1
-1
Rename.purs
...Gargantext/Components/Forest/Tree/Node/Action/Rename.purs
+36
-29
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+14
-10
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
88290311
...
...
@@ -205,7 +205,7 @@ performAction { reload: (_ /\ setReload)
performAction p@{ reload: (_ /\ setReload)
, session
, tree: (NTree (LNode {id}) _) } (RenameNode name) = do
void $ renameNode session id $ RenameValue {name}
void $ renameNode session id $ RenameValue {
text:
name}
performAction p RefreshTree
performAction p@{ openNodes: (_ /\ setOpenNodes)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Rename.purs
View file @
88290311
...
...
@@ -5,13 +5,13 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
import Prelude (Unit, bind, const, discard, pure, ($), (<<<))
import Prelude (Unit, bind, const, discard, pure, ($), (<<<)
, (<>)
)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Types as GT
import Gargantext.Types (
NodeType, ID, Name
)
import Gargantext.Types (
ID
)
import Gargantext.Routes as GR
import Gargantext.Utils.Reactix as R2
import Gargantext.Sessions (Session, get, put, post, delete)
...
...
@@ -22,61 +22,68 @@ renameNode session renameNodeId =
put session $ GR.NodeAPI GT.Node (Just renameNodeId) "rename"
newtype RenameValue = RenameValue
{
name :: Name
}
{
text :: String
}
instance encodeJsonRenameValue :: EncodeJson RenameValue where
encodeJson (RenameValue {
name
})
= "r_name" :=
name
encodeJson (RenameValue {
text
})
= "r_name" :=
text
~> jsonEmptyObject
-- | START Rename Box
type RenameBoxProps =
( id :: ID
, dispatch :: Action -> Aff Unit
, name :: Name
, renameBoxOpen :: R.State Boolean
type TextInputBoxProps =
( id :: ID
, dispatch :: Action -> Aff Unit
, text :: String
, isOpen :: R.State Boolean
, boxName :: String
, textAction :: String -> Action
)
renameBox :: Record RenameBoxProps -> R.Element
renameBox p@{ dispatch, renameBoxOpen: (true /\ setRenameBoxOpen) } = R.createElement el p []
renameAction :: String -> Action
renameAction newName = RenameNode newName
textInputBox :: Record TextInputBoxProps -> R.Element
textInputBox p@{ boxName, textAction, dispatch, isOpen: (true /\ setIsOpen) } = R.createElement el p []
where
el = R.hooksComponent
"RenameBox"
cpt
cpt {id,
name
} _ = do
renameNodeName <- R.useState'
name
el = R.hooksComponent
(boxName <> "Box")
cpt
cpt {id,
text
} _ = do
renameNodeName <- R.useState'
text
pure $ H.div {className: "from-group row-no-padding"}
[
rename
Input renameNodeName
,
renameBtn
renameNodeName
[
text
Input renameNodeName
,
submitBtn
renameNodeName
, cancelBtn
]
where
rename
Input (_ /\ setRenameNodeName) =
text
Input (_ /\ setRenameNodeName) =
H.div {className: "col-md-8"}
[ H.input { type: "text"
, placeholder:
"Rename Node"
, defaultValue:
name
, placeholder:
(boxName <> " Node")
, defaultValue:
text
, className: "form-control"
, onInput: mkEffectFn1 $ setRenameNodeName <<< const <<< R2.unsafeEventValue
, onInput: mkEffectFn1 $ setRenameNodeName
<<< const
<<< R2.unsafeEventValue
}
]
rename
Btn (newName /\ _) =
submit
Btn (newName /\ _) =
H.a {className: "btn glyphitem glyphicon glyphicon-ok col-md-2 pull-left"
, type: "button"
, onClick: mkEffectFn1 $ \_ -> do
set
RenameBox
Open $ const false
launchAff $ dispatch
$ RenameNode newName
, title: "
Rename
"
set
Is
Open $ const false
launchAff $ dispatch
( textAction newName )
, title: "
Submit
"
} []
cancelBtn =
H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove col-md-2 pull-left"
, type: "button"
, onClick: mkEffectFn1 $ \_ -> set
RenameBox
Open $ const false
, onClick: mkEffectFn1 $ \_ -> set
Is
Open $ const false
, title: "Cancel"
} []
renameBox p@{ renameBox
Open: (false /\ _) } = R.createElement el p []
textInputBox p@{ boxName, is
Open: (false /\ _) } = R.createElement el p []
where
el = R.hooksComponent
"RenameBox"
cpt
cpt {
name
} _ = pure $ H.div {} []
el = R.hooksComponent
(boxName <> "Box")
cpt
cpt {
text
} _ = pure $ H.div {} []
-- END Rename Box
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
88290311
...
...
@@ -28,7 +28,7 @@ import Gargantext.Components.Forest.Tree.Node (NodeAction(..), SettingsBox(..),
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
import Gargantext.Components.Forest.Tree.Node.Action.CopyFrom (copyFromCorpusView)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (
renameBox
)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (
textInputBox, renameAction
)
import Gargantext.Components.Forest.Tree.Node.Action.Update
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), uploadFileView, fileTypeView, uploadTermListView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
...
...
@@ -402,9 +402,13 @@ nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
where
cpt p _ = do
renameBoxOpen <- R.useState' false
iframeRef <- R.useRef null
nodePopupState@(nodePopup /\ setNodePopup) <- R.useState' {action: Nothing, id: p.id, name: p.name, nodeType: p.nodeType}
isOpen <- R.useState' false
iframeRef <- R.useRef null
nodePopupState@(nodePopup /\ setNodePopup) <- R.useState' { action: Nothing
, id: p.id
, name: p.name
, nodeType: p.nodeType
}
search <- R.useState' $ defaultSearch { node_id = Just p.id }
pure $ H.div tooltipProps $
[ H.div { className: "popup-container" }
...
...
@@ -416,7 +420,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
, H.p {className: "text-primary center"} [H.text p.name]
]
]
, panelHeading
renameBoxOpen
p
, panelHeading
isOpen
p
, panelBody nodePopupState p
, mPanelAction nodePopupState p search
]
...
...
@@ -435,14 +439,14 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
--, style: { top: y - 65.0, left: x + 10.0 }
}
panelHeading
renameBox
Open@(open /\ _) {dispatch, id, name, nodeType} =
panelHeading
is
Open@(open /\ _) {dispatch, id, name, nodeType} =
H.div {className: "panel-heading"}
[ R2.row
[ H.div {className: "col-md-8"}
[
renameBox { dispatch, id, name, renameBox
Open } ]
[
textInputBox { textAction: renameAction, boxName: "Rename", dispatch, id, text:name, is
Open } ]
, H.div {className: "flex-end"}
[ if edit then editIcon
renameBox
Open else H.div {} []
[ if edit then editIcon
is
Open else H.div {} []
, H.div {className: "col-md-1"}
[ H.a { "type" : "button"
, className: glyphicon "remove-circle"
...
...
@@ -456,12 +460,12 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
SettingsBox {edit, doc, buttons} = settingsBox nodeType
editIcon :: R.State Boolean -> R.Element
editIcon (false /\ set
RenameBox
Open) =
editIcon (false /\ set
Is
Open) =
H.div {className : "col-md-1"}
[ H.a { className: glyphicon "pencil"
, id : "rename1"
, title : "Rename"
, on: { click: \_ -> set
RenameBox
Open $ const true }
, on: { click: \_ -> set
Is
Open $ const true }
}
[]
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment