Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
f0c995d6
Commit
f0c995d6
authored
Jan 28, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[tree] fix for incorrect, nested component definition
parent
ba53ab68
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
56 deletions
+99
-56
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+70
-56
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+29
-0
No files found.
src/Gargantext/Components/Forest/Tree.purs
View file @
f0c995d6
...
@@ -153,7 +153,7 @@ loadedTreeViewFirstLevelCpt = R.hooksComponentWithModule thisModule "loadedTreeV
...
@@ -153,7 +153,7 @@ loadedTreeViewFirstLevelCpt = R.hooksComponentWithModule thisModule "loadedTreeV
} _ = 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
...
@@ -161,34 +161,40 @@ loadedTreeViewFirstLevelCpt = R.hooksComponentWithModule thisModule "loadedTreeV
...
@@ -161,34 +161,40 @@ loadedTreeViewFirstLevelCpt = R.hooksComponentWithModule thisModule "loadedTreeV
, openNodes
, openNodes
, reload
, reload
, reloadTree: reload
, reloadTree: reload
, render: toHtmlFirstLevel
, session
, session
-- , tasks
-- , tasks
, tree
, 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 toHtmlFirstLevelCpt
toHtmlFirstLevel = R2.ntCreateElement toHtmlFirstLevelCpt
where
-- 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
toHtmlFirstLevelCpt :: R.Component ToHtmlProps
toHtmlFirstLevelCpt = R.hooksComponentWithModule thisModule "toHtmlFirstLevel" cpt
cpt p@{ appReload
toHtmlFirstLevelCpt :: R2.NTComponent ToHtmlProps
toHtmlFirstLevelCpt = R2.ntHooksComponentWithModule thisModule "toHtmlFirstLevel" cpt
where
cpt (ToHtmlProps p@{ appReload
, asyncTasks
, asyncTasks
, currentRoute
, currentRoute
, frontends
, frontends
...
@@ -196,6 +202,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
...
@@ -196,6 +202,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
, openNodes
, openNodes
, reload
, reload
, reloadTree
, reloadTree
, render
, session
, session
, tree: tree@(NTree (LNode { id
, tree: tree@(NTree (LNode { id
, name
, name
...
@@ -203,7 +210,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
...
@@ -203,7 +210,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
}
}
) 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)
...
@@ -253,6 +260,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
...
@@ -253,6 +260,7 @@ toHtmlFirstLevel = R.createElement toHtmlFirstLevelCpt
, handed
, handed
, id: cId
, id: cId
, reloadTree
, reloadTree
, render
}
}
) []
) []
) $ sorted publicizedChildren
) $ sorted publicizedChildren
...
@@ -267,18 +275,19 @@ type ChildNodeFirstLevelProps = (
...
@@ -267,18 +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 childNodeFirstLevelCpt
childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
where
-- 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
-- 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
...
@@ -289,6 +298,7 @@ childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
...
@@ -289,6 +298,7 @@ childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
, openNodes
, openNodes
, reload
, reload
, reloadTree
, reloadTree
, render
, session } _ = do
, session } _ = do
cptReload <- GUR.new
cptReload <- GUR.new
...
@@ -302,6 +312,7 @@ childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
...
@@ -302,6 +312,7 @@ childNodeFirstLevel = R.createElement childNodeFirstLevelCpt
, openNodes
, openNodes
, reload: cptReload
, reload: cptReload
, reloadTree
, reloadTree
, render
, session
, session
, tree: loaded } []
, tree: loaded } []
...
@@ -314,30 +325,33 @@ type ChildNodeFirstLevelPaintProps = (
...
@@ -314,30 +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 childNodeFirstLevelPaintCpt
childNodeFirstLevelPaint = R.createElement childNodeFirstLevelPaintCpt
where
-- 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
-- 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
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 ]
...
...
src/Gargantext/Utils/Reactix.purs
View file @
f0c995d6
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment