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
3bcb795f
Unverified
Commit
3bcb795f
authored
Jun 18, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NgramsTable,Document,Annotations: refactoring
parent
f5c6e917
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
560 additions
and
512 deletions
+560
-512
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+4
-9
Menu.purs
src/Gargantext/Components/Annotation/Menu.purs
+11
-12
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+15
-490
Core.purs
src/Gargantext/Components/NgramsTable/Core.purs
+529
-0
Document.purs
src/Gargantext/Pages/Corpus/Document.purs
+1
-1
No files found.
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
3bcb795f
...
@@ -14,22 +14,18 @@ module Gargantext.Components.Annotation.AnnotatedField where
...
@@ -14,22 +14,18 @@ module Gargantext.Components.Annotation.AnnotatedField where
import Prelude
import Prelude
import Data.Map as Map
import Data.Map as Map
import Data.Maybe ( Maybe(..), maybe, maybe' )
import Data.Maybe ( Maybe(..), maybe, maybe' )
import Data.Lens ( Lens', lens )
import Data.Traversable ( traverse_ )
import Data.Tuple ( Tuple(..) )
import Data.Tuple ( Tuple(..) )
import Data.Tuple.Nested ( (/\) )
import Data.Tuple.Nested ( (/\) )
import DOM.Simple.Console
import DOM.Simple.Event as DE
import DOM.Simple.Event as DE
import Effect ( Effect )
import Effect ( Effect )
import Effect.Uncurried (
mkEffectFn1
)
import Effect.Uncurried (
mkEffectFn1
)
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as HTML
import Reactix.DOM.HTML as HTML
import Reactix.SyntheticEvent as E
import Reactix.SyntheticEvent as E
import Gargantext.Types ( TermList
(..)
)
import Gargantext.Types ( TermList )
import Gargantext.Components.Annotation.Utils ( termClass )
import Gargantext.Components.Annotation.Utils ( termClass )
import Gargantext.Components.NgramsTable ( NgramsTable(..), highlightNgrams )
import Gargantext.Components.NgramsTable.Core ( NgramsTable(..), highlightNgrams )
import Gargantext.Components.ContextMenu.ContextMenu as CM
import Gargantext.Components.Annotation.Menu ( AnnotationMenu, annotationMenu )
import Gargantext.Components.Annotation.Menu ( AnnotationMenu, annotationMenu )
import Gargantext.Utils.Selection as Sel
import Gargantext.Utils.Selection as Sel
...
@@ -68,8 +64,7 @@ compile props = runs props.text
...
@@ -68,8 +64,7 @@ compile props = runs props.text
where runs = maybe [] (highlightNgrams props.ngrams)
where runs = maybe [] (highlightNgrams props.ngrams)
maybeShowMenu
maybeShowMenu
:: forall t
:: (Maybe AnnotationMenu -> Effect Unit)
. (Maybe AnnotationMenu -> Effect Unit)
-> NgramsTable
-> NgramsTable
-> E.SyntheticEvent DE.MouseEvent
-> E.SyntheticEvent DE.MouseEvent
-> Effect Unit
-> Effect Unit
...
...
src/Gargantext/Components/Annotation/Menu.purs
View file @
3bcb795f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
module Gargantext.Components.Annotation.Menu where
module Gargantext.Components.Annotation.Menu where
import Prelude ( Unit, (==), ($), (<>), unit, pure )
import Prelude ( Unit, (==), ($), (<>), unit, pure
, otherwise
)
import Data.Array as A
import Data.Array as A
import Data.Maybe ( Maybe(..), maybe' )
import Data.Maybe ( Maybe(..), maybe' )
import Effect ( Effect )
import Effect ( Effect )
...
@@ -18,7 +18,7 @@ import Gargantext.Components.ContextMenu.ContextMenu as CM
...
@@ -18,7 +18,7 @@ import Gargantext.Components.ContextMenu.ContextMenu as CM
type Props = ( list :: Maybe TermList )
type Props = ( list :: Maybe TermList )
type AnnotationMenu = { x :: Number, y :: Number
, list :: Maybe TermList
}
type AnnotationMenu = { x :: Number, y :: Number
| Props
}
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | TermList the currently selected text belongs to
-- | TermList the currently selected text belongs to
...
@@ -29,21 +29,20 @@ annotationMenu setMenu { x,y,list } =
...
@@ -29,21 +29,20 @@ annotationMenu setMenu { x,y,list } =
annotationMenuCpt :: R.Component Props
annotationMenuCpt :: R.Component Props
annotationMenuCpt = R.hooksComponent "Annotation.Menu" cpt
annotationMenuCpt = R.hooksComponent "Annotation.Menu" cpt
where
where
cpt
{ list } _ = pure $ R.fragment $ children list
cpt
props _ = pure $ R.fragment $ children props
children
l = A.mapMaybe (\l' -> addToList l' l
) [ GraphTerm, CandidateTerm, StopTerm ]
children
props = A.mapMaybe (addToList props
) [ GraphTerm, CandidateTerm, StopTerm ]
-- | Given the TermList to render the item for zand the Maybe TermList the item may belong to, possibly render the menuItem
-- | Given the TermList to render the item for zand the Maybe TermList the item may belong to, possibly render the menuItem
addToList :: TermList -> Maybe TermList -> Maybe R.Element
addToList :: Record Props -> TermList -> Maybe R.Element
addToList t (Just t')
addToList {list: Just t'} t
| t == t' = Nothing
| t == t' = Nothing
| true = addToList t Nothing
addToList props t = Just $ CM.contextMenuItem [ link ]
addToList t _ = Just $ CM.contextMenuItem [ link ]
where link = HTML.a { onClick: click, className: className } [ HTML.text label ]
where link = HTML.a { onClick: click, className: className } [ HTML.text label ]
label = "Add to " <> termListName t
label = "Add to " <> termListName t
className = termClass t
className = termClass t
click = mkEffectFn1 $ \_ -> addToTermList t
click = mkEffectFn1 $ \_ -> addToTermList
props
t
-- TODO: what happens when we add to a term list?
-- TODO: what happens when we add to a term list?
addToTermList :: TermList -> Effect Unit
addToTermList ::
Record Props ->
TermList -> Effect Unit
addToTermList _ = pure unit
addToTermList _
_
= pure unit
src/Gargantext/Components/NgramsTable.purs
View file @
3bcb795f
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/NgramsTable/Core.purs
0 → 100644
View file @
3bcb795f
This diff is collapsed.
Click to expand it.
src/Gargantext/Pages/Corpus/Document.purs
View file @
3bcb795f
...
@@ -21,7 +21,7 @@ import Gargantext.Prelude
...
@@ -21,7 +21,7 @@ import Gargantext.Prelude
import Gargantext.Config (toUrl, NodeType(..), End(..), TabSubType(..), TabType(..), CTabNgramType(..))
import Gargantext.Config (toUrl, NodeType(..), End(..), TabSubType(..), TabType(..), CTabNgramType(..))
import Gargantext.Config.REST (get)
import Gargantext.Config.REST (get)
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.Node (NodePoly(..))
import Gargantext.Components.NgramsTable (NgramsTable(..), NgramsElement(..), loadNgramsTable, Versioned(..))
import Gargantext.Components.NgramsTable
.Core
(NgramsTable(..), NgramsElement(..), loadNgramsTable, Versioned(..))
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Components.Annotation.AnnotatedField as AnnotatedField
import Gargantext.Types (TermList(..))
import Gargantext.Types (TermList(..))
import Gargantext.Utils.Reactix ( scuff )
import Gargantext.Utils.Reactix ( scuff )
...
...
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