Commit 514b4eee authored by Karen Konou's avatar Karen Konou

[Docs] refactor subcorpus modal

parent ae221fac
Pipeline #7304 passed with stages
in 24 minutes and 48 seconds
......@@ -153,7 +153,6 @@ docViewCpt = R2.hereComponent here "docView" hCpt
isSubcorpusModalVisibleBox <- T.useBox false
onDocumentCreationPending /\ onDocumentCreationPendingBox <-
R2.useBox' false
reuseParentList' /\ reuseParentList <- R2.useBox' true
onSubcorpusCreationPending' /\ onSubcorpusCreationPending <- R2.useBox' false
{ goToRoute } <- useLinkHandler
......@@ -261,19 +260,6 @@ docViewCpt = R2.hereComponent here "docView" hCpt
, status: onDocumentCreationPending ? Deferred $ Enabled
}
]
,
-- Document Creation Modal
B.baseModal
{ isVisibleBox: isDocumentModalVisibleBox
, title: Just "Add a new document"
, hasCollapsibleBackground: false
, size: LargeModalSize
}
[ DFC.documentFormCreation
{ callback: createDocumentCallback
, status: onDocumentCreationPending ? Deferred $ Enabled
}
]
,
-- Subcorpus Creation Modal
B.baseModal
......@@ -285,8 +271,6 @@ docViewCpt = R2.hereComponent here "docView" hCpt
[ subcorpusCreation
{ callback: createSubcorpusCallback
, query'
, reuseParentList
, reuseParentList'
, onSubcorpusCreationPending'
}
]
......
......@@ -3,9 +3,11 @@ module Gargantext.Components.DocsTable.SubcorpusCreation where
import Gargantext.Prelude
import Effect (Effect)
import Gargantext.Hooks.StateRecord (useStateRecord)
import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ButtonVariant(..), ComponentStatus(..), Variant(..))
import Gargantext.Utils.Reactix as R2
import Record.Unsafe (unsafeSet)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
......@@ -13,8 +15,6 @@ import Toestand as T
type Props =
( callback :: String -> Boolean -> Effect Unit
, query' :: String
, reuseParentList :: T.Box Boolean
, reuseParentList' :: Boolean
, onSubcorpusCreationPending' :: Boolean
)
......@@ -24,23 +24,38 @@ subcorpusCreation = R2.leaf component
component :: R.Component Props
component = R.hooksComponent "subcorpusCreation" cpt
where
cpt { query', reuseParentList, reuseParentList', onSubcorpusCreationPending', callback } _ = do
cpt { query', onSubcorpusCreationPending', callback } _ = do
{ state, stateBox } <- useStateRecord (defaultData :: FormData)
let
onParentListCheckboxChange :: Boolean -> Effect Unit
onParentListCheckboxChange value = T.modify_
(\prev -> unsafeSet "reuseParentList" value prev)
stateBox
pure $ H.div {}
[ H.div { className: "form-group" }
[ H.label {} [ H.text $ "Creating subcorpus from query: " <> query' ]
]
, H.div { className: "form-check" }
[ B.formCheckbox
{ value: reuseParentList'
, callback: \_ -> T.modify_ not reuseParentList
{ value: state.reuseParentList
, callback: onParentListCheckboxChange
}
, H.label { className: "form-check-label" } [ H.text "Reuse parent list?" ]
]
, B.button
{ callback: \_ -> callback query' reuseParentList'
{ callback: \_ -> callback query' state.reuseParentList
, type: "submit"
, variant: ButtonVariant Primary
, status: if query' == "" then Disabled else if onSubcorpusCreationPending' then Deferred else Enabled
}
[ H.text "Create!" ]
]
type FormData = { reuseParentList :: Boolean }
defaultData :: FormData
defaultData =
{ reuseParentList: true
}
\ No newline at end of file
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