Hide the state of NgramsItem

parent 8c3e1b1f
......@@ -2,17 +2,21 @@ module Gargantext.Pages.Corpus.Doc.Facets.Terms.NgramsItem where
import Prelude
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype, unwrap)
import Data.Lens.Iso (re)
import Data.Lens.Iso.Newtype (_Newtype)
import React (ReactElement)
import React.DOM (input, span, td, text, tr)
import React.DOM.Props (_type, checked, className, onChange, style, title)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec)
import Thermite (PerformAction, Render, Spec, modifyState, simpleSpec, hide, focusState)
import Gargantext.Utils (getter, setter)
newtype State = State
{ term :: Term
}
derive instance newtypeState :: Newtype State _
initialState :: State
initialState = State {term : Term {id : 10, term : "hello", occurrence : 10, _type : None, children : []}}
......@@ -40,8 +44,10 @@ performAction (SetMap b) _ _ = void do
performAction (SetStop b) _ _ = void do
modifyState \(State s) -> State s {term = setter (_{_type = (if b then StopTerm else None)}) s.term}
ngramsItemSpec :: Spec State {} Action
ngramsItemSpec = simpleSpec performAction render
ngramsItemSpec :: Spec {} {} Void
ngramsItemSpec = hide (unwrap initialState) $
focusState (re _Newtype) $
simpleSpec performAction render
where
render :: Render State {} Action
render dispatch _ (State state) _ =
......
......@@ -15,12 +15,12 @@ import Prelude (class Eq, class Ord, class Show, map, show, void, ($), (*), (+),
import React (ReactElement)
import React.DOM hiding (style, map)
import React.DOM.Props (_id, _type, className, href, name, onChange, onClick, onInput, placeholder, scope, selected, style, value)
import Thermite (PerformAction, Spec, _render, cotransform, focus, foreach, modifyState, withState, focusState, hide)
import Thermite (PerformAction, Spec, _render, cotransform, focus, foreach, modifyState, focusState, hide)
import Unsafe.Coerce (unsafeCoerce)
newtype State = State
{ items :: List NI.State
, search :: String
{ items :: List {}
, search :: String
, selectString :: String
, totalPages :: Int
, currentPage :: Int
......@@ -31,26 +31,26 @@ newtype State = State
derive instance newtypeState :: Newtype State _
initialState :: State
initialState = State { items : toUnfoldable [NI.initialState]
, search : ""
initialState = State { items : toUnfoldable [{}]
, search : ""
, selectString : ""
,totalPages : 10
, totalPages : 10
, currentPage : 1
, pageSize : PS10
, totalRecords : 100
}
data Action
= ItemAction Int NI.Action
= ItemAction Int Void
| ChangeString String
| SetInput String
| ChangePageSize PageSizes
| ChangePage Int
_itemsList :: Lens' State (List NI.State)
_itemsList :: Lens' State (List {})
_itemsList = lens (\(State s) -> s.items) (\(State s) v -> State s { items = v })
_ItemAction :: Prism' Action (Tuple Int NI.Action)
_ItemAction :: Prism' Action (Tuple Int Void)
_ItemAction = prism (uncurry ItemAction) \ta ->
case ta of
ItemAction i a -> Right (Tuple i a)
......@@ -153,13 +153,14 @@ tableSpec = over _render \render dispatch p (State s) c ->
]
ngramsTableSpec :: Spec {} {} Void
ngramsTableSpec = hide (unwrap initialState) $
focusState (re _Newtype) $
container $ fold
[ tableSpec $ withState \st ->
focus _itemsList _ItemAction $
foreach \_ -> NI.ngramsItemSpec
]
ngramsTableSpec =
hide (unwrap initialState) $
focusState (re _Newtype) $
container $
tableSpec $
focus _itemsList _ItemAction $
foreach $ \ _ ->
NI.ngramsItemSpec
container :: forall state props action. Spec state props action -> Spec state props action
container = over _render \render d p s c ->
......
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