Commit 1aed5d91 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] fix indeterminate checkbox selection

parent d5d02605
...@@ -25,6 +25,7 @@ import Data.Tuple (Tuple(..), fst, snd) ...@@ -25,6 +25,7 @@ import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2) import DOM.Simple.Console (log2)
import Effect (Effect) import Effect (Effect)
import FFI.Simple (delay)
import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||)) import Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, otherwise, pure, show, unit, (#), ($), (&&), (+), (/=), (<$>), (<<<), (<>), (=<<), (==), (||))
import React.DOM (a, span, text) import React.DOM (a, span, text)
import React.DOM.Props (onClick, style) import React.DOM.Props (onClick, style)
...@@ -515,12 +516,11 @@ selectionCheckboxCpt = R.hooksComponent "G.C.NT.selectionCheckbox" cpt ...@@ -515,12 +516,11 @@ selectionCheckboxCpt = R.hooksComponent "G.C.NT.selectionCheckbox" cpt
cpt { allNgramsSelected, dispatch, ngramsSelection } _ = do cpt { allNgramsSelected, dispatch, ngramsSelection } _ = do
ref <- R.useRef null ref <- R.useRef null
R.useEffect' $ do R.useEffect' $ delay unit $ \_ -> do
let mCb = toMaybe $ R.readRef ref let mCb = toMaybe $ R.readRef ref
case mCb of case mCb of
Nothing -> pure unit Nothing -> pure unit
Just cb -> do Just cb -> do
log2 "[loadedNgramsTableSpec] ngramsSelection" ngramsSelection
_ <- if allNgramsSelected || (Set.isEmpty ngramsSelection) then _ <- if allNgramsSelected || (Set.isEmpty ngramsSelection) then
R2.setIndeterminateCheckbox cb false R2.setIndeterminateCheckbox cb false
else else
......
...@@ -307,7 +307,4 @@ focus nEl = case toMaybe nEl of ...@@ -307,7 +307,4 @@ focus nEl = case toMaybe nEl of
Just el -> el ... "focus" $ [] Just el -> el ... "focus" $ []
setIndeterminateCheckbox :: R.Element -> Boolean -> Effect R.Element setIndeterminateCheckbox :: R.Element -> Boolean -> Effect R.Element
setIndeterminateCheckbox el val = do setIndeterminateCheckbox el val = pure $ (el .= "indeterminate") val
log2 "[setIntederminateCheckbox] el" el
log2 "[setIntederminateCheckbox] val" val
pure $ (el .= "indeterminate") val
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