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
5815ecba
Commit
5815ecba
authored
Jun 15, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] using fromChoiceSafe
parent
bced885a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
38 deletions
+20
-38
Add.purs
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
+0
-1
Upload.purs
...Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
+16
-32
Box.purs
src/Gargantext/Components/Forest/Tree/Node/Box.purs
+1
-1
Lang.purs
src/Gargantext/Components/Lang.purs
+3
-4
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Add.purs
View file @
5815ecba
...
...
@@ -87,7 +87,6 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
]
-- END Create Node
showConfig :: NodeType -> R.Element
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Upload.purs
View file @
5815ecba
module Gargantext.Components.Forest.Tree.Node.Action.Upload where
import Data.Maybe (Maybe(..), fromJust)
import Data.Maybe (Maybe(..), fromJust
, fromMaybe
)
import Data.Newtype (class Newtype)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
...
...
@@ -9,7 +9,7 @@ import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..), Props)
import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileType(..), UploadFileContents(..))
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT)
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT
, formChoiceSafe
)
import Gargantext.Components.Lang (Lang(..))
import Gargantext.Prelude (class Show, Unit, discard, bind, const, id, map, pure, show, unit, void, ($), read)
import Gargantext.Routes as GR
...
...
@@ -43,7 +43,7 @@ actionUpload _ _ _ _ =
data DroppedFile =
DroppedFile { contents :: UploadFileContents
, fileType :: Maybe FileType
, lang ::
Maybe
Lang
, lang :: Lang
}
type FileHash = String
...
...
@@ -63,8 +63,8 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
where
cpt {dispatch, id, nodeType} _ = do
mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing
fileType
:: R.State FileType <- R.useState'
CSV
lang
:: R.State (Maybe Lang) <- R.useState' (Just EN)
fileType
@(_ /\ setFileType) <- R.useState'
CSV
lang
@( _chosenLang /\ setLang) <- R.useState' EN
pure $
H.div {className:""}
...
...
@@ -76,21 +76,15 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
}
]
, H.div {className:"col-md-3 flex-space-around"}
[ R2.select {className: "form-control"
, on: {change: onChangeFileType fileType}
}
( map renderOptionFT [ CSV
, CSV_HAL
, WOS
, PresseRIS
]
)
[ formChoiceSafe [ CSV
, CSV_HAL
, WOS
, PresseRIS
] CSV setFileType
]
, H.div {className:"col-md-3 flex-space-around"}
[ R2.select { className: "form-control"
, on: {change: onChangeLang lang}
} (map renderOptionLang [EN, FR])
]
[ formChoiceSafe [EN, FR, No_extraction, Universal] EN setLang ]
]
, H.div { className : "panel-footer" }
...
...
@@ -102,7 +96,7 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
, id
, mFile
, nodeType
}
}
]
]
]
...
...
@@ -136,22 +130,12 @@ uploadFileViewCpt = R.hooksComponent "G.C.F.T.N.A.U.UploadFileView" cpt
$ read
$ R2.unsafeEventValue e
onChangeLang :: forall e
. R.State (Maybe Lang)
-> e
-> Effect Unit
onChangeLang (lang /\ setLang) e = do
setLang $ const
$ unsafePartial
$ read
$ R2.unsafeEventValue e
type UploadButtonProps =
( dispatch :: Action -> Aff Unit
, fileType :: R.State FileType
, id :: GT.ID
, lang :: R.State
(Maybe Lang)
, lang :: R.State
Lang
, mFile :: R.State (Maybe UploadFile)
, nodeType :: GT.NodeType
)
...
...
@@ -187,7 +171,7 @@ uploadButtonCpt = R.hooksComponent "G.C.F.T.N.A.U.uploadButton" cpt
liftEffect $ do
setMFile $ const $ Nothing
setFileType $ const $ CSV
setLang $ const $
Just
EN
setLang $ const $ EN
-- START File Type View
type FileTypeProps =
...
...
@@ -250,7 +234,7 @@ fileTypeViewCpt = R.hooksComponent "G.C.F.T.N.A.U.fileTypeView" cpt
onChange e l =
setDroppedFile $ const $ Just $ DroppedFile $ { contents
, fileType: read $ R2.unsafeEventValue e
, lang : read $ R2.unsafeEventValue l
, lang :
fromMaybe EN $
read $ R2.unsafeEventValue l
}
renderOption opt = H.option {} [ H.text $ show opt ]
...
...
src/Gargantext/Components/Forest/Tree/Node/Box.purs
View file @
5815ecba
...
...
@@ -146,7 +146,7 @@ nodeMainSpan p@{ dispatch, folderOpen, frontends, session } = R.createElement el
$ Just
$ DroppedFile { contents: (UploadFileContents contents)
, fileType: Just CSV
, lang :
Just
EN
, lang : EN
}
onDragOverHandler (_ /\ setIsDragOver) e = do
-- prevent redirection when file is dropped
...
...
src/Gargantext/Components/Lang.purs
View file @
5815ecba
...
...
@@ -15,9 +15,9 @@ allLangs = [ EN
data Lang = FR | EN | Universal | No_extraction
instance showLang :: Show Lang where
show FR = "FR"
show EN = "EN"
show Universal = "All"
show FR
= "FR"
show EN
= "EN"
show Universal
= "All"
show No_extraction = "Nothing"
derive instance eqLang :: Eq Lang
...
...
@@ -33,6 +33,5 @@ instance readLang :: Read Lang where
instance encodeJsonLang :: EncodeJson Lang where
encodeJson a = encodeJson (show a)
-- Language used for the landing page
data LandingLang = LL_EN | LL_FR
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