Commit a716a918 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[REFACT] checkbox

parent df89d465
...@@ -348,7 +348,7 @@ pageCpt = R.hooksComponent "G.C.FacetsTable.Page" cpt ...@@ -348,7 +348,7 @@ pageCpt = R.hooksComponent "G.C.FacetsTable.Page" cpt
] ]
, delete: true } , delete: true }
where where
markClick _ = markCategory session nodeId category [id] markClick _ = markCategory session nodeId category [id]
toggleClick _ = togglePendingDeletion deletions id toggleClick _ = togglePendingDeletion deletions id
maybeStricken delete maybeStricken delete
| delete = H.div { style: { textDecoration: "line-through" } } | delete = H.div { style: { textDecoration: "line-through" } }
......
...@@ -5,7 +5,7 @@ import Data.Maybe (Maybe(..)) ...@@ -5,7 +5,7 @@ import Data.Maybe (Maybe(..))
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel) import Gargantext.Components.Forest.Tree.Node.Tools (submitButton, panel, checkbox)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsIn, subTreeView, SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (SubTreeParamsIn, subTreeView, SubTreeOut(..))
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
...@@ -23,11 +23,15 @@ mergeNode :: Record SubTreeParamsIn -> R.Hooks R.Element ...@@ -23,11 +23,15 @@ mergeNode :: Record SubTreeParamsIn -> R.Hooks R.Element
mergeNode p@{dispatch, subTreeParams, id, nodeType, session} = do mergeNode p@{dispatch, subTreeParams, id, nodeType, session} = do
subTreeOut@(subTreeOutParams /\ setSubTreeOut) :: R.State (Maybe SubTreeOut) subTreeOut@(subTreeOutParams /\ setSubTreeOut) :: R.State (Maybe SubTreeOut)
<- R.useState' Nothing <- R.useState' Nothing
merge <- R.useState' false
let button = case subTreeOutParams of let button = case subTreeOutParams of
Nothing -> H.div {} [] Nothing -> H.div {} []
Just sbto -> submitButton (MergeNode inId outId) dispatch Just sbto -> submitButton (MergeNode inId outId) dispatch
where where
(SubTreeOut { in:inId, out:outId}) = sbto (SubTreeOut { in:inId, out:outId}) = sbto
pure $ panel [ subTreeView { subTreeOut pure $ panel [ subTreeView { subTreeOut
, dispatch , dispatch
, subTreeParams , subTreeParams
...@@ -35,5 +39,6 @@ mergeNode p@{dispatch, subTreeParams, id, nodeType, session} = do ...@@ -35,5 +39,6 @@ mergeNode p@{dispatch, subTreeParams, id, nodeType, session} = do
, nodeType , nodeType
, session , session
} }
, H.div {className: "checkbox"} [checkbox merge, H.text "Merge data?"]
] button ] button
...@@ -9,6 +9,7 @@ data Status = Stable | Test | Dev ...@@ -9,6 +9,7 @@ data Status = Stable | Test | Dev
hasStatus :: NodeType -> NodeAction -> Status hasStatus :: NodeType -> NodeAction -> Status
hasStatus _ SearchBox = Dev hasStatus _ SearchBox = Dev
hasStatus _ Refresh = Dev
hasStatus _ Config = Dev hasStatus _ Config = Dev
hasStatus _ (Link _) = Test hasStatus _ (Link _) = Test
hasStatus _ (Move _) = Test hasStatus _ (Move _) = Test
......
...@@ -8,7 +8,7 @@ import Effect (Effect) ...@@ -8,7 +8,7 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Uncurried (mkEffectFn1) import Effect.Uncurried (mkEffectFn1)
import Gargantext.Components.Forest.Tree.Node.Action import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Prelude (Unit, bind, const, discard, pure, show, ($), (<<<), (<>), read, map, class Read, class Show) import Gargantext.Prelude (Unit, bind, const, discard, pure, show, ($), (<<<), (<>), read, map, class Read, class Show, not)
import Gargantext.Types (ID) import Gargantext.Types (ID)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
...@@ -201,7 +201,17 @@ submitButtonHref action href = ...@@ -201,7 +201,17 @@ submitButtonHref action href =
} }
[ H.text $ " " <> text action] [ H.text $ " " <> text action]
------------------------------------------------------------------------
-- | CheckBox tools
-- checkboxes: Array of poolean values
-- checkbox : One boolean value only
checkbox :: R.State Boolean -> R.Element
checkbox ( val /\ set ) =
H.input { id: "checkbox-id"
, type: "checkbox"
, value: val
, className : "checkbox"
, on: { click: \_ -> set $ const $ not val}
}
...@@ -19,6 +19,7 @@ import Reactix as R ...@@ -19,6 +19,7 @@ import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
------------------------------------------------------------------------ ------------------------------------------------------------------------
import Gargantext.Components.Forest.Tree.Node.Tools (checkbox)
import Gargantext.Components.Forms (clearfix, cardBlock, cardGroup, center, formGroup) import Gargantext.Components.Forms (clearfix, cardBlock, cardGroup, center, formGroup)
import Gargantext.Components.Login.Types (AuthRequest(..)) import Gargantext.Components.Login.Types (AuthRequest(..))
import Gargantext.Ends (Backend(..)) import Gargantext.Ends (Backend(..))
...@@ -178,7 +179,7 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where ...@@ -178,7 +179,7 @@ formCpt = R.hooksComponent "G.C.Login.form" cpt where
, center , center
[ H.label {} [ H.label {}
[ H.div {className: "checkbox"} [ H.div {className: "checkbox"}
[ termsCheckbox setBox [ checkbox setBox
, H.text "I hereby accept " , H.text "I hereby accept "
, H.a { target: "_blank" , H.a { target: "_blank"
, href: "http://gitlab.iscpif.fr/humanities/tofu/tree/master" , href: "http://gitlab.iscpif.fr/humanities/tofu/tree/master"
...@@ -213,15 +214,6 @@ csrfTokenInput _ = ...@@ -213,15 +214,6 @@ csrfTokenInput _ =
, value: csrfMiddlewareToken , value: csrfMiddlewareToken
} -- TODO hard-coded CSRF token } -- TODO hard-coded CSRF token
termsCheckbox :: R.State Boolean -> R.Element
termsCheckbox setCheckBox =
H.input { id: "terms-accept"
, type: "checkbox"
, value: fst setCheckBox
, className: "checkbox"
, on: { click: \_ -> (snd setCheckBox) $ const $ not (fst setCheckBox)}
}
termsLink :: {} -> R.Element termsLink :: {} -> R.Element
termsLink _ = termsLink _ =
H.a { target: "_blank", href: termsUrl } [ H.text "the terms of use" ] H.a { target: "_blank", href: termsUrl } [ H.text "the terms of use" ]
......
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