NgramsTable: short export list, no warnings

parent 998ad895
module Gargantext.Components.NgramsTable where module Gargantext.Components.NgramsTable
( MainNgramsTableProps
, mainNgramsTable
) where
import Prelude import Prelude
( class Show, Unit, bind, const, discard, identity, map, mempty, not ( class Show, Unit, bind, const, discard, identity, map, mempty, not
, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<) , pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<)
, (==), (||) ) , (==), (||) )
import Data.Array as A import Data.Array as A
import Data.Lens (to, view, (%~), (.~), (^.), (^..)) import Data.Lens (Lens', to, view, (%~), (.~), (^.), (^..))
import Data.Lens.Common (_Just) import Data.Lens.Common (_Just)
import Data.Lens.At (at) import Data.Lens.At (at)
import Data.Lens.Index (ix) import Data.Lens.Index (ix)
...@@ -54,6 +57,7 @@ type State = ...@@ -54,6 +57,7 @@ type State =
-- be removed. -- be removed.
) )
_ngramsChildren :: forall row. Lens' { ngramsChildren :: Map NgramsTerm Boolean | row } (Map NgramsTerm Boolean)
_ngramsChildren = prop (SProxy :: SProxy "ngramsChildren") _ngramsChildren = prop (SProxy :: SProxy "ngramsChildren")
initialState :: VersionedNgramsTable -> State initialState :: VersionedNgramsTable -> State
...@@ -191,11 +195,11 @@ type Props = ...@@ -191,11 +195,11 @@ type Props =
, path :: R.State PageParams , path :: R.State PageParams
, versioned :: VersionedNgramsTable ) , versioned :: VersionedNgramsTable )
ngramsTable :: Record Props -> R.Element loadedNgramsTable :: Record Props -> R.Element
ngramsTable props = R.createElement ngramsTableCpt props [] loadedNgramsTable props = R.createElement loadedNgramsTableCpt props []
ngramsTableCpt :: R.Component Props loadedNgramsTableCpt :: R.Component Props
ngramsTableCpt = R.hooksComponent "G.C.NgramsTable.ngramsTable" cpt loadedNgramsTableCpt = R.hooksComponent "G.C.NgramsTable.loadedNgramsTable" cpt
where where
cpt {versioned} _ = do cpt {versioned} _ = do
state <- useNgramsReducer (initialState versioned) state <- useNgramsReducer (initialState versioned)
...@@ -308,7 +312,7 @@ mainNgramsTableCpt = R.hooksComponent "MainNgramsTable" cpt ...@@ -308,7 +312,7 @@ mainNgramsTableCpt = R.hooksComponent "MainNgramsTable" cpt
cpt {nodeId, defaultListId, tabType, session, tabNgramType} _ = do cpt {nodeId, defaultListId, tabType, session, tabNgramType} _ = do
path <- R.useState' $ initialPageParams session nodeId [defaultListId] tabType path <- R.useState' $ initialPageParams session nodeId [defaultListId] tabType
useLoader2 path (loadNgramsTable session) $ useLoader2 path (loadNgramsTable session) $
\versioned -> ngramsTable {session, tabNgramType, path, versioned} \versioned -> loadedNgramsTable {session, tabNgramType, path, versioned}
type NgramsDepth = {ngrams :: NgramsTerm, depth :: Int} type NgramsDepth = {ngrams :: NgramsTerm, depth :: Int}
type NgramsClick = NgramsDepth -> Maybe (Effect Unit) type NgramsClick = NgramsDepth -> Maybe (Effect Unit)
...@@ -318,10 +322,10 @@ tree :: { ngramsTable :: NgramsTable ...@@ -318,10 +322,10 @@ tree :: { ngramsTable :: NgramsTable
, ngramsEdit :: NgramsClick , ngramsEdit :: NgramsClick
, ngramsClick :: NgramsClick , ngramsClick :: NgramsClick
} -> NgramsDepth -> ReactElement } -> NgramsDepth -> ReactElement
tree params@{ngramsTable, ngramsStyle, ngramsEdit, ngramsClick} nd@{ngrams} = tree params@{ngramsTable, ngramsStyle, ngramsEdit, ngramsClick} nd =
li [ style {width : "100%"} ] li [ style {width : "100%"} ]
([ i icon [] ([ i icon []
, tag [text $ " " <> ngrams] , tag [text $ " " <> nd.ngrams]
] <> maybe [] edit (ngramsEdit nd) <> ] <> maybe [] edit (ngramsEdit nd) <>
[ forest cs [ forest cs
]) ])
...@@ -339,7 +343,7 @@ tree params@{ngramsTable, ngramsStyle, ngramsEdit, ngramsClick} nd@{ngrams} = ...@@ -339,7 +343,7 @@ tree params@{ngramsTable, ngramsStyle, ngramsEdit, ngramsClick} nd@{ngrams} =
icon = gray <> [className $ "glyphicon glyphicon-chevron-" <> if open then "down" else "right"] icon = gray <> [className $ "glyphicon glyphicon-chevron-" <> if open then "down" else "right"]
open = not leaf || false {- TODO -} open = not leaf || false {- TODO -}
gray = if leaf then [style {color: "#adb5bd"}] else [] gray = if leaf then [style {color: "#adb5bd"}] else []
cs = ngramsTable ^.. ix ngrams <<< _NgramsElement <<< _children <<< folded cs = ngramsTable ^.. ix nd.ngrams <<< _NgramsElement <<< _children <<< folded
forest = forest =
let depth = nd.depth + 1 in let depth = nd.depth + 1 in
......
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