[NGRAMS-TABLE] small fix and cleanup

parent 86165573
...@@ -53,7 +53,6 @@ import Gargantext.Components.Table as T ...@@ -53,7 +53,6 @@ import Gargantext.Components.Table as T
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Partial.Unsafe (unsafePartial)
import Unsafe.Coerce (unsafeCoerce) import Unsafe.Coerce (unsafeCoerce)
type State = type State =
...@@ -117,7 +116,7 @@ setTermListSetA ngramsTable ns new_list = ...@@ -117,7 +116,7 @@ setTermListSetA ngramsTable ns new_list =
f n unit = NgramsPatch { patch_list, patch_children: mempty } f n unit = NgramsPatch { patch_list, patch_children: mempty }
where where
cur_list = ngramsTable ^? at n <<< _Just <<< _NgramsElement <<< _list cur_list = ngramsTable ^? at n <<< _Just <<< _NgramsElement <<< _list
patch_list = replace (unsafePartial (fromJust cur_list)) new_list patch_list = maybe mempty (\c -> replace c new_list) cur_list
toMap :: forall a. Set a -> Map a Unit toMap :: forall a. Set a -> Map a Unit
toMap = unsafeCoerce toMap = unsafeCoerce
-- TODO https://github.com/purescript/purescript-ordered-collections/pull/21 -- TODO https://github.com/purescript/purescript-ordered-collections/pull/21
...@@ -192,11 +191,11 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath ...@@ -192,11 +191,11 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
, H.div {className: "col-md-1", style: {marginTop : "6px", marginBottom : "1px"}} , H.div {className: "col-md-1", style: {marginTop : "6px", marginBottom : "1px"}}
[ H.li {className: " list-group-item"} [ H.li {className: " list-group-item"}
[ H.button { className: "btn btn-primary" [ H.button { className: "btn btn-primary"
, on: {click: const $ dispatch $ setTermListSetA ngramsTableCache ngramsSelection GraphTerm } , on: {click: const $ setSelection GraphTerm }
} }
[ H.text "Map" ] [ H.text "Map" ]
, H.button { className: "btn btn-primary" , H.button { className: "btn btn-primary"
, on: {click: const $ dispatch $ setTermListSetA ngramsTableCache ngramsSelection StopTerm } , on: {click: const $ setSelection StopTerm }
} }
[ H.text "Stop" ] [ H.text "Stop" ]
] ]
...@@ -230,6 +229,7 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath ...@@ -230,6 +229,7 @@ tableContainer { path: {searchQuery, termListFilter, termSizeFilter} /\ setPath
setSearchQuery x = setPath $ _ { searchQuery = x } setSearchQuery x = setPath $ _ { searchQuery = x }
setTermListFilter x = setPath $ _ { termListFilter = x } setTermListFilter x = setPath $ _ { termListFilter = x }
setTermSizeFilter x = setPath $ _ { termSizeFilter = x } setTermSizeFilter x = setPath $ _ { termSizeFilter = x }
setSelection = dispatch <<< setTermListSetA ngramsTableCache ngramsSelection
toggleMaybe :: forall a. a -> Maybe a -> Maybe a toggleMaybe :: forall a. a -> Maybe a -> Maybe a
toggleMaybe _ (Just _) = Nothing toggleMaybe _ (Just _) = Nothing
......
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