Commit 4f073cb3 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[Tree] fixes to texts/lists pages

parent 03fbb087
...@@ -25,10 +25,10 @@ instance decodeNodePoly :: (DecodeJson a) ...@@ -25,10 +25,10 @@ instance decodeNodePoly :: (DecodeJson a)
parentId <- obj .? "parentId" parentId <- obj .? "parentId"
name <- obj .? "name" name <- obj .? "name"
date <- obj .? "date" date <- obj .? "date"
hyperdata <- obj .? "hyperdata" hyperdata <- obj .? "hyperdata"
hyperdata' <- decodeJson hyperdata hyperdata' <- decodeJson hyperdata
pure $ NodePoly { id : id pure $ NodePoly { id : id
, typename : typename , typename : typename
, userId : userId , userId : userId
......
...@@ -334,7 +334,7 @@ nodeTypeUrl Nodes = "nodes" ...@@ -334,7 +334,7 @@ nodeTypeUrl Nodes = "nodes"
nodeTypeUrl NodeUser = "user" nodeTypeUrl NodeUser = "user"
nodeTypeUrl NodeContact = "contact" nodeTypeUrl NodeContact = "contact"
nodeTypeUrl Tree = "tree" nodeTypeUrl Tree = "tree"
nodeTypeUrl NodeList = "list" nodeTypeUrl NodeList = "lists"
nodeTypeUrl Texts = "texts" nodeTypeUrl Texts = "texts"
------------------------------------------------------------ ------------------------------------------------------------
......
...@@ -21,9 +21,9 @@ import Gargantext.Utils.Reactix as R2 ...@@ -21,9 +21,9 @@ import Gargantext.Utils.Reactix as R2
layout :: Spec {} {nodeId :: Int} Void layout :: Spec {} {nodeId :: Int} Void
layout = layout =
R2.elSpec $ R.hooksComponent "ListsLoader" \{nodeId} _ -> R2.elSpec $ R.hooksComponent "ListsLoader" \{nodeId} _ ->
useLoader nodeId getCorpus $ \{path: corpusId useLoader nodeId getCorpus $ \{loaded: corpusData} ->
,loaded: corpusData} -> let {corpusId
let {corpusNode: ,corpusNode:
NodePoly { name: title NodePoly { name: title
, date: date' , date: date'
, hyperdata: CorpusInfo corpus , hyperdata: CorpusInfo corpus
...@@ -41,11 +41,13 @@ layout = ...@@ -41,11 +41,13 @@ layout =
------------------------------------------------------------------------ ------------------------------------------------------------------------
getCorpus :: Int -> Aff CorpusData getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do getCorpus listId = do
-- fetch corpus via lists parentId
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get $ toUrl Back Corpus $ Just listId
corpusNode <- get $ toUrl Back Corpus $ Just corpusId corpusNode <- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) -> Just (NodePoly { id: defaultListId }) ->
pure {corpusNode, defaultListId} pure {corpusId, corpusNode, defaultListId}
Nothing -> Nothing ->
throwError $ error "Missing default list" throwError $ error "Missing default list"
...@@ -43,7 +43,9 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where ...@@ -43,7 +43,9 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
let totalRecords = 47361 -- TODO let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords} pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
type CorpusData = {corpusNode :: NodePoly CorpusInfo, defaultListId :: Int} type CorpusData = { corpusId :: Int
, corpusNode :: NodePoly CorpusInfo
, defaultListId :: Int}
type PropsRow = ( corpusId :: Int, corpusData :: CorpusData ) type PropsRow = ( corpusId :: Int, corpusData :: CorpusData )
type Props = Record PropsRow type Props = Record PropsRow
......
...@@ -21,9 +21,9 @@ import Gargantext.Utils.Reactix as R2 ...@@ -21,9 +21,9 @@ import Gargantext.Utils.Reactix as R2
layout :: Spec {} {nodeId :: Int} Void layout :: Spec {} {nodeId :: Int} Void
layout = layout =
R2.elSpec $ R.hooksComponent "TextsLoader" \{nodeId} _ -> R2.elSpec $ R.hooksComponent "TextsLoader" \{nodeId} _ ->
useLoader nodeId getCorpus $ \{path: corpusId useLoader nodeId getCorpus $ \{loaded: corpusData} ->
,loaded: corpusData} -> let {corpusId
let {corpusNode: ,corpusNode:
NodePoly { name: title NodePoly { name: title
, date: date' , date: date'
, hyperdata: CorpusInfo corpus , hyperdata: CorpusInfo corpus
...@@ -41,11 +41,13 @@ layout = ...@@ -41,11 +41,13 @@ layout =
------------------------------------------------------------------------ ------------------------------------------------------------------------
getCorpus :: Int -> Aff CorpusData getCorpus :: Int -> Aff CorpusData
getCorpus corpusId = do getCorpus textsId = do
-- fetch corpus via texts parentId
(NodePoly {parentId: corpusId} :: NodePoly {}) <- get $ toUrl Back Corpus $ Just textsId
corpusNode <- get $ toUrl Back Corpus $ Just corpusId corpusNode <- get $ toUrl Back Corpus $ Just corpusId
defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId defaultListIds <- get $ toUrl Back (Children NodeList 0 1 Nothing) $ Just corpusId
case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of case (head defaultListIds :: Maybe (NodePoly HyperdataList)) of
Just (NodePoly { id: defaultListId }) -> Just (NodePoly { id: defaultListId }) ->
pure {corpusNode, defaultListId} pure {corpusId, corpusNode, defaultListId}
Nothing -> Nothing ->
throwError $ error "Missing default list" throwError $ error "Missing default list"
...@@ -43,7 +43,9 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where ...@@ -43,7 +43,9 @@ instance decodeCorpusInfo :: DecodeJson CorpusInfo where
let totalRecords = 47361 -- TODO let totalRecords = 47361 -- TODO
pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords} pure $ CorpusInfo {title, desc, query, authors, chart, totalRecords}
type CorpusData = {corpusNode :: NodePoly CorpusInfo, defaultListId :: Int} type CorpusData = { corpusId :: Int
, corpusNode :: NodePoly CorpusInfo
, defaultListId :: Int}
type PropsRow = ( corpusId :: Int, corpusData :: CorpusData ) type PropsRow = ( corpusId :: Int, corpusData :: CorpusData )
type Props = Record PropsRow type Props = Record PropsRow
......
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