[annotation] don't allow spaces in doc annotation selection

parent fc1136e1
...@@ -13,18 +13,18 @@ module Gargantext.Components.Annotation.Field where ...@@ -13,18 +13,18 @@ module Gargantext.Components.Annotation.Field where
import Gargantext.Prelude import Gargantext.Prelude
import DOM.Simple.Event as DE
import Data.Array as A import Data.Array as A
import Data.List (List(..), (:)) import Data.List (List(..), (:))
import Data.Maybe (Maybe(..), maybe) import Data.Maybe (Maybe(..), maybe)
import Data.String.Common (joinWith) import Data.String.Common (joinWith)
import Data.Tuple (Tuple(..), snd) import Data.Tuple (Tuple(..), snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Event as DE
import Effect (Effect) import Effect (Effect)
import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu) import Gargantext.Components.Annotation.Menu (annotationMenu, AnnotationMenu)
import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass) import Gargantext.Components.Annotation.Types (MenuType(..), ModeType(..), termClass)
import Gargantext.Core.NgramsTable.Functions (findNgramTermList, highlightNgrams, normNgram) import Gargantext.Core.NgramsTable.Functions (findNgramTermList, highlightNgrams, normNgram)
import Gargantext.Core.NgramsTable.Types (NgramsTable, NgramsTerm) import Gargantext.Core.NgramsTable.Types (NgramsTable, NgramsTerm(..))
import Gargantext.Types (CTabNgramType(..), TermList) import Gargantext.Types (CTabNgramType(..), TermList)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Selection as Sel import Gargantext.Utils.Selection as Sel
...@@ -35,7 +35,7 @@ import Record as Record ...@@ -35,7 +35,7 @@ import Record as Record
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Annotation.AnnotatedField" here = R2.here "Gargantext.Components.Annotation.Field"
-- @NOTE #386: add parameter "type" ("Authors", "Terms") -- @NOTE #386: add parameter "type" ("Authors", "Terms")
type Props = type Props =
...@@ -52,7 +52,6 @@ type MouseEvent = E.SyntheticEvent DE.MouseEvent ...@@ -52,7 +52,6 @@ type MouseEvent = E.SyntheticEvent DE.MouseEvent
annotatedField :: R2.Leaf Props annotatedField :: R2.Leaf Props
annotatedField = R2.leaf annotatedFieldCpt annotatedField = R2.leaf annotatedFieldCpt
annotatedFieldCpt :: R.Component Props annotatedFieldCpt :: R.Component Props
annotatedFieldCpt = here.component "annotatedField" cpt where annotatedFieldCpt = here.component "annotatedField" cpt where
cpt props _ = do cpt props _ = do
...@@ -71,7 +70,6 @@ type InnerProps = ...@@ -71,7 +70,6 @@ type InnerProps =
annotatedFieldInner :: R2.Leaf InnerProps annotatedFieldInner :: R2.Leaf InnerProps
annotatedFieldInner = R2.leaf annotatedFieldInnerCpt annotatedFieldInner = R2.leaf annotatedFieldInnerCpt
annotatedFieldInnerCpt :: R.Component InnerProps annotatedFieldInnerCpt :: R.Component InnerProps
annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
cpt { menuRef cpt { menuRef
...@@ -159,16 +157,16 @@ onAnnotationSelect ...@@ -159,16 +157,16 @@ onAnnotationSelect
s <- Sel.getSelection s <- Sel.getSelection
case s of case s of
Just sel -> do Just sel -> do
case Sel.selectionToString sel of case (normNgram CTabTerms $ Sel.selectionToString sel) of
"" -> hideMenu { menuRef, redrawMenu } NormNgramsTerm "" -> hideMenu { menuRef, redrawMenu }
sel' -> do sel' -> do
showMenu { event showMenu { event
, getList: findNgramTermList ngrams , getList: findNgramTermList ngrams
, menuRef , menuRef
, menuType: NewNgram , menuType: NewNgram
, ngram: normNgram CTabTerms sel' , ngram: sel' -- normNgram CTabTerms sel'
, redrawMenu , redrawMenu
, setTermList } , setTermList }
Nothing -> hideMenu { menuRef, redrawMenu } Nothing -> hideMenu { menuRef, redrawMenu }
onAnnotationSelect onAnnotationSelect
...@@ -241,7 +239,6 @@ type RunProps = ...@@ -241,7 +239,6 @@ type RunProps =
annotateRun :: R2.Leaf RunProps annotateRun :: R2.Leaf RunProps
annotateRun = R2.leaf annotatedRunCpt annotateRun = R2.leaf annotatedRunCpt
annotatedRunCpt :: R.Component RunProps annotatedRunCpt :: R.Component RunProps
annotatedRunCpt = here.component "annotatedRun" cpt where annotatedRunCpt = here.component "annotatedRun" cpt where
cpt { list, onSelect, text } _ = pure $ case list of cpt { list, onSelect, text } _ = pure $ case list of
......
...@@ -36,7 +36,6 @@ type AnnotationMenu = ...@@ -36,7 +36,6 @@ type AnnotationMenu =
annotationMenu :: R2.Leaf Props annotationMenu :: R2.Leaf Props
annotationMenu = R2.leaf annotationMenuCpt annotationMenu = R2.leaf annotationMenuCpt
annotationMenuCpt :: R.Component Props annotationMenuCpt :: R.Component Props
annotationMenuCpt = here.component "main" cpt where annotationMenuCpt = here.component "main" cpt where
cpt { menuRef } _ = do cpt { menuRef } _ = do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment