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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
gargantext
purescript-gargantext
Commits
235b9ba9
Commit
235b9ba9
authored
Oct 17, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACT] FOREST cleaning unused code.
parent
d3533356
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
71 deletions
+53
-71
NodeActions.purs
src/Gargantext/Components/Forest/NodeActions.purs
+42
-36
Tree.purs
src/Gargantext/Components/Forest/Tree.purs
+11
-35
No files found.
src/Gargantext/Components/Forest/NodeActions.purs
View file @
235b9ba9
...
...
@@ -8,42 +8,6 @@ import Data.Array (filter)
import Reactix.DOM.HTML as H
import Effect.Aff (Aff, launchAff, runAff)
data NodeAction = Rename
| Documentation NodeType
| Add (Array NodeType)
| Search
| Download | Upload | Refresh
| Move | Clone | Delete
| Share
data ButtonType = Edit | Click | Pop
instance eqButtonType :: Eq ButtonType where
eq Edit Edit = true
eq Click Click = true
eq Pop Pop = true
eq _ _ = false
buttonType :: NodeAction -> ButtonType
buttonType Rename = Edit
buttonType (Add _) = Pop
buttonType Search = Pop
buttonType _ = Click
data Buttons = Buttons { edit :: Array NodeAction
, click :: Array NodeAction
, pop :: Array NodeAction
}
buttons nt = Buttons {edit, click, pop}
where
edit = filter' Edit
click = filter' Click
pop = filter' Pop
filter' b = filter (\a -> buttonType a == b)
(nodeActions nt)
{-
-- | TODO use Set (needs Ord instance for NodeType)
...
...
@@ -82,6 +46,48 @@ nodeActions Texts = [Download, Upload, Delete]
nodeActions _ = []
------------------------------------------------------------------------
data NodeAction = Rename
| Documentation NodeType
| Add (Array NodeType)
| Search
| Download | Upload | Refresh
| Move | Clone | Delete
| Share
data ButtonType = Edit | Click | Pop
instance eqButtonType :: Eq ButtonType where
eq Edit Edit = true
eq Click Click = true
eq Pop Pop = true
eq _ _ = false
buttonType :: NodeAction -> ButtonType
buttonType Rename = Edit
buttonType (Add _) = Pop
buttonType Search = Pop
buttonType _ = Click
data Buttons = Buttons { edit :: Array NodeAction
, click :: Array NodeAction
, pop :: Array NodeAction
}
buttons nt = Buttons {edit, click, pop}
where
edit = filter' Edit
click = filter' Click
pop = filter' Pop
filter' b = filter (\a -> buttonType a == b)
(nodeActions nt)
---------------------------------------------------------
src/Gargantext/Components/Forest/Tree.purs
View file @
235b9ba9
...
...
@@ -28,28 +28,14 @@ import Prelude (Unit, bind, discard, map, pure, void, ($), (+), (<>))
import Reactix as R
import Reactix.DOM.HTML as H
type Open = Boolean
type URL = String
------------------------------------------------------------------------
type Props = ( root :: ID
, mCurrentRoute :: Maybe AppRoute
, session :: Session
, frontends :: Frontends
)
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, session :: Session
)
-- Keep only the nodes matching the predicate.
-- The root of the tree is always kept.
filterNTree :: forall a. (a -> Boolean) -> NTree a -> NTree a
filterNTree p (NTree x ary) =
NTree x $ map (filterNTree p) $ filter (\(NTree a _) -> p a) ary
------------------------------------------------------------------------
-----------------
treeView :: Record Props -> R.Element
treeView props = R.createElement treeViewCpt props []
...
...
@@ -69,6 +55,14 @@ treeLoadView reload p = R.createElement el p []
useLoader root (loadNode session) $ \loaded ->
loadedTreeView reload {tree: loaded, mCurrentRoute, session, frontends}
----------------
type TreeViewProps = ( tree :: FTree
, mCurrentRoute :: Maybe AppRoute
, frontends :: Frontends
, session :: Session
)
loadedTreeView :: R.State Reload -> Record TreeViewProps -> R.Element
loadedTreeView reload p = R.createElement el p []
where
...
...
@@ -79,13 +73,7 @@ loadedTreeView reload p = R.createElement el p []
pure $ H.div {className: "tree"}
[ toHtml reload treeState session frontends mCurrentRoute ]
-- | To HTML
------------------------------------------------------------------------
toHtml :: R.State Reload
-> R.State Tree
-> Session
...
...
@@ -147,15 +135,3 @@ performAction session _ ({tree: NTree (LNode {id}) _} /\ _) (UploadFile fileType
liftEffect $ log2 "uploaded:" hashes
-- TO be deleted
{-
mapFTree :: (FTree -> FTree) -> Tree -> Tree
mapFTree f s@{tree} = s {tree = f tree}
-}
{-
fnTransform :: LNode -> FTree
fnTransform n = NTree n []
-}
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