Commit 6b75d5c4 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-merge' into dev

parents 73473d06 06385559
...@@ -66,7 +66,7 @@ type InnerProps = ...@@ -66,7 +66,7 @@ type InnerProps =
) )
annotatedFieldInner :: R2.Leaf InnerProps annotatedFieldInner :: R2.Leaf InnerProps
annotatedFieldInner p = R.createElement annotatedFieldInnerCpt p [] annotatedFieldInner = R2.leafComponent annotatedFieldInnerCpt
annotatedFieldInnerCpt :: R.Component InnerProps annotatedFieldInnerCpt :: R.Component InnerProps
annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where annotatedFieldInnerCpt = here.component "annotatedFieldInner" cpt where
cpt { menuRef, ngrams, redrawMenu, setTermList, text: fieldText } _ = do cpt { menuRef, ngrams, redrawMenu, setTermList, text: fieldText } _ = do
......
...@@ -60,7 +60,7 @@ eqAnnotationMenuWrapper { new: Just _, old: Nothing } = pure $ false ...@@ -60,7 +60,7 @@ eqAnnotationMenuWrapper { new: Just _, old: Nothing } = pure $ false
eqAnnotationMenuWrapper { new: Just n, old: Just o } = pure $ eqAnnotationMenu n o eqAnnotationMenuWrapper { new: Just n, old: Just o } = pure $ eqAnnotationMenu n o
annotationMenuWrapper :: R2.Leaf AnnotationMenuWrapper annotationMenuWrapper :: R2.Leaf AnnotationMenuWrapper
annotationMenuWrapper p = R.createElement annotationMenuWrapperCpt p [] annotationMenuWrapper = R2.leafComponent annotationMenuWrapperCpt
annotationMenuWrapperCpt :: R.Component AnnotationMenuWrapper annotationMenuWrapperCpt :: R.Component AnnotationMenuWrapper
annotationMenuWrapperCpt = here.component "annotationMenuWrapper" cpt where annotationMenuWrapperCpt = here.component "annotationMenuWrapper" cpt where
cpt { menuRef } _ = do cpt { menuRef } _ = do
...@@ -71,7 +71,7 @@ annotationMenuWrapperCpt = here.component "annotationMenuWrapper" cpt where ...@@ -71,7 +71,7 @@ annotationMenuWrapperCpt = here.component "annotationMenuWrapper" cpt where
-- | An Annotation Menu is parameterised by a Maybe Termlist of the -- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | TermList the currently selected text belongs to -- | TermList the currently selected text belongs to
annotationMenu :: R2.Leaf AnnotationMenu annotationMenu :: R2.Leaf AnnotationMenu
annotationMenu p = R.createElement annotationMenuCpt p [] annotationMenu = R2.leafComponent annotationMenuCpt
annotationMenuCpt :: R.Component AnnotationMenu annotationMenuCpt :: R.Component AnnotationMenu
annotationMenuCpt = here.component "annotationMenu" cpt where annotationMenuCpt = here.component "annotationMenu" cpt where
cpt { x, y, list, menuType, onClose, redrawMenu, setList } _ = do cpt { x, y, list, menuType, onClose, redrawMenu, setList } _ = do
...@@ -82,7 +82,7 @@ annotationMenuCpt = here.component "annotationMenu" cpt where ...@@ -82,7 +82,7 @@ annotationMenuCpt = here.component "annotationMenu" cpt where
] ]
annotationMenuInner :: R2.Leaf Props annotationMenuInner :: R2.Leaf Props
annotationMenuInner p = R.createElement annotationMenuInnerCpt p [] annotationMenuInner = R2.leafComponent annotationMenuInnerCpt
annotationMenuInnerCpt :: R.Component Props annotationMenuInnerCpt :: R.Component Props
annotationMenuInnerCpt = here.component "annotationMenuInner" cpt where annotationMenuInnerCpt = here.component "annotationMenuInner" cpt where
cpt props _ = pure $ R.fragment $ A.mapMaybe (addToList props) [ MapTerm, CandidateTerm, StopTerm ] cpt props _ = pure $ R.fragment $ A.mapMaybe (addToList props) [ MapTerm, CandidateTerm, StopTerm ]
......
...@@ -51,3 +51,14 @@ errorsViewCpt = here.component "errorsView" cpt ...@@ -51,3 +51,14 @@ errorsViewCpt = here.component "errorsView" cpt
Nothing -> es Nothing -> es
Just es' -> es' Just es' -> es'
) errors ) errors
showError errors i (FOtherError { error }) =
RB.alert { dismissible: true
, onClose
, variant: "danger" } [ H.text $ show error ]
where
onClose = do
here.log2 "click!" error
T.modify_ (\es -> case deleteAt i es of
Nothing -> es
Just es' -> es'
) errors
...@@ -53,7 +53,7 @@ type Props = ...@@ -53,7 +53,7 @@ type Props =
data FolderStyle = FolderUp | FolderChild data FolderStyle = FolderUp | FolderChild
folderView :: R2.Leaf Props folderView :: R2.Leaf Props
folderView props = R.createElement folderViewCpt props [] folderView = R2.leafComponent folderViewCpt
folderViewCpt :: R.Component Props folderViewCpt :: R.Component Props
folderViewCpt = here.component "folderViewCpt" cpt where folderViewCpt = here.component "folderViewCpt" cpt where
cpt { backFolder, boxes, nodeId, session } _ = do cpt { backFolder, boxes, nodeId, session } _ = do
......
...@@ -23,7 +23,7 @@ type NodePopupProps = ...@@ -23,7 +23,7 @@ type NodePopupProps =
) )
nodePopupView :: R2.Leaf NodePopupProps nodePopupView :: R2.Leaf NodePopupProps
nodePopupView props = R.createElement nodePopupViewCpt props [] nodePopupView = R2.leafComponent nodePopupViewCpt
nodePopupViewCpt :: R.Component NodePopupProps nodePopupViewCpt :: R.Component NodePopupProps
nodePopupViewCpt = here.component "nodePopupView" cpt where nodePopupViewCpt = here.component "nodePopupView" cpt where
cpt props _ = do cpt props _ = do
......
...@@ -63,7 +63,7 @@ forestCpt = here.component "forest" cpt where ...@@ -63,7 +63,7 @@ forestCpt = here.component "forest" cpt where
type Plus = ( boxes :: Boxes ) type Plus = ( boxes :: Boxes )
plus :: R2.Leaf Plus plus :: R2.Leaf Plus
plus p = R.createElement plusCpt p [] plus = R2.leafComponent plusCpt
plusCpt :: R.Component Plus plusCpt :: R.Component Plus
plusCpt = here.component "plus" cpt where plusCpt = here.component "plus" cpt where
cpt { boxes: { backend, showLogin } } _ = pure $ cpt { boxes: { backend, showLogin } } _ = pure $
......
...@@ -307,7 +307,7 @@ nodeActionsCpt = here.component "nodeActions" cpt where ...@@ -307,7 +307,7 @@ nodeActionsCpt = here.component "nodeActions" cpt where
child _ = H.div {} [] child _ = H.div {} []
graphNodeActions :: R2.Leaf NodeActionsCommon graphNodeActions :: R2.Leaf NodeActionsCommon
graphNodeActions props = R.createElement graphNodeActionsCpt props [] graphNodeActions = R2.leafComponent graphNodeActionsCpt
graphNodeActionsCpt :: R.Component NodeActionsCommon graphNodeActionsCpt :: R.Component NodeActionsCommon
graphNodeActionsCpt = here.component "graphNodeActions" cpt where graphNodeActionsCpt = here.component "graphNodeActions" cpt where
cpt { id, session, refresh } _ = cpt { id, session, refresh } _ =
...@@ -319,7 +319,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where ...@@ -319,7 +319,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where
errorHandler = logRESTError here "[graphNodeActions]" errorHandler = logRESTError here "[graphNodeActions]"
listNodeActions :: R2.Leaf NodeActionsCommon listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions props = R.createElement listNodeActionsCpt props [] listNodeActions = R2.leafComponent listNodeActionsCpt
listNodeActionsCpt :: R.Component NodeActionsCommon listNodeActionsCpt :: R.Component NodeActionsCommon
listNodeActionsCpt = here.component "listNodeActions" cpt where listNodeActionsCpt = here.component "listNodeActions" cpt where
cpt { id, session, refresh } _ = cpt { id, session, refresh } _ =
......
...@@ -13,8 +13,8 @@ import Effect (Effect) ...@@ -13,8 +13,8 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff_) import Effect.Aff (Aff, launchAff_)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Settings (SettingsBox(..), settingsBox) import Gargantext.Components.Forest.Tree.Node.Settings (SettingsBox(..), settingsBox)
import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe, panel, submitButton) import Gargantext.Components.Forest.Tree.Node.Tools (formChoice, panel, submitButton)
import Gargantext.Components.InputWithEnter (inputWithEnter) import Gargantext.Components.InputWithEnter (inputWithEnterWithKey)
import Gargantext.Components.Lang (Lang(..), translate) import Gargantext.Components.Lang (Lang(..), translate)
import Gargantext.Config.REST (RESTError, AffRESTError) import Gargantext.Config.REST (RESTError, AffRESTError)
import Gargantext.Routes as GR import Gargantext.Routes as GR
...@@ -78,21 +78,24 @@ addNodeViewCpt :: R.Component CreateNodeProps ...@@ -78,21 +78,24 @@ addNodeViewCpt :: R.Component CreateNodeProps
addNodeViewCpt = here.component "addNodeView" cpt where addNodeViewCpt = here.component "addNodeView" cpt where
cpt { dispatch cpt { dispatch
, nodeTypes } _ = do , nodeTypes } _ = do
nodeName <- T.useBox "Name" let defaultNodeType = fromMaybe Folder $ head nodeTypes
nodeName <- T.useBox $ GT.prettyNodeType defaultNodeType
nodeName' <- T.useLive T.unequal nodeName nodeName' <- T.useLive T.unequal nodeName
nodeType <- T.useBox $ fromMaybe Folder $ head nodeTypes nodeType <- T.useBox defaultNodeType
nodeType' <- T.useLive T.unequal nodeType nodeType' <- T.useLive T.unequal nodeType
hasChromeAgent' <- R.unsafeHooksEffect hasChromeAgent hasChromeAgent' <- R.unsafeHooksEffect hasChromeAgent
let let
SettingsBox {edit} = settingsBox nodeType' SettingsBox {edit} = settingsBox nodeType'
setNodeType' nt = do setNodeType' nt = do
T.write_ (GT.prettyNodeType nt) nodeName T.write_ (GT.prettyNodeType nt) nodeName
T.write_ nt nodeType T.write_ nt nodeType
(maybeChoose /\ nt') = if length nodeTypes > 1 (maybeChoose /\ nt') = if length nodeTypes > 1
then ([ formChoiceSafe nodeTypes Error setNodeType' (print hasChromeAgent') ] /\ nodeType') then ([ formChoice { items: nodeTypes
, default: Error
, callback: setNodeType'
, print: print hasChromeAgent' } [] ] /\ nodeType')
else ([H.div {} [H.text $ "Creating a node of type " else ([H.div {} [H.text $ "Creating a node of type "
<> show defaultNt <> show defaultNt
<> " with name:" <> " with name:"
...@@ -102,7 +105,7 @@ addNodeViewCpt = here.component "addNodeView" cpt where ...@@ -102,7 +105,7 @@ addNodeViewCpt = here.component "addNodeView" cpt where
where where
defaultNt = (fromMaybe Error $ head nodeTypes) defaultNt = (fromMaybe Error $ head nodeTypes)
maybeEdit = [ if edit maybeEdit = [ if edit
then inputWithEnter { then inputWithEnterWithKey {
onBlur: \val -> T.write_ val nodeName onBlur: \val -> T.write_ val nodeName
, onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt') , onEnter: \_ -> launchAff_ $ dispatch (AddNode nodeName' nt')
, onValueChanged: \val -> T.write_ val nodeName , onValueChanged: \val -> T.write_ val nodeName
...@@ -111,6 +114,7 @@ addNodeViewCpt = here.component "addNodeView" cpt where ...@@ -111,6 +114,7 @@ addNodeViewCpt = here.component "addNodeView" cpt where
, defaultValue: nodeName' -- (prettyNodeType nt') , defaultValue: nodeName' -- (prettyNodeType nt')
, placeholder: nodeName' -- (prettyNodeType nt') , placeholder: nodeName' -- (prettyNodeType nt')
, type: "text" , type: "text"
, key: show nodeType'
} }
else H.div {} [] else H.div {} []
] ]
......
...@@ -54,7 +54,7 @@ type TextInputBoxProps = ...@@ -54,7 +54,7 @@ type TextInputBoxProps =
type AddContactProps = ( firstname :: String, lastname :: String ) type AddContactProps = ( firstname :: String, lastname :: String )
textInputBox :: R2.Leaf TextInputBoxProps textInputBox :: R2.Leaf TextInputBoxProps
textInputBox props = R.createElement textInputBoxCpt props [] textInputBox = R2.leafComponent textInputBoxCpt
textInputBoxCpt :: R.Component TextInputBoxProps textInputBoxCpt :: R.Component TextInputBoxProps
textInputBoxCpt = here.component "textInputBox" cpt where textInputBoxCpt = here.component "textInputBox" cpt where
cpt { boxName, boxAction, dispatch, isOpen cpt { boxName, boxAction, dispatch, isOpen
......
...@@ -64,7 +64,7 @@ derive instance Generic DataField _ ...@@ -64,7 +64,7 @@ derive instance Generic DataField _
instance Show DataField where instance Show DataField where
show Gargantext = "Gargantext" show Gargantext = "Gargantext"
show (External _) = "Databases (APIs)" -- <> show x show (External _) = "Databases (APIs)" -- <> show x
show Web = "Soon: web" show Web = "Web"
show Files = "Files" show Files = "Files"
instance Doc DataField where instance Doc DataField where
doc Gargantext = "All Gargantext Database" doc Gargantext = "All Gargantext Database"
......
...@@ -54,7 +54,10 @@ updateDashboardCpt = here.component "updateDashboard" cpt where ...@@ -54,7 +54,10 @@ updateDashboardCpt = here.component "updateDashboard" cpt where
methodBoard' <- T.useLive T.unequal methodBoard methodBoard' <- T.useLive T.unequal methodBoard
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [All, Sources, Authors, Institutes, Ngrams] All (\val -> T.write_ val methodBoard) show formChoiceSafe { items: [All, Sources, Authors, Institutes, Ngrams]
, default: All
, callback: \val -> T.write_ val methodBoard
, print: show } []
] ]
(submitButton (UpdateNode $ UpdateNodeParamsBoard { methodBoard: methodBoard' }) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsBoard { methodBoard: methodBoard' }) dispatch)
...@@ -67,7 +70,10 @@ updateGraphCpt = here.component "updateGraph" cpt where ...@@ -67,7 +70,10 @@ updateGraphCpt = here.component "updateGraph" cpt where
methodGraph' <- T.useLive T.unequal methodGraph methodGraph' <- T.useLive T.unequal methodGraph
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [Order1, Order2] Order1 (\val -> T.write_ val methodGraph) show formChoiceSafe { items: [Order1, Order2]
, default: Order1
, callback: \val -> T.write_ val methodGraph
, print: show } []
] ]
(submitButton (UpdateNode $ UpdateNodeParamsGraph { methodGraph: methodGraph' }) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsGraph { methodGraph: methodGraph' }) dispatch)
...@@ -80,7 +86,10 @@ updateNodeListCpt = here.component "updateNodeList" cpt where ...@@ -80,7 +86,10 @@ updateNodeListCpt = here.component "updateNodeList" cpt where
methodList' <- T.useLive T.unequal methodList methodList' <- T.useLive T.unequal methodList
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [Basic, Advanced, WithModel] Basic (\val -> T.write_ val methodList) show formChoiceSafe { items: [Basic, Advanced, WithModel]
, default: Basic
, callback: \val -> T.write_ val methodList
, print: show } []
] ]
(submitButton (UpdateNode $ UpdateNodeParamsList { methodList: methodList' }) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsList { methodList: methodList' }) dispatch)
...@@ -93,7 +102,10 @@ updateTextsCpt = here.component "updateTexts" cpt where ...@@ -93,7 +102,10 @@ updateTextsCpt = here.component "updateTexts" cpt where
methodTexts' <- T.useLive T.unequal methodTexts methodTexts' <- T.useLive T.unequal methodTexts
pure $ panel [ -- H.text "Update with" pure $ panel [ -- H.text "Update with"
formChoiceSafe [NewNgrams, NewTexts, Both] NewNgrams (\val -> T.write_ val methodTexts) show formChoiceSafe { items: [NewNgrams, NewTexts, Both]
, default: NewNgrams
, callback: \val -> T.write_ val methodTexts
, print: show } []
] ]
(submitButton (UpdateNode $ UpdateNodeParamsTexts { methodTexts: methodTexts' }) dispatch) (submitButton (UpdateNode $ UpdateNodeParamsTexts { methodTexts: methodTexts' }) dispatch)
......
...@@ -91,7 +91,7 @@ type UploadFile = ...@@ -91,7 +91,7 @@ type UploadFile =
uploadFileView :: R2.Leaf Props uploadFileView :: R2.Leaf Props
uploadFileView props = R.createElement uploadFileViewCpt props [] uploadFileView = R2.leafComponent uploadFileViewCpt
uploadFileViewCpt :: R.Component Props uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = here.component "uploadFileView" cpt uploadFileViewCpt = here.component "uploadFileView" cpt
where where
...@@ -119,19 +119,24 @@ uploadFileViewCpt = here.component "uploadFileView" cpt ...@@ -119,19 +119,24 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
] ]
, R2.row , R2.row
[ H.div {className:"col-6 flex-space-around"} [ H.div {className:"col-6 flex-space-around"}
[ formChoiceSafe [ CSV [ formChoiceSafe { items: [ CSV
, CSV_HAL , CSV_HAL
, WOS , WOS
, PresseRIS , PresseRIS
, Arbitrary , Arbitrary
, ZIP , ZIP
] CSV setFileType' show ]
, default: CSV
, callback: setFileType'
, print: show } []
] ]
] ]
, R2.row , R2.row
[ H.div {className:"col-6 flex-space-around"} [ H.div {className:"col-6 flex-space-around"}
[ formChoiceSafe [EN, FR, No_extraction, Universal] EN setLang' [ formChoiceSafe { items: [EN, FR, No_extraction, Universal]
show , default: EN
, callback: setLang'
, print: show } []
] ]
] ]
, R2.row , R2.row
...@@ -483,7 +488,7 @@ type UploadTermButtonProps = ...@@ -483,7 +488,7 @@ type UploadTermButtonProps =
) )
uploadTermButton :: R2.Leaf UploadTermButtonProps uploadTermButton :: R2.Leaf UploadTermButtonProps
uploadTermButton props = R.createElement uploadTermButtonCpt props [] uploadTermButton = R2.leafComponent uploadTermButtonCpt
uploadTermButtonCpt :: R.Component UploadTermButtonProps uploadTermButtonCpt :: R.Component UploadTermButtonProps
uploadTermButtonCpt = here.component "uploadTermButton" cpt uploadTermButtonCpt = here.component "uploadTermButton" cpt
where where
......
...@@ -43,7 +43,7 @@ type CommonProps = ...@@ -43,7 +43,7 @@ type CommonProps =
, session :: Session ) , session :: Session )
nodePopupView :: R2.Leaf NodePopupProps nodePopupView :: R2.Leaf NodePopupProps
nodePopupView p = R.createElement nodePopupCpt p [] nodePopupView = R2.leafComponent nodePopupCpt
nodePopupCpt :: R.Component NodePopupProps nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = here.component "nodePopupView" cpt where nodePopupCpt = here.component "nodePopupView" cpt where
cpt p@{ id, name, nodeType } _ = do cpt p@{ id, name, nodeType } _ = do
...@@ -178,7 +178,7 @@ type PanelActionProps = ...@@ -178,7 +178,7 @@ type PanelActionProps =
) )
panelAction :: R2.Leaf PanelActionProps panelAction :: R2.Leaf PanelActionProps
panelAction p = R.createElement panelActionCpt p [] panelAction = R2.leafComponent panelActionCpt
panelActionCpt :: R.Component PanelActionProps panelActionCpt :: R.Component PanelActionProps
panelActionCpt = here.component "panelAction" cpt panelActionCpt = here.component "panelAction" cpt
where where
......
...@@ -198,7 +198,7 @@ settingsBox Corpus = ...@@ -198,7 +198,7 @@ settingsBox Corpus =
settingsBox NodeTexts = settingsBox NodeTexts =
SettingsBox { show : true SettingsBox { show : true
, edit : false , edit : true
, doc : Documentation NodeTexts , doc : Documentation NodeTexts
, buttons : [ Refresh , buttons : [ Refresh
, Upload , Upload
...@@ -268,7 +268,7 @@ settingsBox (NodePublic FolderPublic) = ...@@ -268,7 +268,7 @@ settingsBox (NodePublic FolderPublic) =
settingsBox NodeList = settingsBox NodeList =
SettingsBox { show : true SettingsBox { show : true
, edit : false , edit : true
, doc : Documentation NodeList , doc : Documentation NodeList
, buttons : [ Refresh , buttons : [ Refresh
, Config , Config
......
...@@ -11,6 +11,7 @@ import Effect.Aff (Aff, launchAff, launchAff_) ...@@ -11,6 +11,7 @@ import Effect.Aff (Aff, launchAff, launchAff_)
import Gargantext.Components.App.Data (Boxes) import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree.Node.Action (icon, text) import Gargantext.Components.Forest.Tree.Node.Action (icon, text)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action)
import Gargantext.Components.GraphExplorer.Types (mCameraP)
import Gargantext.Components.InputWithEnter (inputWithEnter) import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Prelude (class Ord, class Read, class Show, Unit, bind, const, discard, map, not, pure, read, show, when, mempty, ($), (<), (<<<), (<>), (<$>), (<*>)) import Gargantext.Prelude (class Ord, class Read, class Show, Unit, bind, const, discard, map, not, pure, read, show, when, mempty, ($), (<), (<<<), (<>), (<$>), (<*>))
...@@ -23,6 +24,7 @@ import Gargantext.Utils.Reactix as R2 ...@@ -23,6 +24,7 @@ import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Toestand as T import Toestand as T
import Web.HTML.ValidityState (valid)
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools" here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools"
...@@ -104,73 +106,80 @@ formEdit defaultValue setter = ...@@ -104,73 +106,80 @@ formEdit defaultValue setter =
, placeholder: defaultValue, className: "form-control" } , placeholder: defaultValue, className: "form-control" }
] where input = setter <<< const <<< R.unsafeEventValue ] where input = setter <<< const <<< R.unsafeEventValue
type FormChoiceSafeProps item m =
( items :: Array item
, default :: item
, callback :: item -> Effect m
, print :: item -> String )
-- | Form Choice input -- | Form Choice input
-- if the list of options is not big enough, a button is used instead -- if the list of options is not big enough, a button is used instead
formChoiceSafe :: forall item m formChoiceSafe :: forall item m
. Read item . Read item
=> Show item => Show item
=> Array item => R2.Component (FormChoiceSafeProps item m)
-> item formChoiceSafe = R.createElement formChoiceSafeCpt
-> (item -> Effect m) formChoiceSafeCpt :: forall item m. Read item => Show item => R.Component (FormChoiceSafeProps item m)
-> (item -> String) formChoiceSafeCpt = here.component "formChoiceSafe" cpt where
-> R.Element cpt { items, default, callback, print } _ = do
formChoiceSafe [] _ _ _ = mempty pure $ case items of
formChoiceSafe [n] _ cbk prnt = formButton n cbk prnt [] -> H.div {} []
formChoiceSafe arr def cbk prnt = formChoice arr def cbk prnt [n] -> formButton { item: n, callback, print } []
_ -> formChoice { items, default, callback, print } []
type FormChoiceProps item m =
( items :: Array item
, default :: item
, callback :: item -> Effect m
, print :: item -> String )
-- | List Form -- | List Form
formChoice :: forall item m formChoice :: forall item m
. Read item . Read item
=> Show item => Show item
=> Array item => R2.Component (FormChoiceProps item m)
-> item formChoice = R.createElement formChoiceCpt
-> (item -> Effect m) formChoiceCpt :: forall item m. Read item => Show item => R.Component (FormChoiceProps item m)
-> (item -> String) formChoiceCpt = here.component "formChoice" cpt where
-> R.Element cpt { items, callback, default, print } _ = do
formChoice items def cbk prnt = pure $ H.div { className: "form-group"}
[
H.div { className: "form-group"} R2.select
[ { className: "form-control with-icon-font"
R2.select , on: { change }
{ className: "form-control with-icon-font" } $ map option items
, on: { change } ]
} $
map option items
]
where where
change e = cbk $ fromMaybe def $ read $ R.unsafeEventValue e change e = callback $ fromMaybe default $ read $ R.unsafeEventValue e
option opt = H.option { value: show opt } [ H.text $ print opt ]
option opt = type FormButtonProps item m =
H.option { value: show opt } ( item :: item
[ H.text $ prnt opt ] , callback :: item -> Effect m
, print :: item -> String )
-- | Button Form -- | Button Form
-- FIXME: currently needs a click from the user (by default, we could avoid such click) -- FIXME: currently needs a click from the user (by default, we could avoid such click)
formButton :: forall item m formButton :: forall item m. R2.Component (FormButtonProps item m)
. item formButton = R.createElement formButtonCpt
-> (item -> Effect m) formButtonCpt :: forall item m. R.Component (FormButtonProps item m)
-> (item -> String) formButtonCpt = here.component "formButton" cpt where
-> R.Element cpt { item, callback, print} _ = do
formButton item cbk prnt = pure $ H.div {}
[ H.text $ "Confirm the selection of: " <> print item
H.div {} , cta ]
[
H.text $ "Confirm the selection of: " <> prnt item
,
cta
]
where where
cta = cta =
H.button H.button { className : "cold-md-5 btn btn-primary center"
{ className : "cold-md-5 btn btn-primary center" , type : "button"
, type : "button" , title: "Form Button"
, title: "Form Button" , style : { width: "100%" }
, style : { width: "100%" } , on: { click: \_ -> callback item }
, on: { click: \_ -> cbk item } }
} [ H.text "Confirmation" ]
[ H.text "Confirmation" ]
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
...@@ -201,7 +210,7 @@ type CheckboxProps = ...@@ -201,7 +210,7 @@ type CheckboxProps =
( value :: T.Box Boolean ) ( value :: T.Box Boolean )
checkbox :: R2.Leaf CheckboxProps checkbox :: R2.Leaf CheckboxProps
checkbox props = R.createElement checkboxCpt props [] checkbox = R2.leafComponent checkboxCpt
checkboxCpt :: R.Component CheckboxProps checkboxCpt :: R.Component CheckboxProps
checkboxCpt = here.component "checkbox" cpt checkboxCpt = here.component "checkbox" cpt
where where
......
...@@ -16,7 +16,7 @@ here = R2.here "Gargantext.Components.GraphExplorer.ControlsToggleButton" ...@@ -16,7 +16,7 @@ here = R2.here "Gargantext.Components.GraphExplorer.ControlsToggleButton"
type Props = ( state :: T.Box Boolean ) type Props = ( state :: T.Box Boolean )
controlsToggleButton :: R2.Leaf Props controlsToggleButton :: R2.Leaf Props
controlsToggleButton props = R.createElement controlsToggleButtonCpt props [] controlsToggleButton = R2.leafComponent controlsToggleButtonCpt
controlsToggleButtonCpt :: R.Component Props controlsToggleButtonCpt :: R.Component Props
controlsToggleButtonCpt = here.component "controlsToggleButton" cpt controlsToggleButtonCpt = here.component "controlsToggleButton" cpt
......
...@@ -320,7 +320,7 @@ type BadgeProps = ...@@ -320,7 +320,7 @@ type BadgeProps =
, selectedNodeIds :: T.Box SigmaxT.NodeIds ) , selectedNodeIds :: T.Box SigmaxT.NodeIds )
badge :: R2.Leaf BadgeProps badge :: R2.Leaf BadgeProps
badge props = R.createElement badgeCpt props [] badge = R2.leafComponent badgeCpt
badgeCpt :: R.Component BadgeProps badgeCpt :: R.Component BadgeProps
badgeCpt = here.component "badge" cpt where badgeCpt = here.component "badge" cpt where
cpt { maxSize, minSize, node: { id, label, size }, selectedNodeIds } _ = do cpt { maxSize, minSize, node: { id, label, size }, selectedNodeIds } _ = do
......
...@@ -22,7 +22,7 @@ type TopBar = ...@@ -22,7 +22,7 @@ type TopBar =
) )
topBar :: R2.Leaf TopBar topBar :: R2.Leaf TopBar
topBar p = R.createElement topBarCpt p [] topBar = R2.leafComponent topBarCpt
topBarCpt :: R.Component TopBar topBarCpt :: R.Component TopBar
topBarCpt = here.component "topBar" cpt where topBarCpt = here.component "topBar" cpt where
cpt { boxes: { sidePanelGraph cpt { boxes: { sidePanelGraph
......
...@@ -10,8 +10,8 @@ import Gargantext.Utils.Reactix as R2 ...@@ -10,8 +10,8 @@ import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.InputWithEnter" here = R2.here "Gargantext.Components.InputWithEnter"
type Props a = ( type Props a =
onBlur :: String -> Effect Unit ( onBlur :: String -> Effect Unit
, onEnter :: Unit -> Effect Unit , onEnter :: Unit -> Effect Unit
, onValueChanged :: String -> Effect Unit , onValueChanged :: String -> Effect Unit
...@@ -22,9 +22,25 @@ type Props a = ( ...@@ -22,9 +22,25 @@ type Props a = (
, type :: String , type :: String
) )
inputWithEnter :: forall a. Record (Props a) -> R.Element type PropsKey a =
inputWithEnter props = R.createElement inputWithEnterCpt props [] ( key :: String
| Props a )
inputWithEnterWithKey :: forall a. R2.Leaf (PropsKey a)
inputWithEnterWithKey = R2.leafComponent inputWithEnterWithKeyCpt
inputWithEnterWithKeyCpt = here.component "inputWithEnterWithKey" cpt where
cpt { onBlur, onEnter, onValueChanged, autoFocus, className, defaultValue, placeholder, type: t } _ = do
pure $ inputWithEnter { onBlur
, onEnter
, onValueChanged
, autoFocus
, className
, defaultValue
, placeholder
, type: t }
inputWithEnter :: forall a. R2.Leaf (Props a)
inputWithEnter = R2.leafComponent inputWithEnterCpt
inputWithEnterCpt :: forall a. R.Component (Props a) inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = here.component "inputWithEnter" cpt inputWithEnterCpt = here.component "inputWithEnter" cpt
where where
......
...@@ -31,9 +31,12 @@ selectionCpt :: R.Component Props ...@@ -31,9 +31,12 @@ selectionCpt :: R.Component Props
selectionCpt = here.component "selection" cpt where selectionCpt = here.component "selection" cpt where
cpt { selection, session } _ = do cpt { selection, session } _ = do
pure $ H.div { className: "list-selection" } pure $ H.div { className: "list-selection" }
[ formChoiceSafe [ MyListsFirst [ formChoiceSafe { items: [ MyListsFirst
, OtherListsFirst , OtherListsFirst
, SelectedLists [] ] MyListsFirst setSelection show , SelectedLists [] ]
, default: MyListsFirst
, callback: setSelection
, print: show } []
, selectedIds { selection, session } [] , selectedIds { selection, session } []
] ]
where where
...@@ -159,7 +162,7 @@ type RenderListElementProps = ...@@ -159,7 +162,7 @@ type RenderListElementProps =
, selection :: T.Box Selection ) , selection :: T.Box Selection )
renderListElement :: R2.Leaf RenderListElementProps renderListElement :: R2.Leaf RenderListElementProps
renderListElement props = R.createElement renderListElementCpt props [] renderListElement = R2.leafComponent renderListElementCpt
renderListElementCpt :: R.Component RenderListElementProps renderListElementCpt :: R.Component RenderListElementProps
renderListElementCpt = here.component "renderListElement" cpt where renderListElementCpt = here.component "renderListElement" cpt where
cpt { id, name, selection } _ = do cpt { id, name, selection } _ = do
......
...@@ -38,7 +38,7 @@ type Props = ...@@ -38,7 +38,7 @@ type Props =
) )
login :: R2.Leaf Props login :: R2.Leaf Props
login props = R.createElement loginCpt props [] login = R2.leafComponent loginCpt
loginCpt :: R.Component Props loginCpt :: R.Component Props
loginCpt = here.component "login" cpt where loginCpt = here.component "login" cpt where
...@@ -49,7 +49,7 @@ loginCpt = here.component "login" cpt where ...@@ -49,7 +49,7 @@ loginCpt = here.component "login" cpt where
inner (Just b) = form { backend: b, sessions, visible } inner (Just b) = form { backend: b, sessions, visible }
chooser :: R2.Leaf Props chooser :: R2.Leaf Props
chooser props = R.createElement chooserCpt props [] chooser = R2.leafComponent chooserCpt
chooserCpt :: R.Component Props chooserCpt :: R.Component Props
chooserCpt = here.component "chooser" cpt where chooserCpt = here.component "chooser" cpt where
......
...@@ -86,7 +86,7 @@ type SubmitButtonProps s v = ( cell :: T.Box Form | Props s v ) ...@@ -86,7 +86,7 @@ type SubmitButtonProps s v = ( cell :: T.Box Form | Props s v )
submitButton submitButton
:: forall s v. T.ReadWrite s Sessions => T.Write v Boolean :: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
=> R2.Leaf (SubmitButtonProps s v) => R2.Leaf (SubmitButtonProps s v)
submitButton props = R.createElement submitButtonCpt props [] submitButton = R2.leafComponent submitButtonCpt
submitButtonCpt submitButtonCpt
:: forall s v. T.ReadWrite s Sessions => T.Write v Boolean :: forall s v. T.ReadWrite s Sessions => T.Write v Boolean
......
...@@ -31,7 +31,7 @@ type SearchInputProps = ...@@ -31,7 +31,7 @@ type SearchInputProps =
) )
searchInput :: R2.Leaf SearchInputProps searchInput :: R2.Leaf SearchInputProps
searchInput props = R.createElement searchInputCpt props [] searchInput = R2.leafComponent searchInputCpt
searchInputCpt :: R.Component SearchInputProps searchInputCpt :: R.Component SearchInputProps
searchInputCpt = here.component "searchInput" cpt searchInputCpt = here.component "searchInput" cpt
where where
......
...@@ -54,8 +54,7 @@ type LayoutProps = ...@@ -54,8 +54,7 @@ type LayoutProps =
) )
annuaireLayout :: R2.Leaf LayoutProps annuaireLayout :: R2.Leaf LayoutProps
annuaireLayout props = R.createElement annuaireLayoutCpt props [] annuaireLayout = R2.leafComponent annuaireLayoutCpt
annuaireLayoutCpt :: R.Component LayoutProps annuaireLayoutCpt :: R.Component LayoutProps
annuaireLayoutCpt = here.component "annuaireLayout" cpt where annuaireLayoutCpt = here.component "annuaireLayout" cpt where
cpt { frontends, nodeId, session } _ = do cpt { frontends, nodeId, session } _ = do
...@@ -69,7 +68,7 @@ type KeyLayoutProps = ...@@ -69,7 +68,7 @@ type KeyLayoutProps =
) )
annuaireLayoutWithKey :: R2.Leaf KeyLayoutProps annuaireLayoutWithKey :: R2.Leaf KeyLayoutProps
annuaireLayoutWithKey props = R.createElement annuaireLayoutWithKeyCpt props [] annuaireLayoutWithKey = R2.leafComponent annuaireLayoutWithKeyCpt
annuaireLayoutWithKeyCpt :: R.Component KeyLayoutProps annuaireLayoutWithKeyCpt :: R.Component KeyLayoutProps
annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where annuaireLayoutWithKeyCpt = here.component "annuaireLayoutWithKey" cpt where
...@@ -93,7 +92,7 @@ type AnnuaireProps = ...@@ -93,7 +92,7 @@ type AnnuaireProps =
-- | Renders a basic table and the page loader -- | Renders a basic table and the page loader
annuaire :: R2.Leaf AnnuaireProps annuaire :: R2.Leaf AnnuaireProps
annuaire props = R.createElement annuaireCpt props [] annuaire = R2.leafComponent annuaireCpt
-- Abuses closure to work around the Loader -- Abuses closure to work around the Loader
annuaireCpt :: R.Component AnnuaireProps annuaireCpt :: R.Component AnnuaireProps
......
...@@ -61,7 +61,7 @@ type TabsProps = ...@@ -61,7 +61,7 @@ type TabsProps =
) )
tabs :: R2.Leaf TabsProps tabs :: R2.Leaf TabsProps
tabs props = R.createElement tabsCpt props [] tabs = R2.leafComponent tabsCpt
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt where tabsCpt = here.component "tabs" cpt where
cpt props _ = do cpt props _ = do
...@@ -105,7 +105,7 @@ type NgramsViewTabsProps = ...@@ -105,7 +105,7 @@ type NgramsViewTabsProps =
| TabsProps ) | TabsProps )
ngramsView :: R2.Leaf NgramsViewTabsProps ngramsView :: R2.Leaf NgramsViewTabsProps
ngramsView props = R.createElement ngramsViewCpt props [] ngramsView = R2.leafComponent ngramsViewCpt
ngramsViewCpt :: R.Component NgramsViewTabsProps ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = here.component "ngramsView" cpt where ngramsViewCpt = here.component "ngramsView" cpt where
cpt props@{ defaultListId, mode, nodeId, session } _ = do cpt props@{ defaultListId, mode, nodeId, session } _ = do
......
...@@ -91,7 +91,7 @@ userLayoutCpt = here.component "userLayout" cpt ...@@ -91,7 +91,7 @@ userLayoutCpt = here.component "userLayout" cpt
pure $ userLayoutWithKey $ Record.merge props { key: show sid <> "-" <> show nodeId } pure $ userLayoutWithKey $ Record.merge props { key: show sid <> "-" <> show nodeId }
userLayoutWithKey :: R2.Leaf KeyLayoutProps userLayoutWithKey :: R2.Leaf KeyLayoutProps
userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props [] userLayoutWithKey = R2.leafComponent userLayoutWithKeyCpt
userLayoutWithKeyCpt :: R.Component KeyLayoutProps userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where userLayoutWithKeyCpt = here.component "userLayoutWithKey" cpt where
cpt { boxes: boxes@{ sidePanelTexts } cpt { boxes: boxes@{ sidePanelTexts }
......
...@@ -97,7 +97,7 @@ type ContactInfoItemProps = ...@@ -97,7 +97,7 @@ type ContactInfoItemProps =
) )
contactInfoItem :: R2.Leaf ContactInfoItemProps contactInfoItem :: R2.Leaf ContactInfoItemProps
contactInfoItem props = R.createElement contactInfoItemCpt props [] contactInfoItem = R2.leafComponent contactInfoItemCpt
contactInfoItemCpt :: R.Component ContactInfoItemProps contactInfoItemCpt :: R.Component ContactInfoItemProps
contactInfoItemCpt = here.component "contactInfoItem" cpt contactInfoItemCpt = here.component "contactInfoItem" cpt
where where
...@@ -129,7 +129,7 @@ type ItemProps = ...@@ -129,7 +129,7 @@ type ItemProps =
) )
itemNotEditing :: R2.Leaf ItemProps itemNotEditing :: R2.Leaf ItemProps
itemNotEditing props = R.createElement itemNotEditingCpt props [] itemNotEditing = R2.leafComponent itemNotEditingCpt
itemNotEditingCpt :: R.Component ItemProps itemNotEditingCpt :: R.Component ItemProps
itemNotEditingCpt = here.component "itemEditing" cpt where itemNotEditingCpt = here.component "itemEditing" cpt where
cpt { isEditing, valueBox } _ = do cpt { isEditing, valueBox } _ = do
...@@ -146,7 +146,7 @@ itemNotEditingCpt = here.component "itemEditing" cpt where ...@@ -146,7 +146,7 @@ itemNotEditingCpt = here.component "itemEditing" cpt where
click _ = T.write_ true isEditing click _ = T.write_ true isEditing
itemEditing :: R2.Leaf ItemProps itemEditing :: R2.Leaf ItemProps
itemEditing props = R.createElement itemEditingCpt props [] itemEditing = R2.leafComponent itemEditingCpt
itemEditingCpt :: R.Component ItemProps itemEditingCpt :: R.Component ItemProps
itemEditingCpt = here.component "itemNotEditing" cpt where itemEditingCpt = here.component "itemNotEditing" cpt where
cpt { defaultVal, isEditing, lens, onUpdateUserInfo, userInfo, valueBox } _ = do cpt { defaultVal, isEditing, lens, onUpdateUserInfo, userInfo, valueBox } _ = do
...@@ -231,7 +231,7 @@ contactLayoutCpt = here.component "contactLayout" cpt where ...@@ -231,7 +231,7 @@ contactLayoutCpt = here.component "contactLayout" cpt where
contactLayoutWithKey $ Record.merge props { key } contactLayoutWithKey $ Record.merge props { key }
contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps contactLayoutWithKey :: R2.Leaf AnnuaireKeyLayoutProps
contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props [] contactLayoutWithKey = R2.leafComponent contactLayoutWithKeyCpt
contactLayoutWithKeyCpt :: R.Component AnnuaireKeyLayoutProps contactLayoutWithKeyCpt :: R.Component AnnuaireKeyLayoutProps
contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
cpt { annuaireId cpt { annuaireId
......
...@@ -58,7 +58,7 @@ type TabsProps = ...@@ -58,7 +58,7 @@ type TabsProps =
) )
tabs :: R2.Leaf TabsProps tabs :: R2.Leaf TabsProps
tabs props = R.createElement tabsCpt props [] tabs = R2.leafComponent tabsCpt
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt tabsCpt = here.component "tabs" cpt
where where
......
...@@ -42,7 +42,7 @@ type Props = ...@@ -42,7 +42,7 @@ type Props =
, session :: Session ) , session :: Session )
corpusLayout :: R2.Leaf Props corpusLayout :: R2.Leaf Props
corpusLayout props = R.createElement corpusLayoutCpt props [] corpusLayout = R2.leafComponent corpusLayoutCpt
corpusLayoutCpt :: R.Component Props corpusLayoutCpt :: R.Component Props
corpusLayoutCpt = here.component "corpusLayout" cpt where corpusLayoutCpt = here.component "corpusLayout" cpt where
cpt { boxes, nodeId, session } _ = do cpt { boxes, nodeId, session } _ = do
...@@ -58,7 +58,7 @@ type KeyProps = ...@@ -58,7 +58,7 @@ type KeyProps =
) )
corpusLayoutMain :: R2.Leaf KeyProps corpusLayoutMain :: R2.Leaf KeyProps
corpusLayoutMain props = R.createElement corpusLayoutMainCpt props [] corpusLayoutMain = R2.leafComponent corpusLayoutMainCpt
corpusLayoutMainCpt :: R.Component KeyProps corpusLayoutMainCpt :: R.Component KeyProps
corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
where where
......
...@@ -97,7 +97,7 @@ mkRequest :: Session -> ReloadPath -> GUC.Request ...@@ -97,7 +97,7 @@ mkRequest :: Session -> ReloadPath -> GUC.Request
mkRequest session (_ /\ path) = GUC.makeGetRequest session $ chartUrl path mkRequest session (_ /\ path) = GUC.makeGetRequest session $ chartUrl path
pie :: R2.Leaf Props pie :: R2.Leaf Props
pie props = R.createElement pieCpt props [] pie = R2.leafComponent pieCpt
pieCpt :: R.Component Props pieCpt :: R.Component Props
pieCpt = here.component "pie" cpt pieCpt = here.component "pie" cpt
where where
......
...@@ -41,7 +41,7 @@ type ViewProps = ...@@ -41,7 +41,7 @@ type ViewProps =
) )
corpusCodeLayout :: R2.Leaf Props corpusCodeLayout :: R2.Leaf Props
corpusCodeLayout props = R.createElement corpusCodeLayoutCpt props [] corpusCodeLayout = R2.leafComponent corpusCodeLayoutCpt
corpusCodeLayoutCpt :: R.Component Props corpusCodeLayoutCpt :: R.Component Props
corpusCodeLayoutCpt = here.component "corpusCodeLayout" cpt where corpusCodeLayoutCpt = here.component "corpusCodeLayout" cpt where
cpt { nodeId, session, boxes } _ = do cpt { nodeId, session, boxes } _ = do
......
...@@ -48,7 +48,7 @@ instance Eq File where ...@@ -48,7 +48,7 @@ instance Eq File where
type FileLayoutProps = ( nodeId :: NodeID, session :: Session ) type FileLayoutProps = ( nodeId :: NodeID, session :: Session )
fileLayout :: R2.Leaf FileLayoutProps fileLayout :: R2.Leaf FileLayoutProps
fileLayout props = R.createElement fileLayoutCpt props [] fileLayout = R2.leafComponent fileLayoutCpt
fileLayoutCpt :: R.Component FileLayoutProps fileLayoutCpt :: R.Component FileLayoutProps
fileLayoutCpt = here.component "fileLayout" cpt where fileLayoutCpt = here.component "fileLayout" cpt where
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
......
...@@ -48,7 +48,7 @@ type KeyProps = ...@@ -48,7 +48,7 @@ type KeyProps =
) )
frameLayout :: R2.Leaf Props frameLayout :: R2.Leaf Props
frameLayout props = R.createElement frameLayoutCpt props [] frameLayout = R2.leafComponent frameLayoutCpt
frameLayoutCpt :: R.Component Props frameLayoutCpt :: R.Component Props
frameLayoutCpt = here.component "frameLayout" cpt where frameLayoutCpt = here.component "frameLayout" cpt where
cpt { nodeId, nodeType, session } _ = do cpt { nodeId, nodeType, session } _ = do
...@@ -57,7 +57,7 @@ frameLayoutCpt = here.component "frameLayout" cpt where ...@@ -57,7 +57,7 @@ frameLayoutCpt = here.component "frameLayout" cpt where
key = show (sessionId session) <> "-" <> show nodeId key = show (sessionId session) <> "-" <> show nodeId
frameLayoutWithKey :: R2.Leaf KeyProps frameLayoutWithKey :: R2.Leaf KeyProps
frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props [] frameLayoutWithKey = R2.leafComponent frameLayoutWithKeyCpt
frameLayoutWithKeyCpt :: R.Component KeyProps frameLayoutWithKeyCpt :: R.Component KeyProps
frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where frameLayoutWithKeyCpt = here.component "frameLayoutWithKey" cpt where
cpt { nodeId, session, nodeType} _ = do cpt { nodeId, session, nodeType} _ = do
...@@ -89,7 +89,7 @@ hframeUrl NodeFrameVisio base frame_id = base <> "/" <> frame_id ...@@ -89,7 +89,7 @@ hframeUrl NodeFrameVisio base frame_id = base <> "/" <> frame_id
hframeUrl _ base frame_id = base <> "/" <> frame_id <> "?view" -- "?both" hframeUrl _ base frame_id = base <> "/" <> frame_id <> "?view" -- "?both"
frameLayoutView :: R2.Leaf ViewProps frameLayoutView :: R2.Leaf ViewProps
frameLayoutView props = R.createElement frameLayoutViewCpt props [] frameLayoutView = R2.leafComponent frameLayoutViewCpt
frameLayoutViewCpt :: R.Component ViewProps frameLayoutViewCpt :: R.Component ViewProps
frameLayoutViewCpt = here.component "frameLayoutView" cpt frameLayoutViewCpt = here.component "frameLayoutView" cpt
where where
...@@ -123,7 +123,7 @@ type NodeFrameVisioProps = ...@@ -123,7 +123,7 @@ type NodeFrameVisioProps =
) )
nodeFrameVisio :: R2.Leaf NodeFrameVisioProps nodeFrameVisio :: R2.Leaf NodeFrameVisioProps
nodeFrameVisio props = R.createElement nodeFrameVisioCpt props [] nodeFrameVisio = R2.leafComponent nodeFrameVisioCpt
nodeFrameVisioCpt :: R.Component NodeFrameVisioProps nodeFrameVisioCpt :: R.Component NodeFrameVisioProps
nodeFrameVisioCpt = here.component "nodeFrameVisio" cpt nodeFrameVisioCpt = here.component "nodeFrameVisio" cpt
where where
......
...@@ -57,7 +57,7 @@ type HomeProps = ...@@ -57,7 +57,7 @@ type HomeProps =
) )
homeLayout :: R2.Leaf HomeProps homeLayout :: R2.Leaf HomeProps
homeLayout props = R.createElement homeLayoutCpt props [] homeLayout = R2.leafComponent homeLayoutCpt
homeLayoutCpt :: R.Component HomeProps homeLayoutCpt :: R.Component HomeProps
homeLayoutCpt = here.component "homeLayout" cpt homeLayoutCpt = here.component "homeLayout" cpt
where where
...@@ -152,7 +152,7 @@ type TutorialProps = ...@@ -152,7 +152,7 @@ type TutorialProps =
, sessions :: Array Session ) , sessions :: Array Session )
tutorial :: R2.Leaf TutorialProps tutorial :: R2.Leaf TutorialProps
tutorial props = R.createElement tutorialCpt props [] tutorial = R2.leafComponent tutorialCpt
tutorialCpt :: R.Component TutorialProps tutorialCpt :: R.Component TutorialProps
tutorialCpt = here.component "tutorial" cpt where tutorialCpt = here.component "tutorial" cpt where
cpt { boxes cpt { boxes
......
...@@ -66,7 +66,7 @@ loadPublicData _l = do ...@@ -66,7 +66,7 @@ loadPublicData _l = do
-} -}
renderPublic :: R2.Leaf () renderPublic :: R2.Leaf ()
renderPublic props = R.createElement renderPublicCpt props [] renderPublic = R2.leafComponent renderPublicCpt
renderPublicCpt :: R.Component () renderPublicCpt :: R.Component ()
renderPublicCpt = here.component "renderPublic" cpt where renderPublicCpt = here.component "renderPublic" cpt where
cpt _ _ = do cpt _ _ = do
......
...@@ -62,7 +62,7 @@ type SessionNodeProps = ( nodeId :: NodeID | SessionProps ) ...@@ -62,7 +62,7 @@ type SessionNodeProps = ( nodeId :: NodeID | SessionProps )
type Props' = ( backend :: Backend, route' :: AppRoute | Props ) type Props' = ( backend :: Backend, route' :: AppRoute | Props )
router :: R2.Leaf Props router :: R2.Leaf Props
router props = R.createElement routerCpt props [] router = R2.leafComponent routerCpt
routerCpt :: R.Component Props routerCpt :: R.Component Props
routerCpt = here.component "router" cpt where routerCpt = here.component "router" cpt where
cpt { boxes: boxes@{ handed } } _ = do cpt { boxes: boxes@{ handed } } _ = do
...@@ -85,7 +85,7 @@ routerCpt = here.component "router" cpt where ...@@ -85,7 +85,7 @@ routerCpt = here.component "router" cpt where
loginModal :: R2.Leaf Props loginModal :: R2.Leaf Props
loginModal p = R.createElement loginModalCpt p [] loginModal = R2.leafComponent loginModalCpt
loginModalCpt :: R.Component Props loginModalCpt :: R.Component Props
loginModalCpt = here.component "loginModal" cpt loginModalCpt = here.component "loginModal" cpt
where where
...@@ -95,7 +95,7 @@ loginModalCpt = here.component "loginModal" cpt ...@@ -95,7 +95,7 @@ loginModalCpt = here.component "loginModal" cpt
pure $ if showLogin' then login' boxes else H.div {} [] pure $ if showLogin' then login' boxes else H.div {} []
topBar :: R2.Leaf Props topBar :: R2.Leaf Props
topBar p = R.createElement topBarCpt p [] topBar = R2.leafComponent topBarCpt
topBarCpt :: R.Component Props topBarCpt :: R.Component Props
topBarCpt = here.component "topBar" cpt where topBarCpt = here.component "topBar" cpt where
cpt { boxes: boxes@{ route } } _ = do cpt { boxes: boxes@{ route } } _ = do
...@@ -108,7 +108,7 @@ topBarCpt = here.component "topBar" cpt where ...@@ -108,7 +108,7 @@ topBarCpt = here.component "topBar" cpt where
pure $ TopBar.topBar { boxes } children pure $ TopBar.topBar { boxes } children
mainPage :: R2.Leaf Props mainPage :: R2.Leaf Props
mainPage p = R.createElement mainPageCpt p [] mainPage = R2.leafComponent mainPageCpt
mainPageCpt :: R.Component Props mainPageCpt :: R.Component Props
mainPageCpt = here.component "mainPage" cpt where mainPageCpt = here.component "mainPage" cpt where
cpt { boxes } _ = do cpt { boxes } _ = do
...@@ -197,7 +197,7 @@ mainPageCpt = here.component "mainPage" cpt where ...@@ -197,7 +197,7 @@ mainPageCpt = here.component "mainPage" cpt where
forest :: R2.Leaf Props forest :: R2.Leaf Props
forest p = R.createElement forestCpt p [] forest = R2.leafComponent forestCpt
forestCpt :: R.Component Props forestCpt :: R.Component Props
forestCpt = here.component "forest" cpt where forestCpt = here.component "forest" cpt where
cpt { boxes: boxes@{ showTree } } _ = do cpt { boxes: boxes@{ showTree } } _ = do
...@@ -212,7 +212,7 @@ forestCpt = here.component "forest" cpt where ...@@ -212,7 +212,7 @@ forestCpt = here.component "forest" cpt where
, frontends: defaultFrontends } [] , frontends: defaultFrontends } []
sidePanel :: R2.Leaf Props sidePanel :: R2.Leaf Props
sidePanel p = R.createElement sidePanelCpt p [] sidePanel = R2.leafComponent sidePanelCpt
sidePanelCpt :: R.Component Props sidePanelCpt :: R.Component Props
sidePanelCpt = here.component "sidePanel" cpt where sidePanelCpt = here.component "sidePanel" cpt where
cpt props@{ boxes: { session cpt props@{ boxes: { session
...@@ -233,7 +233,7 @@ type RenderRouteProps = ...@@ -233,7 +233,7 @@ type RenderRouteProps =
) )
renderRoute :: R2.Leaf RenderRouteProps renderRoute :: R2.Leaf RenderRouteProps
renderRoute p = R.createElement renderRouteCpt p [] renderRoute = R2.leafComponent renderRouteCpt
renderRouteCpt :: R.Component RenderRouteProps renderRouteCpt :: R.Component RenderRouteProps
renderRouteCpt = here.component "renderRoute" cpt where renderRouteCpt = here.component "renderRoute" cpt where
cpt { boxes, route } _ = do cpt { boxes, route } _ = do
......
...@@ -20,7 +20,7 @@ type TabsProps = ( ...@@ -20,7 +20,7 @@ type TabsProps = (
) )
tabs :: R2.Leaf TabsProps tabs :: R2.Leaf TabsProps
tabs props = R.createElement tabsCpt props [] tabs = R2.leafComponent tabsCpt
-- this is actually just the list of tabs, not the tab contents itself -- this is actually just the list of tabs, not the tab contents itself
tabsCpt :: R.Component TabsProps tabsCpt :: R.Component TabsProps
tabsCpt = here.component "tabs" cpt where tabsCpt = here.component "tabs" cpt where
......
...@@ -113,7 +113,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt ...@@ -113,7 +113,7 @@ tableHeaderLayoutCpt = here.component "tableHeaderLayout" cpt
cacheStateToggle NT.CacheOff = NT.CacheOn cacheStateToggle NT.CacheOff = NT.CacheOn
table :: R2.Leaf Props table :: R2.Leaf Props
table props = R.createElement tableCpt props [] table = R2.leafComponent tableCpt
tableCpt :: R.Component Props tableCpt :: R.Component Props
tableCpt = here.component "table" cpt tableCpt = here.component "table" cpt
where where
...@@ -237,7 +237,7 @@ type PaginationProps = ...@@ -237,7 +237,7 @@ type PaginationProps =
, totalPages :: Int ) , totalPages :: Int )
pagination :: R2.Leaf PaginationProps pagination :: R2.Leaf PaginationProps
pagination props = R.createElement paginationCpt props [] pagination = R2.leafComponent paginationCpt
paginationCpt :: R.Component PaginationProps paginationCpt :: R.Component PaginationProps
paginationCpt = here.component "pagination" cpt paginationCpt = here.component "pagination" cpt
where where
......
...@@ -16,7 +16,8 @@ import Toestand as T ...@@ -16,7 +16,8 @@ import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Config.Utils" here = R2.here "Gargantext.Config.Utils"
handleRESTError :: forall a. T.Box (Array FrontendError) handleRESTError :: forall a.
T.Box (Array FrontendError)
-> Either RESTError a -> Either RESTError a
-> (a -> Aff Unit) -> (a -> Aff Unit)
-> Aff Unit -> Aff Unit
......
...@@ -796,6 +796,7 @@ toggleSidePanelState Opened = Closed ...@@ -796,6 +796,7 @@ toggleSidePanelState Opened = Closed
data FrontendError = data FrontendError =
FStringError { error :: String } FStringError { error :: String }
| FRESTError { error :: RESTError } | FRESTError { error :: RESTError }
| FOtherError { error :: String }
derive instance Generic FrontendError _ derive instance Generic FrontendError _
instance Eq FrontendError where eq = genericEq instance Eq FrontendError where eq = genericEq
...@@ -47,6 +47,9 @@ type Component p = Record p -> Array R.Element -> R.Element ...@@ -47,6 +47,9 @@ type Component p = Record p -> Array R.Element -> R.Element
-- | UI Component type with only required props and no child -- | UI Component type with only required props and no child
type Leaf p = Record p -> R.Element type Leaf p = Record p -> R.Element
leafComponent :: forall cpt p. (R.Component p) -> Record p -> R.Element
leafComponent cpt p = R.createElement cpt p []
-- | UI Component type containing optional props and children -- | UI Component type containing optional props and children
type OptComponent options props provided = CO.Defaults (Record options) (Record provided) (Record props) type OptComponent options props provided = CO.Defaults (Record options) (Record provided) (Record props)
=> Record provided -> Array R.Element -> R.Element => Record provided -> Array R.Element -> R.Element
......
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