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
Show 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)
...
@@ -205,7 +205,7 @@ performAction { reload: (_ /\ setReload)
performAction p@{ reload: (_ /\ setReload)
performAction p@{ reload: (_ /\ setReload)
, session
, session
, tree: (NTree (LNode {id}) _) } (RenameNode name) = do
, 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 RefreshTree
performAction p@{ openNodes: (_ /\ setOpenNodes)
performAction p@{ openNodes: (_ /\ setOpenNodes)
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Rename.purs
View file @
88290311
...
@@ -5,13 +5,13 @@ import Data.Maybe (Maybe(..))
...
@@ -5,13 +5,13 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (mkEffectFn1)
import Prelude (Unit, bind, const, discard, pure, ($), (<<<))
import Prelude (Unit, bind, const, discard, pure, ($), (<<<)
, (<>)
)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Types (
NodeType, ID, Name
)
import Gargantext.Types (
ID
)
import Gargantext.Routes as GR
import Gargantext.Routes as GR
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Gargantext.Sessions (Session, get, put, post, delete)
import Gargantext.Sessions (Session, get, put, post, delete)
...
@@ -22,61 +22,68 @@ renameNode session renameNodeId =
...
@@ -22,61 +22,68 @@ renameNode session renameNodeId =
put session $ GR.NodeAPI GT.Node (Just renameNodeId) "rename"
put session $ GR.NodeAPI GT.Node (Just renameNodeId) "rename"
newtype RenameValue = RenameValue
newtype RenameValue = RenameValue
{
name :: Name
}
{
text :: String
}
instance encodeJsonRenameValue :: EncodeJson RenameValue where
instance encodeJsonRenameValue :: EncodeJson RenameValue where
encodeJson (RenameValue {
name
})
encodeJson (RenameValue {
text
})
= "r_name" :=
name
= "r_name" :=
text
~> jsonEmptyObject
~> jsonEmptyObject
-- | START Rename Box
-- | START Rename Box
type
Rename
BoxProps =
type
TextInput
BoxProps =
( id :: ID
( id :: ID
, dispatch :: Action -> Aff Unit
, dispatch :: Action -> Aff Unit
, name :: Name
, text :: String
, renameBoxOpen :: R.State Boolean
, isOpen :: R.State Boolean
, boxName :: String
, textAction :: String -> Action
)
)
renameBox :: Record RenameBoxProps -> R.Element
renameAction :: String -> Action
renameBox p@{ dispatch, renameBoxOpen: (true /\ setRenameBoxOpen) } = R.createElement el p []
renameAction newName = RenameNode newName
textInputBox :: Record TextInputBoxProps -> R.Element
textInputBox p@{ boxName, textAction, dispatch, isOpen: (true /\ setIsOpen) } = R.createElement el p []
where
where
el = R.hooksComponent
"RenameBox"
cpt
el = R.hooksComponent
(boxName <> "Box")
cpt
cpt {id,
name
} _ = do
cpt {id,
text
} _ = do
renameNodeName <- R.useState'
name
renameNodeName <- R.useState'
text
pure $ H.div {className: "from-group row-no-padding"}
pure $ H.div {className: "from-group row-no-padding"}
[
rename
Input renameNodeName
[
text
Input renameNodeName
,
renameBtn
renameNodeName
,
submitBtn
renameNodeName
, cancelBtn
, cancelBtn
]
]
where
where
rename
Input (_ /\ setRenameNodeName) =
text
Input (_ /\ setRenameNodeName) =
H.div {className: "col-md-8"}
H.div {className: "col-md-8"}
[ H.input { type: "text"
[ H.input { type: "text"
, placeholder:
"Rename Node"
, placeholder:
(boxName <> " Node")
, defaultValue:
name
, defaultValue:
text
, className: "form-control"
, 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"
H.a {className: "btn glyphitem glyphicon glyphicon-ok col-md-2 pull-left"
, type: "button"
, type: "button"
, onClick: mkEffectFn1 $ \_ -> do
, onClick: mkEffectFn1 $ \_ -> do
set
RenameBox
Open $ const false
set
Is
Open $ const false
launchAff $ dispatch
$ RenameNode newName
launchAff $ dispatch
( textAction newName )
, title: "
Rename
"
, title: "
Submit
"
} []
} []
cancelBtn =
cancelBtn =
H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove col-md-2 pull-left"
H.a {className: "btn text-danger glyphitem glyphicon glyphicon-remove col-md-2 pull-left"
, type: "button"
, type: "button"
, onClick: mkEffectFn1 $ \_ -> set
RenameBox
Open $ const false
, onClick: mkEffectFn1 $ \_ -> set
Is
Open $ const false
, title: "Cancel"
, title: "Cancel"
} []
} []
renameBox p@{ renameBox
Open: (false /\ _) } = R.createElement el p []
textInputBox p@{ boxName, is
Open: (false /\ _) } = R.createElement el p []
where
where
el = R.hooksComponent
"RenameBox"
cpt
el = R.hooksComponent
(boxName <> "Box")
cpt
cpt {
name
} _ = pure $ H.div {} []
cpt {
text
} _ = pure $ H.div {} []
-- END Rename Box
-- 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(..),
...
@@ -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 (Action(..), FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (NodePopup(..), addNodeView)
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.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.Update
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), uploadFileView, fileTypeView, uploadTermListView)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (DroppedFile(..), uploadFileView, fileTypeView, uploadTermListView)
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
import Gargantext.Components.Forest.Tree.Node.ProgressBar (asyncProgressBar, BarType(..))
...
@@ -402,9 +402,13 @@ nodePopupCpt :: R.Component NodePopupProps
...
@@ -402,9 +402,13 @@ nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
where
where
cpt p _ = do
cpt p _ = do
renameBoxOpen
<- R.useState' false
isOpen
<- R.useState' false
iframeRef <- R.useRef null
iframeRef <- R.useRef null
nodePopupState@(nodePopup /\ setNodePopup) <- R.useState' {action: Nothing, id: p.id, name: p.name, nodeType: p.nodeType}
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 }
search <- R.useState' $ defaultSearch { node_id = Just p.id }
pure $ H.div tooltipProps $
pure $ H.div tooltipProps $
[ H.div { className: "popup-container" }
[ H.div { className: "popup-container" }
...
@@ -416,7 +420,7 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
...
@@ -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]
, H.p {className: "text-primary center"} [H.text p.name]
]
]
]
]
, panelHeading
renameBoxOpen
p
, panelHeading
isOpen
p
, panelBody nodePopupState p
, panelBody nodePopupState p
, mPanelAction nodePopupState p search
, mPanelAction nodePopupState p search
]
]
...
@@ -435,14 +439,14 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
...
@@ -435,14 +439,14 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
--, style: { top: y - 65.0, left: x + 10.0 }
--, 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"}
H.div {className: "panel-heading"}
[ R2.row
[ R2.row
[ H.div {className: "col-md-8"}
[ 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"}
, 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.div {className: "col-md-1"}
[ H.a { "type" : "button"
[ H.a { "type" : "button"
, className: glyphicon "remove-circle"
, className: glyphicon "remove-circle"
...
@@ -456,12 +460,12 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
...
@@ -456,12 +460,12 @@ nodePopupCpt = R.hooksComponent "G.C.F.T.N.B.nodePopupView" cpt
SettingsBox {edit, doc, buttons} = settingsBox nodeType
SettingsBox {edit, doc, buttons} = settingsBox nodeType
editIcon :: R.State Boolean -> R.Element
editIcon :: R.State Boolean -> R.Element
editIcon (false /\ set
RenameBox
Open) =
editIcon (false /\ set
Is
Open) =
H.div {className : "col-md-1"}
H.div {className : "col-md-1"}
[ H.a { className: glyphicon "pencil"
[ H.a { className: glyphicon "pencil"
, id : "rename1"
, id : "rename1"
, title : "Rename"
, 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