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