Commit 62b19335 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-node-corpus-add-text-cells' of...

Merge branch 'dev-node-corpus-add-text-cells' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 4767842e 175b0065
...@@ -24,6 +24,7 @@ import Gargantext.Prelude ...@@ -24,6 +24,7 @@ import Gargantext.Prelude
import Gargantext.Utils.HighlightJS as HLJS import Gargantext.Utils.HighlightJS as HLJS
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.CodeEditor" thisModule = "Gargantext.Components.CodeEditor"
type Code = String type Code = String
......
...@@ -38,10 +38,10 @@ type Props = ( ...@@ -38,10 +38,10 @@ type Props = (
forest :: R2.Component Props forest :: R2.Component Props
forest = R.createElement forestCpt forest = R.createElement forestCpt
where
forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt
forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt
where
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, backend , backend
...@@ -124,10 +124,10 @@ type ForestLayoutProps = ( ...@@ -124,10 +124,10 @@ type ForestLayoutProps = (
forestLayout :: R2.Component ForestLayoutProps forestLayout :: R2.Component ForestLayoutProps
forestLayout props = R.createElement forestLayoutCpt props forestLayout props = R.createElement forestLayoutCpt props
where
forestLayoutCpt :: R.Component ForestLayoutProps
forestLayoutCpt = R.hooksComponentWithModule thisModule "forestLayout" cpt
forestLayoutCpt :: R.Component ForestLayoutProps
forestLayoutCpt = R.hooksComponentWithModule thisModule "forestLayout" cpt
where
cpt props@{ handed } children = do cpt props@{ handed } children = do
pure $ R.fragment [ topBar { handed } [], forestLayoutMain props children ] pure $ R.fragment [ topBar { handed } [], forestLayoutMain props children ]
...@@ -135,10 +135,10 @@ forestLayout props = R.createElement forestLayoutCpt props ...@@ -135,10 +135,10 @@ forestLayout props = R.createElement forestLayoutCpt props
-- while the remaining ones are put into the main view -- while the remaining ones are put into the main view
forestLayoutWithTopBar :: R2.Component ForestLayoutProps forestLayoutWithTopBar :: R2.Component ForestLayoutProps
forestLayoutWithTopBar props = R.createElement forestLayoutWithTopBarCpt props forestLayoutWithTopBar props = R.createElement forestLayoutWithTopBarCpt props
where
forestLayoutWithTopBarCpt :: R.Component ForestLayoutProps
forestLayoutWithTopBarCpt = R.hooksComponentWithModule thisModule "forestLayoutWithTopBar" cpt
forestLayoutWithTopBarCpt :: R.Component ForestLayoutProps
forestLayoutWithTopBarCpt = R.hooksComponentWithModule thisModule "forestLayoutWithTopBar" cpt
where
cpt props@{ handed } children = do cpt props@{ handed } children = do
let { head: topBarChild, tail: mainChildren } = let { head: topBarChild, tail: mainChildren } =
fromMaybe { head: H.div {} [], tail: [] } $ A.uncons children fromMaybe { head: H.div {} [], tail: [] } $ A.uncons children
...@@ -149,10 +149,10 @@ forestLayoutWithTopBar props = R.createElement forestLayoutWithTopBarCpt props ...@@ -149,10 +149,10 @@ forestLayoutWithTopBar props = R.createElement forestLayoutWithTopBarCpt props
forestLayoutMain :: R2.Component ForestLayoutProps forestLayoutMain :: R2.Component ForestLayoutProps
forestLayoutMain props = R.createElement forestLayoutMainCpt props forestLayoutMain props = R.createElement forestLayoutMainCpt props
where
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponentWithModule thisModule "forestLayoutMain" cpt
where
cpt props children = do cpt props children = do
pure $ forestLayoutRaw props [ pure $ forestLayoutRaw props [
mainPage {} children mainPage {} children
...@@ -160,10 +160,10 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props ...@@ -160,10 +160,10 @@ forestLayoutMain props = R.createElement forestLayoutMainCpt props
forestLayoutRaw :: R2.Component ForestLayoutProps forestLayoutRaw :: R2.Component ForestLayoutProps
forestLayoutRaw props = R.createElement forestLayoutRawCpt props forestLayoutRaw props = R.createElement forestLayoutRawCpt props
where
forestLayoutRawCpt :: R.Component ForestLayoutProps
forestLayoutRawCpt = R.hooksComponentWithModule thisModule "forestLayoutRaw" cpt
forestLayoutRawCpt :: R.Component ForestLayoutProps
forestLayoutRawCpt = R.hooksComponentWithModule thisModule "forestLayoutRaw" cpt
where
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, backend , backend
...@@ -194,10 +194,10 @@ forestLayoutRaw props = R.createElement forestLayoutRawCpt props ...@@ -194,10 +194,10 @@ forestLayoutRaw props = R.createElement forestLayoutRawCpt props
mainPage :: R2.Component () mainPage :: R2.Component ()
mainPage = R.createElement mainPageCpt mainPage = R.createElement mainPageCpt
where
mainPageCpt :: R.Component ()
mainPageCpt = R.hooksComponentWithModule thisModule "mainPage" cpt
mainPageCpt :: R.Component ()
mainPageCpt = R.hooksComponentWithModule thisModule "mainPage" cpt
where
cpt {} children = do cpt {} children = do
pure $ H.div {className: "col-md-10"} [ pure $ H.div {className: "col-md-10"} [
H.div {id: "page-wrapper"} [ H.div {id: "page-wrapper"} [
......
...@@ -63,11 +63,11 @@ type Props = ( ...@@ -63,11 +63,11 @@ type Props = (
) )
treeView :: R2.Component Props treeView :: R2.Component Props
treeView = R.createElement elCpt treeView = R.createElement treeViewCpt
where
elCpt :: R.Component Props
elCpt = R.hooksComponentWithModule thisModule "treeView" cpt
treeViewCpt :: R.Component Props
treeViewCpt = R.hooksComponentWithModule thisModule "treeView" cpt
where
cpt { appReload cpt { appReload
, asyncTasks , asyncTasks
, currentRoute , currentRoute
...@@ -90,11 +90,11 @@ treeView = R.createElement elCpt ...@@ -90,11 +90,11 @@ treeView = R.createElement elCpt
} [] } []
treeLoadView :: R2.Component Props treeLoadView :: R2.Component Props
treeLoadView = R.createElement elCpt treeLoadView = R.createElement treeLoadViewCpt
where
elCpt :: R.Component Props
elCpt = R.hooksComponentWithModule thisModule "treeLoadView" cpt
treeLoadViewCpt :: R.Component Props
treeLoadViewCpt = R.hooksComponentWithModule thisModule "treeLoadView" cpt
where
cpt { appReload cpt { appReload
, asyncTasks , asyncTasks
, currentRoute , currentRoute
...@@ -135,11 +135,11 @@ type TreeViewProps = ( ...@@ -135,11 +135,11 @@ type TreeViewProps = (
) )
loadedTreeViewFirstLevel :: R2.Component TreeViewProps loadedTreeViewFirstLevel :: R2.Component TreeViewProps
loadedTreeViewFirstLevel = R.createElement elCpt loadedTreeViewFirstLevel = R.createElement loadedTreeViewFirstLevelCpt
where
elCpt :: R.Component TreeViewProps
elCpt = R.hooksComponentWithModule thisModule "loadedTreeViewFirstLevel" cpt
loadedTreeViewFirstLevelCpt :: R.Component TreeViewProps
loadedTreeViewFirstLevelCpt = R.hooksComponentWithModule thisModule "loadedTreeViewFirstLevel" cpt
where
cpt { appReload cpt { appReload
, asyncTasks , asyncTasks
, currentRoute , currentRoute
...@@ -153,54 +153,64 @@ loadedTreeViewFirstLevel = R.createElement elCpt ...@@ -153,54 +153,64 @@ loadedTreeViewFirstLevel = R.createElement elCpt
} _ = do } _ = do
pure $ H.ul { className: "tree " <> if handed == GT.RightHanded then "mr-auto" else "ml-auto" } [ pure $ H.ul { className: "tree " <> if handed == GT.RightHanded then "mr-auto" else "ml-auto" } [
H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [ H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [
toHtmlFirstLevel { appReload toHtmlFirstLevel (ToHtmlProps { appReload
, asyncTasks , asyncTasks
, currentRoute , currentRoute
, frontends , frontends
, handed , handed
, openNodes , openNodes
, reload , reload
, reloadTree: reload , reloadTree: reload
, session , render: toHtmlFirstLevel
-- , tasks , session
, tree -- , tasks
} [] , tree
}) []
] ]
] ]
------------------------------------------------------------------------ ------------------------------------------------------------------------
type ToHtmlProps = ( newtype ToHtmlProps = ToHtmlProps {
asyncTasks :: GAT.Reductor asyncTasks :: GAT.Reductor
, reloadTree :: GUR.ReloadS , reloadTree :: GUR.ReloadS
, render :: ToHtmlProps -> Array R.Element -> R.Element
-- , tasks :: Record Tasks -- , tasks :: Record Tasks
, tree :: FTree , tree :: FTree
| CommonProps -- | CommonProps
) , appReload :: GUR.ReloadS
, currentRoute :: AppRoute
, frontends :: Frontends
, handed :: GT.Handed
, openNodes :: R.State OpenNodes
, reload :: GUR.ReloadS
, session :: Session
}
toHtmlFirstLevel :: R2.Component ToHtmlProps toHtmlFirstLevel :: ToHtmlProps -> Array R.Element -> R.Element
toHtmlFirstLevel = R.createElement elCpt toHtmlFirstLevel = R2.ntCreateElement toHtmlFirstLevelCpt
toHtmlFirstLevelCpt :: R2.NTComponent ToHtmlProps
toHtmlFirstLevelCpt = R2.ntHooksComponentWithModule thisModule "toHtmlFirstLevel" cpt
where where
elCpt :: R.Component ToHtmlProps cpt (ToHtmlProps p@{ appReload
elCpt = R.hooksComponentWithModule thisModule "toHtmlFirstLevel" cpt , asyncTasks
, currentRoute
cpt p@{ appReload , frontends
, asyncTasks , handed
, currentRoute , openNodes
, frontends , reload
, handed , reloadTree
, openNodes , render
, reload , session
, reloadTree , tree: tree@(NTree (LNode { id
, session , name
, tree: tree@(NTree (LNode { id , nodeType
, name }
, nodeType ) ary
} )
) ary }) _ = do
)
} _ = do
setPopoverRef <- R.useRef Nothing setPopoverRef <- R.useRef Nothing
let pAction a = performAction a (RecordE.pick (Record.merge p { setPopoverRef }) :: Record PerformActionProps) let pAction a = performAction a (RecordE.pick (Record.merge p { setPopoverRef }) :: Record PerformActionProps)
...@@ -250,6 +260,7 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -250,6 +260,7 @@ toHtmlFirstLevel = R.createElement elCpt
, handed , handed
, id: cId , id: cId
, reloadTree , reloadTree
, render
} }
) [] ) []
) $ sorted publicizedChildren ) $ sorted publicizedChildren
...@@ -264,15 +275,19 @@ type ChildNodeFirstLevelProps = ( ...@@ -264,15 +275,19 @@ type ChildNodeFirstLevelProps = (
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
, id :: ID , id :: ID
, reloadTree :: GUR.ReloadS , reloadTree :: GUR.ReloadS
, render :: ToHtmlProps -> Array R.Element -> R.Element
| CommonProps | CommonProps
) )
childNodeFirstLevel :: R2.Component ChildNodeFirstLevelProps childNodeFirstLevel :: R2.Component ChildNodeFirstLevelProps
childNodeFirstLevel = R.createElement elCpt childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
where
elCpt :: R.Component ChildNodeFirstLevelProps
elCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevel" cpt
-- TODO This shouldn't be here: make it a top-level function but be careful
-- about cyclic defines
-- https://discourse.purescript.org/t/strange-compiler-error-with-an-undefined-reference/2060/3
childNodeFirstLevelCpt :: R.Component ChildNodeFirstLevelProps
childNodeFirstLevelCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevel" cpt
where
cpt props@{ appReload cpt props@{ appReload
, asyncTasks , asyncTasks
, currentRoute , currentRoute
...@@ -283,6 +298,7 @@ childNodeFirstLevel = R.createElement elCpt ...@@ -283,6 +298,7 @@ childNodeFirstLevel = R.createElement elCpt
, openNodes , openNodes
, reload , reload
, reloadTree , reloadTree
, render
, session } _ = do , session } _ = do
cptReload <- GUR.new cptReload <- GUR.new
...@@ -296,6 +312,7 @@ childNodeFirstLevel = R.createElement elCpt ...@@ -296,6 +312,7 @@ childNodeFirstLevel = R.createElement elCpt
, openNodes , openNodes
, reload: cptReload , reload: cptReload
, reloadTree , reloadTree
, render
, session , session
, tree: loaded } [] , tree: loaded } []
...@@ -308,28 +325,33 @@ type ChildNodeFirstLevelPaintProps = ( ...@@ -308,28 +325,33 @@ type ChildNodeFirstLevelPaintProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
, reloadTree :: GUR.ReloadS , reloadTree :: GUR.ReloadS
, render :: ToHtmlProps -> Array R.Element -> R.Element
, tree :: FTree , tree :: FTree
| CommonProps | CommonProps
) )
childNodeFirstLevelPaint :: R2.Component ChildNodeFirstLevelPaintProps childNodeFirstLevelPaint :: R2.Component ChildNodeFirstLevelPaintProps
childNodeFirstLevelPaint = R.createElement elCpt childNodeFirstLevelPaint = R.createElement childNodeFirstLevelPaintCpt
-- TODO This shouldn't be here: make it a top-level function but be careful
-- about cyclic defines
-- https://discourse.purescript.org/t/strange-compiler-error-with-an-undefined-reference/2060/3
childNodeFirstLevelPaintCpt :: R.Component ChildNodeFirstLevelPaintProps
childNodeFirstLevelPaintCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevelPaint" cpt
-- TODO folderOpen is unused
where where
elCpt :: R.Component ChildNodeFirstLevelPaintProps
elCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevelPaint" cpt
-- TODO folderOpen is unused
cpt props@{ asyncTasks cpt props@{ asyncTasks
, handed , handed
, reload , reload
, reloadTree , reloadTree
, render
, tree: ctree@(NTree (LNode { id }) _) } _ = do , tree: ctree@(NTree (LNode { id }) _) } _ = do
pure $ H.ul {} [ pure $ H.ul {} [
toHtmlFirstLevel (Record.merge commonProps { asyncTasks render (ToHtmlProps (Record.merge commonProps { asyncTasks
, handed , handed
, reloadTree , reloadTree
, tree: ctree } , render
, tree: ctree })
) [] ) []
] ]
-- pure $ H.div { } [ H.text $ "[closed] Node id " <> show id ] -- pure $ H.div { } [ H.text $ "[closed] Node id " <> show id ]
......
...@@ -60,19 +60,19 @@ type IsLeaf = Boolean ...@@ -60,19 +60,19 @@ type IsLeaf = Boolean
nodeSpan :: R2.Component NodeMainSpanProps nodeSpan :: R2.Component NodeMainSpanProps
nodeSpan = R.createElement nodeSpanCpt nodeSpan = R.createElement nodeSpanCpt
where
nodeSpanCpt :: R.Component NodeMainSpanProps
nodeSpanCpt = R.hooksComponentWithModule thisModule "nodeSpan" cpt
nodeSpanCpt :: R.Component NodeMainSpanProps
nodeSpanCpt = R.hooksComponentWithModule thisModule "nodeSpan" cpt
where
cpt props children = do cpt props children = do
pure $ H.div {} ([ nodeMainSpan props [] ] <> children) pure $ H.div {} ([ nodeMainSpan props [] ] <> children)
nodeMainSpan :: R2.Component NodeMainSpanProps nodeMainSpan :: R2.Component NodeMainSpanProps
nodeMainSpan = R.createElement nodeMainSpanCpt nodeMainSpan = R.createElement nodeMainSpanCpt
where
nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
where
cpt props@{ appReload cpt props@{ appReload
, asyncTasks: (asyncTasks /\ dispatchAsyncTasks) , asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
, currentRoute , currentRoute
...@@ -249,10 +249,10 @@ type NodeActionsProps = ...@@ -249,10 +249,10 @@ type NodeActionsProps =
nodeActions :: Record NodeActionsProps -> R.Element nodeActions :: Record NodeActionsProps -> R.Element
nodeActions p = R.createElement nodeActionsCpt p [] nodeActions p = R.createElement nodeActionsCpt p []
where
nodeActionsCpt :: R.Component NodeActionsProps
nodeActionsCpt = R.hooksComponentWithModule thisModule "nodeActions" cpt
nodeActionsCpt :: R.Component NodeActionsProps
nodeActionsCpt = R.hooksComponentWithModule thisModule "nodeActions" cpt
where
cpt { id cpt { id
, nodeType: GT.Graph , nodeType: GT.Graph
, session , session
......
...@@ -86,7 +86,6 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p [] ...@@ -86,7 +86,6 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
onEnter: \_ -> launchAff_ $ dispatch (AddNode name' nt') onEnter: \_ -> launchAff_ $ dispatch (AddNode name' nt')
, onValueChanged: \val -> setNodeName $ const val , onValueChanged: \val -> setNodeName $ const val
, autoFocus: true , autoFocus: true
, autoSave: false
, className: "form-control" , className: "form-control"
, defaultValue: name' , defaultValue: name'
, placeholder: name' , placeholder: name'
......
...@@ -55,8 +55,8 @@ linkNodeType (Just GT.Annuaire) = GT.Corpus ...@@ -55,8 +55,8 @@ linkNodeType (Just GT.Annuaire) = GT.Corpus
linkNodeType _ = GT.Error linkNodeType _ = GT.Error
linkNode :: Record SubTreeParamsIn -> R.Element linkNode :: R2.Component SubTreeParamsIn
linkNode p = R.createElement linkNodeCpt p [] linkNode = R.createElement linkNodeCpt
linkNodeCpt :: R.Component SubTreeParamsIn linkNodeCpt :: R.Component SubTreeParamsIn
linkNodeCpt = R.hooksComponentWithModule thisModule "linkNode" cpt linkNodeCpt = R.hooksComponentWithModule thisModule "linkNode" cpt
......
...@@ -22,12 +22,12 @@ mergeNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID) ...@@ -22,12 +22,12 @@ mergeNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
mergeNodeReq session fromId toId = mergeNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("merge/" <> show toId) put_ session $ NodeAPI GT.Node (Just fromId) ("merge/" <> show toId)
mergeNode :: Record SubTreeParamsIn -> R.Element mergeNode :: R2.Component SubTreeParamsIn
mergeNode p = R.createElement mergeNodeCpt p [] mergeNode = R.createElement mergeNodeCpt
where
mergeNodeCpt :: R.Component SubTreeParamsIn
mergeNodeCpt = R.hooksComponentWithModule thisModule "mergeNode" cpt
mergeNodeCpt :: R.Component SubTreeParamsIn
mergeNodeCpt = R.hooksComponentWithModule thisModule "mergeNode" cpt
where
cpt p@{dispatch, subTreeParams, id, nodeType, session, handed} _ = do cpt p@{dispatch, subTreeParams, id, nodeType, session, handed} _ = do
action@(valAction /\ setAction) :: R.State Action <- R.useState' (MergeNode {params:Nothing}) action@(valAction /\ setAction) :: R.State Action <- R.useState' (MergeNode {params:Nothing})
......
...@@ -14,6 +14,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTre ...@@ -14,6 +14,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.SubTree (subTreeView, SubTre
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, put_) import Gargantext.Sessions (Session, put_)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Forest.Tree.Node.Action.Move" thisModule = "Gargantext.Components.Forest.Tree.Node.Action.Move"
...@@ -22,12 +23,12 @@ moveNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID) ...@@ -22,12 +23,12 @@ moveNodeReq :: Session -> GT.ID -> GT.ID -> Aff (Array GT.ID)
moveNodeReq session fromId toId = moveNodeReq session fromId toId =
put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId) put_ session $ NodeAPI GT.Node (Just fromId) ("move/" <> show toId)
moveNode :: Record SubTreeParamsIn -> R.Element moveNode :: R2.Component SubTreeParamsIn
moveNode p = R.createElement moveNodeCpt p [] moveNode = R.createElement moveNodeCpt
where
moveNodeCpt :: R.Component SubTreeParamsIn
moveNodeCpt = R.hooksComponentWithModule thisModule "moveNode" cpt
moveNodeCpt :: R.Component SubTreeParamsIn
moveNodeCpt = R.hooksComponentWithModule thisModule "moveNode" cpt
where
cpt { dispatch, handed, id, nodeType, session, subTreeParams } _ = do cpt { dispatch, handed, id, nodeType, session, subTreeParams } _ = do
action@(valAction /\ setAction) :: R.State Action <- R.useState' (MoveNode {params: Nothing}) action@(valAction /\ setAction) :: R.State Action <- R.useState' (MoveNode {params: Nothing})
......
...@@ -41,10 +41,10 @@ type SearchIFramesProps = ( ...@@ -41,10 +41,10 @@ type SearchIFramesProps = (
searchIframes :: Record SearchIFramesProps -> R.Element searchIframes :: Record SearchIFramesProps -> R.Element
searchIframes props = R.createElement searchIframesCpt props [] searchIframes props = R.createElement searchIframesCpt props []
where
searchIframesCpt :: R.Component SearchIFramesProps
searchIframesCpt = R.hooksComponentWithModule thisModule "searchIframes" cpt
searchIframesCpt :: R.Component SearchIFramesProps
searchIframesCpt = R.hooksComponentWithModule thisModule "searchIframes" cpt
where
cpt { iframeRef, search: search@(search' /\ _) } _ = do cpt { iframeRef, search: search@(search' /\ _) } _ = do
pure $ if isIsTex_Advanced search'.datafield pure $ if isIsTex_Advanced search'.datafield
then divIframe { frameSource: Istex, iframeRef, search } then divIframe { frameSource: Istex, iframeRef, search }
...@@ -62,10 +62,10 @@ type IFrameProps = ( ...@@ -62,10 +62,10 @@ type IFrameProps = (
divIframe :: Record IFrameProps -> R.Element divIframe :: Record IFrameProps -> R.Element
divIframe props = R.createElement divIframeCpt props [] divIframe props = R.createElement divIframeCpt props []
where
divIframeCpt :: R.Component IFrameProps
divIframeCpt = R.hooksComponentWithModule thisModule "divIframe" cpt
divIframeCpt :: R.Component IFrameProps
divIframeCpt = R.hooksComponentWithModule thisModule "divIframe" cpt
where
cpt { frameSource, iframeRef, search: search@(search' /\ _) } _ = do cpt { frameSource, iframeRef, search: search@(search' /\ _) } _ = do
pure $ H.div { className: "frame-search card" } pure $ H.div { className: "frame-search card" }
[ iframeWith { frameSource, iframeRef, search } ] [ iframeWith { frameSource, iframeRef, search } ]
...@@ -77,10 +77,10 @@ frameUrl Searx = "https://searx.frame.gargantext.org" -- 192.168.1.4:8080" ...@@ -77,10 +77,10 @@ frameUrl Searx = "https://searx.frame.gargantext.org" -- 192.168.1.4:8080"
iframeWith :: Record IFrameProps -> R.Element iframeWith :: Record IFrameProps -> R.Element
iframeWith props = R.createElement iframeWithCpt props [] iframeWith props = R.createElement iframeWithCpt props []
where
iframeWithCpt :: R.Component IFrameProps
iframeWithCpt = R.hooksComponentWithModule thisModule "iframeWith" cpt
iframeWithCpt :: R.Component IFrameProps
iframeWithCpt = R.hooksComponentWithModule thisModule "iframeWith" cpt
where
cpt { frameSource, iframeRef, search: (search /\ setSearch) } _ = cpt { frameSource, iframeRef, search: (search /\ setSearch) } _ =
pure $ H.iframe { src: src frameSource search.term pure $ H.iframe { src: src frameSource search.term
, width: "100%" , width: "100%"
......
...@@ -26,10 +26,10 @@ type Props = ( langs :: Array Lang ...@@ -26,10 +26,10 @@ type Props = ( langs :: Array Lang
searchBar :: Record Props -> R.Element searchBar :: Record Props -> R.Element
searchBar props = R.createElement searchBarCpt props [] searchBar props = R.createElement searchBarCpt props []
where
searchBarCpt :: R.Component Props
searchBarCpt = R.hooksComponentWithModule thisModule "searchBar" cpt
searchBarCpt :: R.Component Props
searchBarCpt = R.hooksComponentWithModule thisModule "searchBar" cpt
where
cpt {langs, onSearch, search: search@(s /\ _), session} _ = do cpt {langs, onSearch, search: search@(s /\ _), session} _ = do
--onSearchChange session s --onSearchChange session s
pure $ H.div { className: "search-bar" } pure $ H.div { className: "search-bar" }
......
...@@ -266,10 +266,10 @@ type DatabaseInputProps = ( ...@@ -266,10 +266,10 @@ type DatabaseInputProps = (
databaseInput :: R2.Component DatabaseInputProps databaseInput :: R2.Component DatabaseInputProps
databaseInput = R.createElement databaseInputCpt databaseInput = R.createElement databaseInputCpt
where
databaseInputCpt :: R.Component DatabaseInputProps
databaseInputCpt = R.hooksComponentWithModule thisModule "databaseInput" cpt
databaseInputCpt :: R.Component DatabaseInputProps
databaseInputCpt = R.hooksComponentWithModule thisModule "databaseInput" cpt
where
cpt { databases cpt { databases
, search: (search /\ setSearch) } _ = do , search: (search /\ setSearch) } _ = do
pure $ pure $
...@@ -338,10 +338,10 @@ type SearchInputProps = ...@@ -338,10 +338,10 @@ type SearchInputProps =
searchInput :: Record SearchInputProps -> R.Element searchInput :: Record SearchInputProps -> R.Element
searchInput p = R.createElement searchInputCpt p [] searchInput p = R.createElement searchInputCpt p []
where
searchInputCpt :: R.Component SearchInputProps
searchInputCpt = R.hooksComponentWithModule thisModule "searchInput" cpt
searchInputCpt :: R.Component SearchInputProps
searchInputCpt = R.hooksComponentWithModule thisModule "searchInput" cpt
where
cpt {search: (search@{ term } /\ setSearch)} _ = do cpt {search: (search@{ term } /\ setSearch)} _ = do
valueRef <- R.useRef term valueRef <- R.useRef term
...@@ -349,7 +349,6 @@ searchInput p = R.createElement searchInputCpt p [] ...@@ -349,7 +349,6 @@ searchInput p = R.createElement searchInputCpt p []
inputWithEnter { onEnter: onEnter valueRef setSearch inputWithEnter { onEnter: onEnter valueRef setSearch
, onValueChanged: onValueChanged valueRef , onValueChanged: onValueChanged valueRef
, autoFocus: false , autoFocus: false
, autoSave: true
, className: "form-control" , className: "form-control"
, defaultValue: R.readRef valueRef , defaultValue: R.readRef valueRef
, placeholder: "Your query here" , placeholder: "Your query here"
...@@ -380,10 +379,10 @@ type SubmitButtonProps = ...@@ -380,10 +379,10 @@ type SubmitButtonProps =
submitButton :: Record SubmitButtonProps -> R.Element submitButton :: Record SubmitButtonProps -> R.Element
submitButton p = R.createElement submitButtonComponent p [] submitButton p = R.createElement submitButtonComponent p []
where
submitButtonComponent :: R.Component SubmitButtonProps
submitButtonComponent = R.hooksComponentWithModule thisModule "submitButton" cpt
submitButtonComponent :: R.Component SubmitButtonProps
submitButtonComponent = R.hooksComponentWithModule thisModule "submitButton" cpt
where
cpt {onSearch, search: (mySearch /\ _), session} _ = cpt {onSearch, search: (mySearch /\ _), session} _ =
pure $ pure $
H.button { className: "btn btn-primary" H.button { className: "btn btn-primary"
......
...@@ -57,10 +57,10 @@ instance encodeJsonShareNodeParams :: Argonaut.EncodeJson ShareNodeParams where ...@@ -57,10 +57,10 @@ instance encodeJsonShareNodeParams :: Argonaut.EncodeJson ShareNodeParams where
------------------------------------------------------------------------ ------------------------------------------------------------------------
shareNode :: Record SubTreeParamsIn -> R.Element shareNode :: Record SubTreeParamsIn -> R.Element
shareNode p = R.createElement shareNodeCpt p [] shareNode p = R.createElement shareNodeCpt p []
where
shareNodeCpt :: R.Component SubTreeParamsIn
shareNodeCpt = R.hooksComponentWithModule thisModule "shareNode" cpt
shareNodeCpt :: R.Component SubTreeParamsIn
shareNodeCpt = R.hooksComponentWithModule thisModule "shareNode" cpt
where
cpt p@{dispatch, subTreeParams, id, nodeType, session, handed} _ = do cpt p@{dispatch, subTreeParams, id, nodeType, session, handed} _ = do
action@(valAction /\ setAction) :: R.State Action <- R.useState' (Action.SharePublic {params: Nothing}) action@(valAction /\ setAction) :: R.State Action <- R.useState' (Action.SharePublic {params: Nothing})
......
...@@ -71,10 +71,10 @@ type UploadFile = ...@@ -71,10 +71,10 @@ type UploadFile =
uploadFileView :: Record Props -> R.Element uploadFileView :: Record Props -> R.Element
uploadFileView props = R.createElement uploadFileViewCpt props [] uploadFileView props = R.createElement uploadFileViewCpt props []
where
uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt
uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = R.hooksComponentWithModule thisModule "uploadFileView" cpt
where
cpt {dispatch, id, nodeType} _ = do cpt {dispatch, id, nodeType} _ = do
mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing
fileType@(_ /\ setFileType) <- R.useState' CSV fileType@(_ /\ setFileType) <- R.useState' CSV
......
...@@ -48,10 +48,10 @@ type CommonProps = ...@@ -48,10 +48,10 @@ type CommonProps =
nodePopupView :: Record NodePopupProps -> R.Element nodePopupView :: Record NodePopupProps -> R.Element
nodePopupView p = R.createElement nodePopupCpt p [] nodePopupView p = R.createElement nodePopupCpt p []
where
nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = R.hooksComponentWithModule thisModule "nodePopupView" cpt
nodePopupCpt :: R.Component NodePopupProps
nodePopupCpt = R.hooksComponentWithModule thisModule "nodePopupView" cpt
where
cpt p _ = do cpt p _ = do
renameIsOpen <- R.useState' false renameIsOpen <- R.useState' false
...@@ -254,10 +254,10 @@ type PanelActionProps = ...@@ -254,10 +254,10 @@ type PanelActionProps =
panelAction :: Record PanelActionProps -> R.Element panelAction :: Record PanelActionProps -> R.Element
panelAction p = R.createElement panelActionCpt p [] panelAction p = R.createElement panelActionCpt p []
where
panelActionCpt :: R.Component PanelActionProps
panelActionCpt = R.hooksComponentWithModule thisModule "panelAction" cpt
panelActionCpt :: R.Component PanelActionProps
panelActionCpt = R.hooksComponentWithModule thisModule "panelAction" cpt
where
cpt {action: Documentation nodeType} _ = actionDoc nodeType cpt {action: Documentation nodeType} _ = actionDoc nodeType
cpt {action: Download, id, nodeType, session} _ = actionDownload nodeType id session cpt {action: Download, id, nodeType, session} _ = actionDownload nodeType id session
cpt {action: Upload, dispatch, id, nodeType, session} _ = actionUpload nodeType id session dispatch cpt {action: Upload, dispatch, id, nodeType, session} _ = actionUpload nodeType id session dispatch
...@@ -274,13 +274,13 @@ panelAction p = R.createElement panelActionCpt p [] ...@@ -274,13 +274,13 @@ panelAction p = R.createElement panelActionCpt p []
----------- -----------
-- Functions using SubTree -- Functions using SubTree
cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do cpt {action: Merge {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do
pure $ mergeNode {dispatch, id, nodeType, session, subTreeParams, handed} pure $ mergeNode {dispatch, id, nodeType, session, subTreeParams, handed} []
cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do cpt {action: Move {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do
pure $ moveNode {dispatch, id, nodeType, session, subTreeParams, handed} pure $ moveNode {dispatch, id, nodeType, session, subTreeParams, handed} []
cpt {action: Link {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do cpt {action: Link {subTreeParams}, dispatch, id, nodeType, session, handed} _ = do
pure $ linkNode {dispatch, id, nodeType, session, subTreeParams, handed} pure $ linkNode {dispatch, id, nodeType, session, subTreeParams, handed} []
----------- -----------
cpt {action : Share, dispatch, id, name } _ = do cpt {action : Share, dispatch, id, name } _ = do
......
...@@ -65,12 +65,12 @@ type TextInputBoxProps = ...@@ -65,12 +65,12 @@ type TextInputBoxProps =
) )
textInputBox :: R2.Component TextInputBoxProps textInputBox :: R2.Component TextInputBoxProps
textInputBox props@{ boxName } = R.createElement el props textInputBox = R.createElement textInputBoxCpt
where
el :: R.Component TextInputBoxProps
el = R.hooksComponentWithModule thisModule (boxName <> "Box") cpt
cpt p@{ boxAction, dispatch, id, isOpen: (true /\ setIsOpen), text } _ = do textInputBoxCpt :: R.Component TextInputBoxProps
textInputBoxCpt = R.hooksComponentWithModule thisModule "textInputBox" cpt
where
cpt p@{ boxAction, boxName, dispatch, id, isOpen: (true /\ setIsOpen), text } _ = do
renameNodeNameRef <- R.useRef text renameNodeNameRef <- R.useRef text
pure $ H.div { className: "from-group row" } pure $ H.div { className: "from-group row" }
...@@ -85,7 +85,6 @@ textInputBox props@{ boxName } = R.createElement el props ...@@ -85,7 +85,6 @@ textInputBox props@{ boxName } = R.createElement el props
onEnter: submit renameNodeNameRef onEnter: submit renameNodeNameRef
, onValueChanged: R.setRef renameNodeNameRef , onValueChanged: R.setRef renameNodeNameRef
, autoFocus: true , autoFocus: true
, autoSave: false
, className: "form-control" , className: "form-control"
, defaultValue: text , defaultValue: text
, placeholder: (boxName <> " Node") , placeholder: (boxName <> " Node")
...@@ -105,8 +104,8 @@ textInputBox props@{ boxName } = R.createElement el props ...@@ -105,8 +104,8 @@ textInputBox props@{ boxName } = R.createElement el props
, title: "Cancel" , title: "Cancel"
} [] } []
submit renameNodeNameRef _ = do submit renameNodeNameRef _ = do
setIsOpen $ const false
launchAff_ $ dispatch ( boxAction $ R.readRef renameNodeNameRef ) launchAff_ $ dispatch ( boxAction $ R.readRef renameNodeNameRef )
setIsOpen $ const false
cpt { isOpen: (false /\ _) } _ = pure $ H.div {} [] cpt { isOpen: (false /\ _) } _ = pure $ H.div {} []
-- | END Rename Box -- | END Rename Box
...@@ -292,10 +291,10 @@ type NodeLinkProps = ( ...@@ -292,10 +291,10 @@ type NodeLinkProps = (
nodeLink :: R2.Component NodeLinkProps nodeLink :: R2.Component NodeLinkProps
nodeLink = R.createElement nodeLinkCpt nodeLink = R.createElement nodeLinkCpt
where
nodeLinkCpt :: R.Component NodeLinkProps
nodeLinkCpt = R.hooksComponentWithModule thisModule "nodeLink" cpt
nodeLinkCpt :: R.Component NodeLinkProps
nodeLinkCpt = R.hooksComponentWithModule thisModule "nodeLink" cpt
where
cpt { folderOpen: (_ /\ setFolderOpen) cpt { folderOpen: (_ /\ setFolderOpen)
, frontends , frontends
, handed , handed
...@@ -348,10 +347,10 @@ type NodeTextProps = ...@@ -348,10 +347,10 @@ type NodeTextProps =
nodeText :: Record NodeTextProps -> R.Element nodeText :: Record NodeTextProps -> R.Element
nodeText p = R.createElement nodeTextCpt p [] nodeText p = R.createElement nodeTextCpt p []
where
nodeTextCpt :: R.Component NodeTextProps
nodeTextCpt = R.hooksComponentWithModule thisModule "nodeText" cpt
nodeTextCpt :: R.Component NodeTextProps
nodeTextCpt = R.hooksComponentWithModule thisModule "nodeText" cpt
where
cpt { isSelected: true, name } _ = do cpt { isSelected: true, name } _ = do
pure $ H.u {} [ pure $ H.u {} [
H.b {} [ H.b {} [
......
...@@ -36,10 +36,10 @@ type SubTreeParamsProps = ...@@ -36,10 +36,10 @@ type SubTreeParamsProps =
subTreeView :: Record SubTreeParamsProps -> R.Element subTreeView :: Record SubTreeParamsProps -> R.Element
subTreeView props = R.createElement subTreeViewCpt props [] subTreeView props = R.createElement subTreeViewCpt props []
where
subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = R.hooksComponentWithModule thisModule "subTreeView" cpt
subTreeViewCpt :: R.Component SubTreeParamsProps
subTreeViewCpt = R.hooksComponentWithModule thisModule "subTreeView" cpt
where
cpt params@{ action cpt params@{ action
, dispatch , dispatch
, handed , handed
......
...@@ -54,10 +54,10 @@ type Props = ...@@ -54,10 +54,10 @@ type Props =
sidebar :: Record Props -> R.Element sidebar :: Record Props -> R.Element
sidebar props = R.createElement sidebarCpt props [] sidebar props = R.createElement sidebarCpt props []
where
sidebarCpt :: R.Component Props
sidebarCpt = R.hooksComponentWithModule thisModule "sidebar" cpt
sidebarCpt :: R.Component Props
sidebarCpt = R.hooksComponentWithModule thisModule "sidebar" cpt
where
cpt {showSidePanel: (GET.Closed /\ _)} _children = do cpt {showSidePanel: (GET.Closed /\ _)} _children = do
pure $ RH.div {} [] pure $ RH.div {} []
cpt {showSidePanel: (GET.InitialClosed /\ _)} _children = do cpt {showSidePanel: (GET.InitialClosed /\ _)} _children = do
......
...@@ -16,7 +16,6 @@ type Props a = ( ...@@ -16,7 +16,6 @@ type Props a = (
, onValueChanged :: String -> Effect Unit , onValueChanged :: String -> Effect Unit
, autoFocus :: Boolean , autoFocus :: Boolean
, autoSave :: Boolean
, className :: String , className :: String
, defaultValue :: String , defaultValue :: String
, placeholder :: String , placeholder :: String
...@@ -25,13 +24,13 @@ type Props a = ( ...@@ -25,13 +24,13 @@ type Props a = (
inputWithEnter :: forall a. Record (Props a) -> R.Element inputWithEnter :: forall a. Record (Props a) -> R.Element
inputWithEnter props = R.createElement inputWithEnterCpt props [] inputWithEnter props = R.createElement inputWithEnterCpt props []
where
inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = R.hooksComponentWithModule thisModule "inputWithEnter" cpt
inputWithEnterCpt :: forall a. R.Component (Props a)
inputWithEnterCpt = R.hooksComponentWithModule thisModule "inputWithEnter" cpt
where
cpt props@{ onEnter, onValueChanged cpt props@{ onEnter, onValueChanged
, autoFocus, autoSave, className, defaultValue, placeholder } _ = do , autoFocus, className, defaultValue, placeholder } _ = do
pure $ H.input { on: { blur: \_ -> if autoSave then onEnter unit else pure unit pure $ H.input { on: { blur: \_ -> onEnter unit
, input: onInput , input: onInput
, keyPress: onKeyPress } , keyPress: onKeyPress }
, autoFocus , autoFocus
...@@ -41,11 +40,7 @@ inputWithEnter props = R.createElement inputWithEnterCpt props [] ...@@ -41,11 +40,7 @@ inputWithEnter props = R.createElement inputWithEnterCpt props []
, type: props.type } , type: props.type }
where where
onInput e = do onInput e = onValueChanged $ R.unsafeEventValue e
if autoSave then
onValueChanged $ R.unsafeEventValue e
else
pure unit
onKeyPress e = do onKeyPress e = do
char <- R2.keyCode e char <- R2.keyCode e
......
...@@ -274,10 +274,9 @@ type Props = ( ...@@ -274,10 +274,9 @@ type Props = (
loadedNgramsTable :: R2.Component Props loadedNgramsTable :: R2.Component Props
loadedNgramsTable = R.createElement loadedNgramsTableCpt loadedNgramsTable = R.createElement loadedNgramsTableCpt
loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
where where
loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
cpt props@{ afterSync cpt props@{ afterSync
, appReload , appReload
, asyncTasksRef , asyncTasksRef
...@@ -524,10 +523,9 @@ type MainNgramsTableProps = ( ...@@ -524,10 +523,9 @@ type MainNgramsTableProps = (
mainNgramsTable :: R2.Component MainNgramsTableProps mainNgramsTable :: R2.Component MainNgramsTableProps
mainNgramsTable = R.createElement mainNgramsTableCpt mainNgramsTable = R.createElement mainNgramsTableCpt
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
where where
mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
cpt props@{ afterSync cpt props@{ afterSync
, appReload , appReload
, asyncTasksRef , asyncTasksRef
...@@ -631,10 +629,10 @@ type MainNgramsTablePaintProps = ( ...@@ -631,10 +629,10 @@ type MainNgramsTablePaintProps = (
mainNgramsTablePaint :: R2.Component MainNgramsTablePaintProps mainNgramsTablePaint :: R2.Component MainNgramsTablePaintProps
mainNgramsTablePaint = R.createElement mainNgramsTablePaintCpt mainNgramsTablePaint = R.createElement mainNgramsTablePaintCpt
where
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where
cpt props@{ afterSync cpt props@{ afterSync
, appReload , appReload
, asyncTasksRef , asyncTasksRef
...@@ -670,10 +668,10 @@ type MainNgramsTablePaintNoCacheProps = ( ...@@ -670,10 +668,10 @@ type MainNgramsTablePaintNoCacheProps = (
mainNgramsTablePaintNoCache :: R2.Component MainNgramsTablePaintNoCacheProps mainNgramsTablePaintNoCache :: R2.Component MainNgramsTablePaintNoCacheProps
mainNgramsTablePaintNoCache = R.createElement mainNgramsTablePaintNoCacheCpt mainNgramsTablePaintNoCache = R.createElement mainNgramsTablePaintNoCacheCpt
where
mainNgramsTablePaintNoCacheCpt :: R.Component MainNgramsTablePaintNoCacheProps
mainNgramsTablePaintNoCacheCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintNoCache" cpt
mainNgramsTablePaintNoCacheCpt :: R.Component MainNgramsTablePaintNoCacheProps
mainNgramsTablePaintNoCacheCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaintNoCache" cpt
where
cpt props@{ afterSync cpt props@{ afterSync
, appReload , appReload
, asyncTasksRef , asyncTasksRef
......
...@@ -1129,10 +1129,10 @@ type SyncResetButtonsProps = ...@@ -1129,10 +1129,10 @@ type SyncResetButtonsProps =
syncResetButtons :: Record SyncResetButtonsProps -> R.Element syncResetButtons :: Record SyncResetButtonsProps -> R.Element
syncResetButtons p = R.createElement syncResetButtonsCpt p [] syncResetButtons p = R.createElement syncResetButtonsCpt p []
where
syncResetButtonsCpt :: R.Component SyncResetButtonsProps
syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" cpt
syncResetButtonsCpt :: R.Component SyncResetButtonsProps
syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" cpt
where
cpt { afterSync, ngramsLocalPatch, performAction } _ = do cpt { afterSync, ngramsLocalPatch, performAction } _ = do
synchronizing@(s /\ setSynchronizing) <- R.useState' false synchronizing@(s /\ setSynchronizing) <- R.useState' false
......
...@@ -128,7 +128,6 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt ...@@ -128,7 +128,6 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt
H.div { className: "input-group col-sm-6" } [ H.div { className: "input-group col-sm-6" } [
inputWithEnter { inputWithEnter {
autoFocus: true autoFocus: true
, autoSave: false
, className: "form-control" , className: "form-control"
, defaultValue: R.readRef valueRef , defaultValue: R.readRef valueRef
, onEnter: onClick , onEnter: onClick
......
...@@ -144,10 +144,10 @@ type NgramsViewTabsProps = ( ...@@ -144,10 +144,10 @@ type NgramsViewTabsProps = (
ngramsView :: R2.Component NgramsViewTabsProps ngramsView :: R2.Component NgramsViewTabsProps
ngramsView = R.createElement ngramsViewCpt ngramsView = R.createElement ngramsViewCpt
where
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
ngramsViewCpt :: R.Component NgramsViewTabsProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, cacheState , cacheState
......
...@@ -47,10 +47,10 @@ type KeyProps = ...@@ -47,10 +47,10 @@ type KeyProps =
corpusLayout :: Record Props -> R.Element corpusLayout :: Record Props -> R.Element
corpusLayout props = R.createElement corpusLayoutCpt props [] corpusLayout props = R.createElement corpusLayoutCpt props []
where
corpusLayoutCpt :: R.Component Props
corpusLayoutCpt = R.hooksComponentWithModule thisModule "corpusLayout" cpt
corpusLayoutCpt :: R.Component Props
corpusLayoutCpt = R.hooksComponentWithModule thisModule "corpusLayout" cpt
where
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
let sid = sessionId session let sid = sessionId session
...@@ -59,10 +59,9 @@ corpusLayout props = R.createElement corpusLayoutCpt props [] ...@@ -59,10 +59,9 @@ corpusLayout props = R.createElement corpusLayoutCpt props []
corpusLayoutWithKey :: Record KeyProps -> R.Element corpusLayoutWithKey :: Record KeyProps -> R.Element
corpusLayoutWithKey props = R.createElement corpusLayoutWithKeyCpt props [] corpusLayoutWithKey props = R.createElement corpusLayoutWithKeyCpt props []
corpusLayoutWithKeyCpt :: R.Component KeyProps
corpusLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "corpusLayoutWithKey" cpt
where where
corpusLayoutWithKeyCpt :: R.Component KeyProps
corpusLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "corpusLayoutWithKey" cpt
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
reload <- GUR.new reload <- GUR.new
...@@ -77,10 +76,10 @@ type ViewProps = ...@@ -77,10 +76,10 @@ type ViewProps =
corpusLayoutView :: Record ViewProps -> R.Element corpusLayoutView :: Record ViewProps -> R.Element
corpusLayoutView props = R.createElement corpusLayoutViewCpt props [] corpusLayoutView props = R.createElement corpusLayoutViewCpt props []
where
corpusLayoutViewCpt :: R.Component ViewProps
corpusLayoutViewCpt = R.hooksComponentWithModule thisModule "corpusLayoutView" cpt
corpusLayoutViewCpt :: R.Component ViewProps
corpusLayoutViewCpt = R.hooksComponentWithModule thisModule "corpusLayoutView" cpt
where
cpt {corpus: (NodePoly {hyperdata: Hyperdata {fields}}), nodeId, reload, session} _ = do cpt {corpus: (NodePoly {hyperdata: Hyperdata {fields}}), nodeId, reload, session} _ = do
let fieldsWithIndex = List.mapWithIndex (\idx -> \t -> Tuple idx t) fields let fieldsWithIndex = List.mapWithIndex (\idx -> \t -> Tuple idx t) fields
fieldsS <- R.useState' fieldsWithIndex fieldsS <- R.useState' fieldsWithIndex
...@@ -105,7 +104,7 @@ corpusLayoutView props = R.createElement corpusLayoutViewCpt props [] ...@@ -105,7 +104,7 @@ corpusLayoutView props = R.createElement corpusLayoutViewCpt props []
, H.div {} , H.div {}
[ fieldsCodeEditor { fields: fieldsS [ fieldsCodeEditor { fields: fieldsS
, nodeId , nodeId
, session } ] , session } [] ]
, H.div { className: "row" } , H.div { className: "row" }
[ H.div { className: "btn btn-secondary" [ H.div { className: "btn btn-secondary"
, on: { click: onClickAdd fieldsS } , on: { click: onClickAdd fieldsS }
...@@ -139,14 +138,14 @@ type FieldsCodeEditorProps = ...@@ -139,14 +138,14 @@ type FieldsCodeEditorProps =
| LoadProps | LoadProps
) )
fieldsCodeEditor :: Record FieldsCodeEditorProps -> R.Element fieldsCodeEditor :: R2.Component FieldsCodeEditorProps
fieldsCodeEditor props = R.createElement fieldsCodeEditorCpt props [] fieldsCodeEditor = R.createElement fieldsCodeEditorCpt
where
fieldsCodeEditorCpt :: R.Component FieldsCodeEditorProps
fieldsCodeEditorCpt = R.hooksComponentWithModule thisModule "fieldsCodeEditorCpt" cpt
fieldsCodeEditorCpt :: R.Component FieldsCodeEditorProps
fieldsCodeEditorCpt = R.hooksComponentWithModule thisModule "fieldsCodeEditorCpt" cpt
where
cpt {nodeId, fields: fS@(fields /\ _), session} _ = do cpt {nodeId, fields: fS@(fields /\ _), session} _ = do
masterKey <- R.useState' 0 masterKey <- GUR.new
pure $ H.div {} $ List.toUnfoldable (editors masterKey) pure $ H.div {} $ List.toUnfoldable (editors masterKey)
where where
...@@ -170,13 +169,13 @@ fieldsCodeEditor props = R.createElement fieldsCodeEditorCpt props [] ...@@ -170,13 +169,13 @@ fieldsCodeEditor props = R.createElement fieldsCodeEditorCpt props []
List.modifyAt idx (\(Tuple _ (Field f)) -> Tuple idx (Field $ f { typ = typ })) fields List.modifyAt idx (\(Tuple _ (Field f)) -> Tuple idx (Field $ f { typ = typ })) fields
onMoveDown :: GUR.ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit onMoveDown :: GUR.ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveDown (_ /\ setMasterKey) (fs /\ setFields) idx _ = do onMoveDown masterKey (_ /\ setFields) idx _ = do
setMasterKey $ (+) 1 GUR.bump masterKey
setFields $ recomputeIndices <<< (GDA.swapList idx (idx + 1)) setFields $ recomputeIndices <<< (GDA.swapList idx (idx + 1))
onMoveUp :: GUR.ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit onMoveUp :: GUR.ReloadS -> R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
onMoveUp (_ /\ setMasterKey) (_ /\ setFields) idx _ = do onMoveUp masterKey (_ /\ setFields) idx _ = do
setMasterKey $ (+) 1 GUR.bump masterKey
setFields $ recomputeIndices <<< (GDA.swapList idx (idx - 1)) setFields $ recomputeIndices <<< (GDA.swapList idx (idx - 1))
onRemove :: R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit onRemove :: R.State FTFieldsWithIndex -> Index -> Unit -> Effect Unit
...@@ -210,10 +209,10 @@ type FieldCodeEditorProps = ...@@ -210,10 +209,10 @@ type FieldCodeEditorProps =
fieldCodeEditorWrapper :: Record FieldCodeEditorProps -> R.Element fieldCodeEditorWrapper :: Record FieldCodeEditorProps -> R.Element
fieldCodeEditorWrapper props = R.createElement fieldCodeEditorWrapperCpt props [] fieldCodeEditorWrapper props = R.createElement fieldCodeEditorWrapperCpt props []
where
fieldCodeEditorWrapperCpt :: R.Component FieldCodeEditorProps
fieldCodeEditorWrapperCpt = R.hooksComponentWithModule thisModule "fieldCodeEditorWrapperCpt" cpt
fieldCodeEditorWrapperCpt :: R.Component FieldCodeEditorProps
fieldCodeEditorWrapperCpt = R.hooksComponentWithModule thisModule "fieldCodeEditorWrapperCpt" cpt
where
cpt props@{canMoveDown, canMoveUp, field: Field {name, typ}, onMoveDown, onMoveUp, onRemove, onRename} _ = do cpt props@{canMoveDown, canMoveUp, field: Field {name, typ}, onMoveDown, onMoveUp, onRemove, onRename} _ = do
pure $ H.div { className: "row card" } [ pure $ H.div { className: "row card" } [
H.div { className: "card-header" } [ H.div { className: "card-header" } [
...@@ -259,10 +258,10 @@ type RenameableProps = ...@@ -259,10 +258,10 @@ type RenameableProps =
renameable :: Record RenameableProps -> R.Element renameable :: Record RenameableProps -> R.Element
renameable props = R.createElement renameableCpt props [] renameable props = R.createElement renameableCpt props []
where
renameableCpt :: R.Component RenameableProps
renameableCpt = R.hooksComponentWithModule thisModule "renameableCpt" cpt
renameableCpt :: R.Component RenameableProps
renameableCpt = R.hooksComponentWithModule thisModule "renameableCpt" cpt
where
cpt {onRename, text} _ = do cpt {onRename, text} _ = do
isEditing <- R.useState' false isEditing <- R.useState' false
state <- R.useState' text state <- R.useState' text
...@@ -289,10 +288,10 @@ type RenameableTextProps = ...@@ -289,10 +288,10 @@ type RenameableTextProps =
renameableText :: Record RenameableTextProps -> R.Element renameableText :: Record RenameableTextProps -> R.Element
renameableText props = R.createElement renameableTextCpt props [] renameableText props = R.createElement renameableTextCpt props []
where
renameableTextCpt :: R.Component RenameableTextProps
renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cpt
renameableTextCpt :: R.Component RenameableTextProps
renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cpt
where
cpt {isEditing: (false /\ setIsEditing), state: (text /\ _)} _ = do cpt {isEditing: (false /\ setIsEditing), state: (text /\ _)} _ = do
pure $ H.div { className: "input-group" } pure $ H.div { className: "input-group" }
[ H.input { className: "form-control" [ H.input { className: "form-control"
...@@ -308,7 +307,6 @@ renameableText props = R.createElement renameableTextCpt props [] ...@@ -308,7 +307,6 @@ renameableText props = R.createElement renameableTextCpt props []
pure $ H.div { className: "input-group" } pure $ H.div { className: "input-group" }
[ inputWithEnter { [ inputWithEnter {
autoFocus: false autoFocus: false
, autoSave: false
, className: "form-control text" , className: "form-control text"
, defaultValue: text , defaultValue: text
, onEnter: submit , onEnter: submit
...@@ -328,10 +326,10 @@ renameableText props = R.createElement renameableTextCpt props [] ...@@ -328,10 +326,10 @@ renameableText props = R.createElement renameableTextCpt props []
fieldCodeEditor :: Record FieldCodeEditorProps -> R.Element fieldCodeEditor :: Record FieldCodeEditorProps -> R.Element
fieldCodeEditor props = R.createElement fieldCodeEditorCpt props [] fieldCodeEditor props = R.createElement fieldCodeEditorCpt props []
where
fieldCodeEditorCpt :: R.Component FieldCodeEditorProps
fieldCodeEditorCpt = R.hooksComponentWithModule thisModule "fieldCodeEditorCpt" cpt
fieldCodeEditorCpt :: R.Component FieldCodeEditorProps
fieldCodeEditorCpt = R.hooksComponentWithModule thisModule "fieldCodeEditorCpt" cpt
where
cpt {field: Field {typ: typ@(Haskell {haskell})}, onChange} _ = do cpt {field: Field {typ: typ@(Haskell {haskell})}, onChange} _ = do
pure $ CE.codeEditor {code: haskell, defaultCodeType: CE.Haskell, onChange: changeCode onChange typ} pure $ CE.codeEditor {code: haskell, defaultCodeType: CE.Haskell, onChange: changeCode onChange typ}
......
...@@ -29,10 +29,10 @@ cacheName = "metrics" ...@@ -29,10 +29,10 @@ cacheName = "metrics"
metricsLoadView :: forall a. Record (MetricsLoadViewProps a) -> R.Element metricsLoadView :: forall a. Record (MetricsLoadViewProps a) -> R.Element
metricsLoadView p = R.createElement metricsLoadViewCpt p [] metricsLoadView p = R.createElement metricsLoadViewCpt p []
where
metricsLoadViewCpt :: R.Component (MetricsLoadViewProps a)
metricsLoadViewCpt = R.hooksComponentWithModule thisModule "metricsLoadView" cpt
metricsLoadViewCpt :: forall a. R.Component (MetricsLoadViewProps a)
metricsLoadViewCpt = R.hooksComponentWithModule thisModule "metricsLoadView" cpt
where
cpt { getMetrics, loaded, path, reload, session } _ = do cpt { getMetrics, loaded, path, reload, session } _ = do
useLoader (fst reload /\ path) (getMetrics session) $ \l -> useLoader (fst reload /\ path) (getMetrics session) $ \l ->
loaded { path, reload, session } l loaded { path, reload, session } l
...@@ -48,10 +48,11 @@ type MetricsWithCacheLoadViewProps res ret = ( ...@@ -48,10 +48,11 @@ type MetricsWithCacheLoadViewProps res ret = (
metricsWithCacheLoadView :: forall res ret. DecodeJson res => metricsWithCacheLoadView :: forall res ret. DecodeJson res =>
Record (MetricsWithCacheLoadViewProps res ret) -> R.Element Record (MetricsWithCacheLoadViewProps res ret) -> R.Element
metricsWithCacheLoadView p = R.createElement metricsWithCacheLoadViewCpt p [] metricsWithCacheLoadView p = R.createElement metricsWithCacheLoadViewCpt p []
where
metricsWithCacheLoadViewCpt :: R.Component (MetricsWithCacheLoadViewProps res ret)
metricsWithCacheLoadViewCpt = R.hooksComponentWithModule thisModule "metricsWithCacheLoadView" cpt
metricsWithCacheLoadViewCpt :: forall res ret. DecodeJson res =>
R.Component (MetricsWithCacheLoadViewProps res ret)
metricsWithCacheLoadViewCpt = R.hooksComponentWithModule thisModule "metricsWithCacheLoadView" cpt
where
cpt { getMetricsHash, handleResponse, loaded, mkRequest, path, reload, session } _ = do cpt { getMetricsHash, handleResponse, loaded, mkRequest, path, reload, session } _ = do
useLoaderWithCacheAPI { cacheEndpoint: (getMetricsHash session) useLoaderWithCacheAPI { cacheEndpoint: (getMetricsHash session)
, handleResponse , handleResponse
......
...@@ -81,10 +81,10 @@ mkRequest session (_ /\ path@{ corpusId, limit, listId, tabType }) = GUC.makeGet ...@@ -81,10 +81,10 @@ mkRequest session (_ /\ path@{ corpusId, limit, listId, tabType }) = GUC.makeGet
histo :: Record Props -> R.Element histo :: Record Props -> R.Element
histo props = R.createElement histoCpt props [] histo props = R.createElement histoCpt props []
where
histoCpt :: R.Component Props
histoCpt = R.hooksComponentWithModule thisModule "histo" cpt
histoCpt :: R.Component Props
histoCpt = R.hooksComponentWithModule thisModule "histo" cpt
where
cpt { path, session } _ = do cpt { path, session } _ = do
reload <- R.useState' 0 reload <- R.useState' 0
pure $ metricsWithCacheLoadView { pure $ metricsWithCacheLoadView {
......
module Gargantext.Components.Nodes.Corpus.Dashboard where module Gargantext.Components.Nodes.Corpus.Dashboard where
import DOM.Simple.Console (log2) import Gargantext.Components.Nodes.Types
import Gargantext.Prelude
import DOM.Simple.Console (log, log2)
import Data.Array as A import Data.Array as A
import Data.List as List import Data.List as List
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
...@@ -9,19 +12,16 @@ import Data.Tuple.Nested ((/\)) ...@@ -9,19 +12,16 @@ import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Effect.Aff (launchAff_) import Effect.Aff (launchAff_)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor) import Gargantext.Components.Nodes.Corpus (fieldsCodeEditor)
import Gargantext.Components.Nodes.Corpus.Chart.Predefined as P import Gargantext.Components.Nodes.Corpus.Chart.Predefined as P
import Gargantext.Components.Nodes.Dashboard.Types as DT import Gargantext.Components.Nodes.Dashboard.Types as DT
import Gargantext.Components.Nodes.Types
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
import Gargantext.Types (NodeID) import Gargantext.Types (NodeID)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR import Gargantext.Utils.Reload as GUR
import Reactix as R
import Reactix.DOM.HTML as H
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Nodes.Corpus.Dashboard" thisModule = "Gargantext.Components.Nodes.Corpus.Dashboard"
...@@ -33,10 +33,10 @@ type Props = ...@@ -33,10 +33,10 @@ type Props =
dashboardLayout :: R2.Component Props dashboardLayout :: R2.Component Props
dashboardLayout = R.createElement dashboardLayoutCpt dashboardLayout = R.createElement dashboardLayoutCpt
where
dashboardLayoutCpt :: R.Component Props
dashboardLayoutCpt = R.hooksComponentWithModule thisModule "dashboardLayout" cpt
dashboardLayoutCpt :: R.Component Props
dashboardLayoutCpt = R.hooksComponentWithModule thisModule "dashboardLayout" cpt
where
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
let sid = sessionId session let sid = sessionId session
...@@ -49,10 +49,10 @@ type KeyProps = ( ...@@ -49,10 +49,10 @@ type KeyProps = (
dashboardLayoutWithKey :: R2.Component KeyProps dashboardLayoutWithKey :: R2.Component KeyProps
dashboardLayoutWithKey = R.createElement dashboardLayoutWithKeyCpt dashboardLayoutWithKey = R.createElement dashboardLayoutWithKeyCpt
where
dashboardLayoutWithKeyCpt :: R.Component KeyProps
dashboardLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "dashboardLayoutWithKey" cpt
dashboardLayoutWithKeyCpt :: R.Component KeyProps
dashboardLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "dashboardLayoutWithKey" cpt
where
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
reload <- GUR.new reload <- GUR.new
...@@ -63,15 +63,15 @@ dashboardLayoutWithKey = R.createElement dashboardLayoutWithKeyCpt ...@@ -63,15 +63,15 @@ dashboardLayoutWithKey = R.createElement dashboardLayoutWithKeyCpt
, corpusId: parentId , corpusId: parentId
, defaultListId: 0 , defaultListId: 0
, fields , fields
, key: show $ GUR.value reload
, nodeId , nodeId
, onChange: onChange nodeId reload (DT.Hyperdata h) , onChange: onChange nodeId reload (DT.Hyperdata h)
, session } [] , session } []
where where
onChange :: NodeID -> GUR.ReloadS -> DT.Hyperdata -> Array P.PredefinedChart -> Effect Unit onChange :: NodeID -> GUR.ReloadS -> DT.Hyperdata -> { charts :: Array P.PredefinedChart
onChange nodeId' reload (DT.Hyperdata h) charts = do , fields :: List.List FTField } -> Effect Unit
onChange nodeId' reload (DT.Hyperdata h) { charts, fields } = do
launchAff_ do launchAff_ do
DT.saveDashboard { hyperdata: DT.Hyperdata $ h { charts = charts } DT.saveDashboard { hyperdata: DT.Hyperdata $ h { charts = charts, fields = fields }
, nodeId:nodeId' , nodeId:nodeId'
, session } , session }
liftEffect $ GUR.bump reload liftEffect $ GUR.bump reload
...@@ -81,18 +81,61 @@ type LoadedProps = ...@@ -81,18 +81,61 @@ type LoadedProps =
, corpusId :: NodeID , corpusId :: NodeID
, defaultListId :: Int , defaultListId :: Int
, fields :: List.List FTField , fields :: List.List FTField
, key :: String , onChange :: { charts :: Array P.PredefinedChart
, onChange :: Array P.PredefinedChart -> Effect Unit , fields :: List.List FTField } -> Effect Unit
| Props | Props
) )
dashboardLayoutLoaded :: R2.Component LoadedProps dashboardLayoutLoaded :: R2.Component LoadedProps
dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt
where
dashboardLayoutLoadedCpt :: R.Component LoadedProps
dashboardLayoutLoadedCpt = R.hooksComponentWithModule thisModule "dashboardLayoutLoaded" cpt
dashboardLayoutLoadedCpt :: R.Component LoadedProps
dashboardLayoutLoadedCpt = R.hooksComponentWithModule thisModule "dashboardLayoutLoaded" cpt
where
cpt props@{ charts, corpusId, defaultListId, fields, nodeId, onChange, session } _ = do cpt props@{ charts, corpusId, defaultListId, fields, nodeId, onChange, session } _ = do
pure $ H.div {}
[ H.div { className: "row" }
[ H.div { className: "col-12" }
([ H.h1 {} [ H.text "Board" ]
, H.p {} [ H.text "Summary of all your charts here" ]
] <> chartsEls <> [addNew])
]
, dashboardCodeEditor { fields
, nodeId
, onChange: \fs -> onChange { charts, fields: fs }
, session } []
]
where
addNew = H.div { className: "row" } [
H.span { className: "btn btn-secondary"
, on: { click: onClickAddChart }} [ H.span { className: "fa fa-plus" } [] ]
]
where
onClickAddChart _ = onChange { charts: A.cons P.CDocsHistogram charts
, fields }
chartsEls = A.mapWithIndex chartIdx charts
chartIdx idx chart =
renderChart { chart, corpusId, defaultListId, onChange: onChangeChart, onRemove, session } []
where
onChangeChart c = do
onChange { charts: fromMaybe charts (A.modifyAt idx (\_ -> c) charts)
, fields }
onRemove _ = onChange { charts: fromMaybe charts $ A.deleteAt idx charts
, fields }
type CodeEditorProps =
( fields :: List.List FTField
, onChange :: List.List FTField -> Effect Unit
| Props
)
dashboardCodeEditor :: R2.Component CodeEditorProps
dashboardCodeEditor = R.createElement dashboardCodeEditorCpt
dashboardCodeEditorCpt :: R.Component CodeEditorProps
dashboardCodeEditorCpt = R.hooksComponentWithModule thisModule "dashboardCodeEditor" cpt
where
cpt props@{ fields, nodeId, onChange, session } _ = do
let fieldsWithIndex = List.mapWithIndex (\idx -> \t -> Tuple idx t) fields let fieldsWithIndex = List.mapWithIndex (\idx -> \t -> Tuple idx t) fields
fieldsS <- R.useState' fieldsWithIndex fieldsS <- R.useState' fieldsWithIndex
fieldsRef <- R.useRef fields fieldsRef <- R.useRef fields
...@@ -105,18 +148,20 @@ dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt ...@@ -105,18 +148,20 @@ dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt
R.setRef fieldsRef fields R.setRef fieldsRef fields
snd fieldsS $ const fieldsWithIndex snd fieldsS $ const fieldsWithIndex
pure $ H.div {} pure $ R.fragment
[ H.div { className: "row" } [ H.div { className: "row" }
[ H.div { className: "col-12" } [ H.div { className: "btn btn-secondary " <> (saveEnabled fieldsWithIndex fieldsS)
([ H.h1 {} [ H.text "Board" ] , on: { click: onClickSave fieldsS }
, H.p {} [ H.text "Summary of all your charts here" ] }
] <> chartsEls <> [addNew]) [ H.span { className: "fa fa-floppy-o" } [ ]
]
] ]
, H.div { className: "row" } , H.div { className: "row" }
[ H.div { className: "col-12" } [ H.div { className: "col-12" }
[ fieldsCodeEditor { fields: fieldsS [ fieldsCodeEditor { fields: fieldsS
, nodeId , nodeId
, session } ] , session} []
]
] ]
, H.div { className: "row" } , H.div { className: "row" }
[ H.div { className: "btn btn-secondary" [ H.div { className: "btn btn-secondary"
...@@ -127,19 +172,18 @@ dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt ...@@ -127,19 +172,18 @@ dashboardLayoutLoaded = R.createElement dashboardLayoutLoadedCpt
] ]
] ]
where where
addNew = H.div { className: "row" } [ saveEnabled :: FTFieldsWithIndex -> R.State FTFieldsWithIndex -> String
H.span { className: "btn btn-secondary" saveEnabled fs (fsS /\ _) = if fs == fsS then "disabled" else "enabled"
, on: { click: onClickAddChart }} [ H.span { className: "fa fa-plus" } [] ]
] onClickSave :: forall e. R.State FTFieldsWithIndex -> e -> Effect Unit
where onClickSave (fields /\ _) _ = do
onClickAddChart _ = onChange $ A.cons P.CDocsHistogram charts log "[dashboardCodeEditor] saving (TODO)"
chartsEls = A.mapWithIndex chartIdx charts onChange $ snd <$> fields
chartIdx idx chart = -- launchAff_ do
renderChart { chart, corpusId, defaultListId, onChange: onChangeChart, onRemove, session } [] -- saveCorpus $ { hyperdata: Hyperdata {fields: (\(Tuple _ f) -> f) <$> fieldsS}
where -- , nodeId
onChangeChart c = do -- , session }
onChange $ fromMaybe charts (A.modifyAt idx (\_ -> c) charts)
onRemove _ = onChange $ fromMaybe charts $ A.deleteAt idx charts
onClickAddField :: forall e. R.State FTFieldsWithIndex -> e -> Effect Unit onClickAddField :: forall e. R.State FTFieldsWithIndex -> e -> Effect Unit
onClickAddField (_ /\ setFieldsS) _ = do onClickAddField (_ /\ setFieldsS) _ = do
setFieldsS $ \fieldsS -> List.snoc fieldsS $ Tuple (List.length fieldsS) defaultField setFieldsS $ \fieldsS -> List.snoc fieldsS $ Tuple (List.length fieldsS) defaultField
...@@ -155,10 +199,10 @@ type PredefinedChartProps = ...@@ -155,10 +199,10 @@ type PredefinedChartProps =
renderChart :: R2.Component PredefinedChartProps renderChart :: R2.Component PredefinedChartProps
renderChart = R.createElement renderChartCpt renderChart = R.createElement renderChartCpt
where
renderChartCpt :: R.Component PredefinedChartProps
renderChartCpt = R.hooksComponentWithModule thisModule "renderChart" cpt
renderChartCpt :: R.Component PredefinedChartProps
renderChartCpt = R.hooksComponentWithModule thisModule "renderChart" cpt
where
cpt { chart, corpusId, defaultListId, onChange, onRemove, session } _ = do cpt { chart, corpusId, defaultListId, onChange, onRemove, session } _ = do
pure $ H.div { className: "row chart card" } pure $ H.div { className: "row chart card" }
[ H.div { className: "card-header" } [ H.div { className: "card-header" }
...@@ -168,6 +212,7 @@ renderChart = R.createElement renderChartCpt ...@@ -168,6 +212,7 @@ renderChart = R.createElement renderChartCpt
, on: { change: onSelectChange } , on: { change: onSelectChange }
} (option <$> P.allPredefinedCharts) } (option <$> P.allPredefinedCharts)
] ]
, H.div { className: "col-9" } []
, H.div { className: "col-1" } , H.div { className: "col-1" }
[ H.span { className: "btn btn-danger" [ H.span { className: "btn btn-danger"
, on: { click: onRemoveClick }} [ H.span { className: "fa fa-trash" } [] ] , on: { click: onRemoveClick }} [ H.span { className: "fa fa-trash" } [] ]
......
...@@ -54,10 +54,10 @@ type DocViewProps = ( ...@@ -54,10 +54,10 @@ type DocViewProps = (
docView :: R2.Component DocViewProps docView :: R2.Component DocViewProps
docView = R.createElement docViewCpt docView = R.createElement docViewCpt
where
docViewCpt :: R.Component DocViewProps
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
docViewCpt :: R.Component DocViewProps
docViewCpt = R.hooksComponentWithModule thisModule "docView" cpt
where
cpt { path cpt { path
, loaded: loaded@{ ngramsTable: Versioned { data: initTable }, document } , loaded: loaded@{ ngramsTable: Versioned { data: initTable }, document }
, state: state@({ ngramsVersion: version, ngramsLocalPatch } /\ _) , state: state@({ ngramsVersion: version, ngramsLocalPatch } /\ _)
......
...@@ -35,10 +35,10 @@ type ListsWithForest = ( ...@@ -35,10 +35,10 @@ type ListsWithForest = (
listsWithForest :: R2.Component ListsWithForest listsWithForest :: R2.Component ListsWithForest
listsWithForest = R.createElement listsWithForestCpt listsWithForest = R.createElement listsWithForestCpt
where
listsWithForestCpt :: R.Component ListsWithForest
listsWithForestCpt = R.hooksComponentWithModule thisModule "listsWithForest" cpt
listsWithForestCpt :: R.Component ListsWithForest
listsWithForestCpt = R.hooksComponentWithModule thisModule "listsWithForest" cpt
where
cpt { forestProps cpt { forestProps
, listsProps: listsProps@{ session } } _ = do , listsProps: listsProps@{ session } } _ = do
controls <- initialControls controls <- initialControls
...@@ -58,10 +58,10 @@ type TopBarProps = ( ...@@ -58,10 +58,10 @@ type TopBarProps = (
topBar :: R2.Component TopBarProps topBar :: R2.Component TopBarProps
topBar = R.createElement topBarCpt topBar = R.createElement topBarCpt
where
topBarCpt :: R.Component TopBarProps
topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt
topBarCpt :: R.Component TopBarProps
topBarCpt = R.hooksComponentWithModule thisModule "topBar" cpt
where
cpt { controls } _ = do cpt { controls } _ = do
-- empty for now because the button is moved to the side panel -- empty for now because the button is moved to the side panel
pure $ H.div {} [] pure $ H.div {} []
...@@ -93,10 +93,10 @@ type WithTreeProps = ( ...@@ -93,10 +93,10 @@ type WithTreeProps = (
listsLayout :: R2.Component Props listsLayout :: R2.Component Props
listsLayout = R.createElement listsLayoutCpt listsLayout = R.createElement listsLayoutCpt
where
listsLayoutCpt :: R.Component Props
listsLayoutCpt = R.hooksComponentWithModule thisModule "listsLayout" cpt
listsLayoutCpt :: R.Component Props
listsLayoutCpt = R.hooksComponentWithModule thisModule "listsLayout" cpt
where
cpt path@{ nodeId, session } _ = do cpt path@{ nodeId, session } _ = do
let sid = sessionId session let sid = sessionId session
...@@ -109,10 +109,10 @@ type KeyProps = ( ...@@ -109,10 +109,10 @@ type KeyProps = (
listsLayoutWithKey :: Record KeyProps -> R.Element listsLayoutWithKey :: Record KeyProps -> R.Element
listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props [] listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
where
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where
cpt { appReload cpt { appReload
, asyncTasksRef , asyncTasksRef
, controls , controls
...@@ -164,10 +164,10 @@ type SidePanelProps = ( ...@@ -164,10 +164,10 @@ type SidePanelProps = (
sidePanel :: R2.Component SidePanelProps sidePanel :: R2.Component SidePanelProps
sidePanel = R.createElement sidePanelCpt sidePanel = R.createElement sidePanelCpt
where
sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
sidePanelCpt :: R.Component SidePanelProps
sidePanelCpt = R.hooksComponentWithModule thisModule "sidePanel" cpt
where
cpt { controls: { triggers: { toggleSidePanel cpt { controls: { triggers: { toggleSidePanel
, triggerSidePanel , triggerSidePanel
} } } }
...@@ -208,10 +208,10 @@ type SidePanelDocView = ( ...@@ -208,10 +208,10 @@ type SidePanelDocView = (
sidePanelDocView :: R2.Component SidePanelDocView sidePanelDocView :: R2.Component SidePanelDocView
sidePanelDocView = R.createElement sidePanelDocViewCpt sidePanelDocView = R.createElement sidePanelDocViewCpt
where
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt = R.hooksComponentWithModule thisModule "sidePanelDocView" cpt
sidePanelDocViewCpt :: R.Component SidePanelDocView
sidePanelDocViewCpt = R.hooksComponentWithModule thisModule "sidePanelDocView" cpt
where
cpt { session } _ = do cpt { session } _ = do
-- pure $ H.h4 {} [ H.text txt ] -- pure $ H.h4 {} [ H.text txt ]
pure $ H.div {} [ H.text "Hello ngrams" ] pure $ H.div {} [ H.text "Hello ngrams" ]
...@@ -58,10 +58,9 @@ initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Nothing, searchTy ...@@ -58,10 +58,9 @@ initialParams = stateParams {page: 1, pageSize: PS10, orderBy: Nothing, searchTy
tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element tableHeaderLayout :: Record TableHeaderLayoutProps -> R.Element
tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props [] tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout" cpt
where where
tableHeaderLayoutCpt :: R.Component TableHeaderLayoutProps
tableHeaderLayoutCpt = R.hooksComponentWithModule thisModule "tableHeaderLayout" cpt
cpt { afterCacheStateChange, cacheState, date, desc, query, title, user } _ = cpt { afterCacheStateChange, cacheState, date, desc, query, title, user } _ =
pure $ R.fragment pure $ R.fragment
[ R2.row [ R2.row
...@@ -115,10 +114,9 @@ tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props [] ...@@ -115,10 +114,9 @@ tableHeaderLayout props = R.createElement tableHeaderLayoutCpt props []
table :: Record Props -> R.Element table :: Record Props -> R.Element
table props = R.createElement tableCpt props [] table props = R.createElement tableCpt props []
tableCpt :: R.Component Props
tableCpt = R.hooksComponentWithModule thisModule "table" cpt
where where
tableCpt :: R.Component Props
tableCpt = R.hooksComponentWithModule thisModule "table" cpt
cpt {container, syncResetButton, colNames, wrapColElts, totalRecords, rows, params} _ = do cpt {container, syncResetButton, colNames, wrapColElts, totalRecords, rows, params} _ = do
let let
state = paramsState $ fst params state = paramsState $ fst params
...@@ -194,10 +192,10 @@ type SizeDDProps = ...@@ -194,10 +192,10 @@ type SizeDDProps =
sizeDD :: Record SizeDDProps -> R.Element sizeDD :: Record SizeDDProps -> R.Element
sizeDD p = R.createElement sizeDDCpt p [] sizeDD p = R.createElement sizeDDCpt p []
where
sizeDDCpt :: R.Component SizeDDProps
sizeDDCpt = R.hooksComponentWithModule thisModule "sizeDD" cpt
sizeDDCpt :: R.Component SizeDDProps
sizeDDCpt = R.hooksComponentWithModule thisModule "sizeDD" cpt
where
cpt {params: params /\ setParams} _ = do cpt {params: params /\ setParams} _ = do
pure $ H.span {} [ pure $ H.span {} [
R2.select { className, defaultValue: show pageSize, on: {change} } sizes R2.select { className, defaultValue: show pageSize, on: {change} } sizes
......
...@@ -151,10 +151,10 @@ type MenuButtonProps = ( ...@@ -151,10 +151,10 @@ type MenuButtonProps = (
menuButton :: R2.Component MenuButtonProps menuButton :: R2.Component MenuButtonProps
menuButton = R.createElement menuButtonCpt menuButton = R.createElement menuButtonCpt
where
menuButtonCpt :: R.Component MenuButtonProps
menuButtonCpt = R.hooksComponentWithModule thisModule "menuButton" cpt
menuButtonCpt :: R.Component MenuButtonProps
menuButtonCpt = R.hooksComponentWithModule thisModule "menuButton" cpt
where
cpt { element: LiNav { title, href, icon, text }, show: (_ /\ setShow) } _ = do cpt { element: LiNav { title, href, icon, text }, show: (_ /\ setShow) } _ = do
pure $ H.a { className: "dropdown-toggle navbar-text" pure $ H.a { className: "dropdown-toggle navbar-text"
-- , data: {toggle: "dropdown"} -- , data: {toggle: "dropdown"}
...@@ -173,10 +173,10 @@ type MenuElementsProps = ( ...@@ -173,10 +173,10 @@ type MenuElementsProps = (
menuElements :: R2.Component MenuElementsProps menuElements :: R2.Component MenuElementsProps
menuElements = R.createElement menuElementsCpt menuElements = R.createElement menuElementsCpt
where
menuElementsCpt :: R.Component MenuElementsProps
menuElementsCpt = R.hooksComponentWithModule thisModule "menuElements" cpt
menuElementsCpt :: R.Component MenuElementsProps
menuElementsCpt = R.hooksComponentWithModule thisModule "menuElements" cpt
where
cpt { show: false /\ _ } _ = do cpt { show: false /\ _ } _ = do
pure $ H.div {} [] pure $ H.div {} []
cpt { elements, show: (true /\ setShow) } _ = do cpt { elements, show: (true /\ setShow) } _ = do
......
...@@ -45,6 +45,35 @@ import Web.Storage.Storage (Storage, getItem, setItem) ...@@ -45,6 +45,35 @@ import Web.Storage.Storage (Storage, getItem, setItem)
type Component p = Record p -> Array R.Element -> R.Element type Component p = Record p -> Array R.Element -> R.Element
-- newtypes
type NTHooksComponent props = props -> Array R.Element -> R.Hooks R.Element
newtype NTComponent p = NTComponent (EffectFn1 p R.Element)
class NTIsComponent component (props :: Type) children
| component -> props, component -> children where
ntCreateElement :: component -> props -> children -> R.Element
instance componentIsNTComponent :: NTIsComponent (NTComponent props) props (Array R.Element) where
ntCreateElement = R.rawCreateElement
-- | Turns a `HooksComponent` function into a Component
ntHooksComponent :: forall props. String -> NTHooksComponent props -> NTComponent props
ntHooksComponent name c = NTComponent $ named name $ mkEffectFn1 c'
where
c' :: props -> Effect R.Element
c' props = R.runHooks $ c props (children props)
ntHooksComponentWithModule :: forall props. Module -> String -> NTHooksComponent props -> NTComponent props
ntHooksComponentWithModule module' name c = ntHooksComponent (module' <> "." <> name) c
---------------------------
-- TODO Copied from reactix, export these:
children :: forall a. a -> Array R.Element
children a = react .. "Children" ... "toArray" $ [ (a .. "children") ]
type Module = String
---------------------------
newtype Point = Point { x :: Number, y :: Number } newtype Point = Point { x :: Number, y :: Number }
-- a reducer function living in effector, for useReductor -- a reducer function living in effector, for useReductor
......
module Gargantext.Utils.Reload where module Gargantext.Utils.Reload where
import Data.Maybe (Maybe(..), fromMaybe) import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect) import Effect (Effect)
import Reactix as R import Reactix as R
......
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