where
import Control.Lens hiding (makeLenses, both, Level)
-
-import Data.List (head,null,(++),sortOn)
-import Gargantext.Prelude hiding (head)
+import Data.List (null,(++),sortOn)
+import Gargantext.Prelude
import Gargantext.Viz.Phylo
import Gargantext.Viz.Phylo.Tools
where
--------------------------------------
lvl' :: Level
- lvl' = getNodeLevel $ head $ nested
+ lvl' = getNodeLevel $ head' "toNestedView" nested
--------------------------------------
nested :: [PhyloNode]
nested = foldl (\ns'' n -> let nIds' = getNodeParentsId n
in map (\n' -> if elem (getNodeId n') nIds'
- then n' & phylo_nodeLevelChilds %~ (++ [n])
+ then n' & pn_childs %~ (++ [n])
else n') ns'') ns' ns
--------------------------------------
-- | To process a DisplayMode to a PhyloView
-processDisplay :: DisplayMode -> PhyloView -> PhyloView
-processDisplay d v = case d of
- Flat -> v
- Nested -> let ns = sortOn getNodeLevel $ v ^. phylo_viewNodes
- lvl = getNodeLevel $ head ns
- in v & phylo_viewNodes .~ toNestedView (filter (\n -> lvl == getNodeLevel n) ns)
- (filter (\n -> lvl < getNodeLevel n) ns)
- --_ -> panic "[ERR][Viz.Phylo.Example.processDisplay] display not found"
+processDisplay :: DisplayMode -> ExportMode -> PhyloView -> PhyloView
+processDisplay d e v = case e of
+ Json -> case d of
+ Flat -> v
+ Nested -> let ns = sortOn getNodeLevel $ v ^. pv_nodes
+ lvl = getNodeLevel $ head' "processDisplay" ns
+ in v & pv_nodes .~ toNestedView (filter (\n -> lvl == getNodeLevel n) ns)
+ (filter (\n -> lvl < getNodeLevel n) ns)
+ _ -> v