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
277ac340
Commit
277ac340
authored
Jan 24, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CodeEditor] allow to rename file names
parent
173a4d33
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
10 deletions
+87
-10
CodeEditor.css
dist/styles/CodeEditor.css
+14
-0
CodeEditor.sass
dist/styles/CodeEditor.sass
+11
-0
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+62
-10
No files found.
dist/styles/CodeEditor.css
View file @
277ac340
.code-editor-heading
{
display
:
flex
;
}
.code-editor-heading
.renameable
{
flex-grow
:
2
;
}
.code-editor-heading
.renameable
.text
{
padding-right
:
10px
;
}
.code-editor-heading
.buttons-right
{
display
:
flex
;
justify-content
:
flex-end
;
}
.code-editor
.toolbar
{
display
:
flex
;
justify-content
:
flex-start
;
...
...
dist/styles/CodeEditor.sass
View file @
277ac340
...
...
@@ -19,6 +19,17 @@
white-space
:
pre-wrap
word-break
:
keep-all
.code-editor-heading
display
:
flex
//justify-content: space-between
.renameable
flex-grow
:
2
.text
padding-right
:
10px
.buttons-right
display
:
flex
justify-content
:
flex-end
.code-editor
.toolbar
display
:
flex
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
277ac340
...
...
@@ -119,6 +119,7 @@ fieldsCodeEditorCpt = R.hooksComponent "G.C.N.C.fieldsCodeEditorCpt" cpt
fieldCodeEditorWrapper { field
, onChange: onChange fS idx
, onRemove: onRemove fS idx
, onRename: onRename fS idx
}) <$> fields
onChange :: R.State (Array FTFieldWithIndex) -> Index -> FieldType -> Effect Unit
...
...
@@ -135,11 +136,19 @@ fieldsCodeEditorCpt = R.hooksComponent "G.C.N.C.fieldsCodeEditorCpt" cpt
Nothing -> fields
Just newFields -> newFields
onRename :: R.State (Array FTFieldWithIndex) -> Index -> String -> Effect Unit
onRename (_ /\ setFields) idx newName = do
setFields $ \fields ->
case A.modifyAt idx (\(Tuple _ (Field f)) -> Tuple idx (Field $ f { name = newName })) fields of
Nothing -> fields
Just newFields -> newFields
type FieldCodeEditorProps =
(
field :: FTField
, onChange :: FieldType -> Effect Unit
, onRemove :: Unit -> Effect Unit
, onRename :: String -> Effect Unit
)
fieldCodeEditorWrapper :: Record FieldCodeEditorProps -> R.Element
...
...
@@ -148,15 +157,17 @@ fieldCodeEditorWrapper props = R.createElement fieldCodeEditorWrapperCpt props [
fieldCodeEditorWrapperCpt :: R.Component FieldCodeEditorProps
fieldCodeEditorWrapperCpt = R.hooksComponent "G.C.N.C.fieldCodeEditorWrapperCpt" cpt
where
cpt props@{field: Field {name, typ}, onRemove} _ = do
cpt props@{field: Field {name, typ}, onRemove
, onRename
} _ = do
pure $ H.div { className: "row panel panel-default" } [
H.div { className: "panel-heading" } [
H.span {} [ H.text name ]
, H.div { className: "pull-right" } [
H.div { className: "code-editor-heading" } [
renameable {onRename, text: name}
, H.div { className: "buttons-right" } [
H.div { className: "btn btn-danger"
, on: { click: \_ -> onRemove unit }
} [
H.span { className: "glyphicon glyphicon-minus" } [ ]
H.span { className: "glyphicon glyphicon-trash" } [ ]
]
]
]
]
...
...
@@ -165,6 +176,47 @@ fieldCodeEditorWrapperCpt = R.hooksComponent "G.C.N.C.fieldCodeEditorWrapperCpt"
]
]
type RenameableProps =
(
onRename :: String -> Effect Unit
, text :: String
)
renameable :: Record RenameableProps -> R.Element
renameable props = R.createElement renameableCpt props []
renameableCpt :: R.Component RenameableProps
renameableCpt = R.hooksComponent "G.C.N.C.renameableCpt" cpt
where
cpt {onRename, text} _ = do
isEditing <- R.useState' false
state <- R.useState' text
pure $ H.div { className: "renameable" } [
textCpt isEditing onRename state
]
textCpt :: R.State Boolean -> (String -> Effect Unit) -> R.State String -> R.Element
textCpt (false /\ setIsEditing) _ (text /\ _) = H.div {} [
H.span { className: "text" } [ H.text text ]
, H.span { className: "btn btn-default"
, on: { click: \_ -> setIsEditing $ const true } } [
H.span { className: "glyphicon glyphicon-pencil" } []
]
]
textCpt (true /\ setIsEditing) onRename (text /\ setText) = H.div {} [
H.input { defaultValue: text
, className: "form-control text"
, on: { change: \e -> setText $ const $ R2.unsafeEventValue e } }
, H.span { className: "btn btn-default"
, on: { click: \_ -> do
setIsEditing $ const false
onRename text
} } [
H.span { className: "glyphicon glyphicon-save" } []
]
]
fieldCodeEditor :: Record FieldCodeEditorProps -> R.Element
fieldCodeEditor props = R.createElement fieldCodeEditorCpt props []
...
...
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