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
128
Issues
128
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
gargantext
purescript-gargantext
Commits
90f5ec44
Commit
90f5ec44
authored
Jan 23, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CodeEditor] add file functionality
parent
df5c9252
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+25
-4
No files found.
src/Gargantext/Components/Nodes/Corpus.purs
View file @
90f5ec44
module Gargantext.Components.Nodes.Corpus where
module Gargantext.Components.Nodes.Corpus where
import Data.Argonaut (class DecodeJson, encodeJson)
import Data.Argonaut (class DecodeJson, encodeJson)
import Data.Array
(head)
import Data.Array
as A
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, throwError)
import Effect.Aff (Aff, throwError)
import Effect.Exception (error)
import Effect.Exception (error)
...
@@ -47,10 +49,28 @@ corpusLayoutViewCpt :: R.Component ViewProps
...
@@ -47,10 +49,28 @@ corpusLayoutViewCpt :: R.Component ViewProps
corpusLayoutViewCpt = R.hooksComponent "G.C.N.C.corpusLayoutView" cpt
corpusLayoutViewCpt = R.hooksComponent "G.C.N.C.corpusLayoutView" cpt
where
where
cpt {corpus: (NodePoly {hyperdata: CorpusHyperdata {fields}}), nodeId, session} _ = do
cpt {corpus: (NodePoly {hyperdata: CorpusHyperdata {fields}}), nodeId, session} _ = do
pure $ H.div {}
fieldsS <- R.useState' fields
(corpusFieldCodeEditor {nodeId, session} <$> fields)
pure $ H.div {} [
H.div {} (corpusFieldCodeEditor {nodeId, session} <$> (fst fieldsS))
, H.div { className: "row" } [
H.div { className: "btn btn-default"
, on: { click: onClick fieldsS }
} [
H.span { className: "glyphicon glyphicon-plus" } [ ]
]
]
]
--H.iframe { src: gargMd , width: "100%", height: "100%", style: {"border-style": "none"}} []
--H.iframe { src: gargMd , width: "100%", height: "100%", style: {"border-style": "none"}} []
--gargMd = "https://hackmd.iscpif.fr/g9Aah4iwQtCayIzsKQjA0Q#"
--gargMd = "https://hackmd.iscpif.fr/g9Aah4iwQtCayIzsKQjA0Q#"
onClick (_ /\ setFieldsS) _ = do
setFieldsS $ \fieldsS -> A.snoc fieldsS $ CorpusField {
name: "New file"
, typ: Markdown {
tag: "MarkdownField"
, text: "# New file"
}
}
corpusFieldCodeEditor :: Record LoadProps -> CorpusField CorpusFieldType -> R.Element
corpusFieldCodeEditor :: Record LoadProps -> CorpusField CorpusFieldType -> R.Element
corpusFieldCodeEditor p (CorpusField {name, typ}) =
corpusFieldCodeEditor p (CorpusField {name, typ}) =
...
@@ -60,6 +80,7 @@ corpusFieldCodeEditor p (CorpusField {name, typ}) =
...
@@ -60,6 +80,7 @@ corpusFieldCodeEditor p (CorpusField {name, typ}) =
corpusFieldCodeEditor' typ
corpusFieldCodeEditor' typ
]
]
]
]
corpusFieldCodeEditor' :: CorpusFieldType -> R.Element
corpusFieldCodeEditor' :: CorpusFieldType -> R.Element
corpusFieldCodeEditor' (Markdown {text}) =
corpusFieldCodeEditor' (Markdown {text}) =
CE.codeEditor {code: text, defaultCodeType: CE.Markdown, onChange}
CE.codeEditor {code: text, defaultCodeType: CE.Markdown, onChange}
...
@@ -87,7 +108,7 @@ loadCorpus {nodeId, session} = do
...
@@ -87,7 +108,7 @@ loadCorpus {nodeId, session} = do
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session nodePolyRoute
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get session nodePolyRoute
corpusNode <- get session $ corpusNodeRoute corpusId ""
corpusNode <- get session $ corpusNodeRoute corpusId ""
defaultListIds <- (get session $ defaultListIdsRoute corpusId) :: forall a. DecodeJson a => AffTableResult (NodePoly a)
defaultListIds <- (get session $ defaultListIdsRoute corpusId) :: forall a. DecodeJson a => AffTableResult (NodePoly a)
case (head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
case (
A.
head defaultListIds.docs :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) ->
Just (NodePoly { id: defaultListId }) ->
pure {corpusId, corpusNode, defaultListId}
pure {corpusId, corpusNode, defaultListId}
Nothing ->
Nothing ->
...
...
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